{"id":674,"hash":"d2de6585141c11a281448dc162a1932fc3e04a42483dbf9ffa6c8f437bcab6db","pattern":"Invalid Chai property in Vitest","full_message":"I have this Vitest test:\n\n    import React from 'react';\n    import { expect, it, vi } from 'vitest';\n    import { render, screen } from '@testing-library/react';\n    import { StyledNativeTimePicker } from \n       '../timePicker/StyledNativeTimePicker.jsx';\n\n    ...\n\n    it('Shows the time correctly', async () => {\n    const time = '12:00';\n    render(\n        <StyledNativeTimePicker\n            time={time}\n            timeChanged={() => {}}\n        ></StyledNativeTimePicker>\n    );\n    const testInput = screen.getByRole('input', { type: 'time' });\n    expect(testInput).toHaveValue(time);\n   });\n   ...\n\nNow I get this error Error: Invalid Chai property: toHaveValue. Any Idea why when Chai is not installed?","ecosystem":"npm","package_name":"react-testing-library","package_version":null,"solution":"First you need to create setupTests.js file, then connect it to the config. You may have to install jsdom as a dependency to the project.\n\nsetupTests.js\n\nimport '@testing-library/jest-dom';\n\nvite.config.js\n\nimport { defineConfig } from 'vite';\n\nexport default defineConfig({\n  test: {\n    globals: true,\n    environment: \"jsdom\",\n    setupFiles: [\"./setupTests.js\"],\n  },\n});\n\nlinks: Github problem and Configuring Vitest","confidence":0.95,"source":"stackoverflow","source_url":"https://stackoverflow.com/questions/77611978/invalid-chai-property-in-vitest","votes":10,"created_at":"2026-04-19T04:51:28.853804+00:00","updated_at":"2026-04-19T04:51:28.853804+00:00"}