Skip to content

Commit

Permalink
test: add jest-dom matchers and eslint plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
kretajak committed Nov 11, 2024
1 parent e65fd89 commit d016dd4
Show file tree
Hide file tree
Showing 6 changed files with 89 additions and 3 deletions.
2 changes: 2 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"react-hooks",
"import",
"@vitest",
"jest-dom",
"testing-library",
"eslint-plugin-react-compiler"
],
Expand Down Expand Up @@ -107,6 +108,7 @@
"overrides": [
{
"extends": [
"plugin:jest-dom/recommended",
"plugin:testing-library/react",
"plugin:@vitest/legacy-recommended"
],
Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@
"@rollup/plugin-node-resolve": "^15.3.0",
"@rollup/plugin-replace": "^6.0.1",
"@rollup/plugin-typescript": "^12.1.1",
"@testing-library/jest-dom": "^6.6.3",
"@testing-library/react": "^16.0.1",
"@types/jsdom": "^21.1.7",
"@types/react": "^18.3.12",
Expand All @@ -125,6 +126,7 @@
"eslint-config-prettier": "^9.1.0",
"eslint-import-resolver-alias": "^1.1.2",
"eslint-plugin-import": "^2.31.0",
"eslint-plugin-jest-dom": "^5.4.0",
"eslint-plugin-prettier": "^5.2.1",
"eslint-plugin-react": "^7.37.2",
"eslint-plugin-react-compiler": "19.0.0-beta-8a03594-20241020",
Expand Down
80 changes: 80 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions tests/proxySet.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -649,7 +649,7 @@ describe('ui updates - useSnapshot', async () => {

fireEvent.click(screen.getByText('Add Item'))

expect(await screen.findByText('1')).toBeDefined()
expect(await screen.findByText('1')).toBeInTheDocument()

Check failure on line 652 in tests/proxySet.test.tsx

View workflow job for this annotation

GitHub Actions / test_matrix (4.8.4)

Property 'toBeInTheDocument' does not exist on type 'Assertion<HTMLElement, any>'.

Check failure on line 652 in tests/proxySet.test.tsx

View workflow job for this annotation

GitHub Actions / test_matrix (4.7.4)

Property 'toBeInTheDocument' does not exist on type 'Assertion<HTMLElement, any>'.

Check failure on line 652 in tests/proxySet.test.tsx

View workflow job for this annotation

GitHub Actions / test_matrix (4.6.4)

Property 'toBeInTheDocument' does not exist on type 'Assertion<HTMLElement, any>'.

Check failure on line 652 in tests/proxySet.test.tsx

View workflow job for this annotation

GitHub Actions / test_matrix (4.5.5)

Property 'toBeInTheDocument' does not exist on type 'Assertion<HTMLElement, any>'.
})

it('should be reactive to changes when using keys method', async () => {
Expand Down Expand Up @@ -682,7 +682,7 @@ describe('ui updates - useSnapshot', async () => {
)

fireEvent.click(screen.getByText('Add Item'))
expect(await screen.findByText('item key: 1')).toBeDefined()
expect(await screen.findByText('item key: 1')).toBeInTheDocument()

Check failure on line 685 in tests/proxySet.test.tsx

View workflow job for this annotation

GitHub Actions / test_matrix (4.8.4)

Property 'toBeInTheDocument' does not exist on type 'Assertion<HTMLElement, any>'.

Check failure on line 685 in tests/proxySet.test.tsx

View workflow job for this annotation

GitHub Actions / test_matrix (4.7.4)

Property 'toBeInTheDocument' does not exist on type 'Assertion<HTMLElement, any>'.

Check failure on line 685 in tests/proxySet.test.tsx

View workflow job for this annotation

GitHub Actions / test_matrix (4.6.4)

Property 'toBeInTheDocument' does not exist on type 'Assertion<HTMLElement, any>'.

Check failure on line 685 in tests/proxySet.test.tsx

View workflow job for this annotation

GitHub Actions / test_matrix (4.5.5)

Property 'toBeInTheDocument' does not exist on type 'Assertion<HTMLElement, any>'.
})

it('should be reactive to changes when using entries method', async () => {
Expand Down Expand Up @@ -715,7 +715,7 @@ describe('ui updates - useSnapshot', async () => {
)

fireEvent.click(screen.getByText('Add Item'))
expect(await screen.findByText('key: 1; value: 1')).toBeDefined()
expect(await screen.findByText('key: 1; value: 1')).toBeInTheDocument()

Check failure on line 718 in tests/proxySet.test.tsx

View workflow job for this annotation

GitHub Actions / test_matrix (4.8.4)

Property 'toBeInTheDocument' does not exist on type 'Assertion<HTMLElement, any>'.

Check failure on line 718 in tests/proxySet.test.tsx

View workflow job for this annotation

GitHub Actions / test_matrix (4.7.4)

Property 'toBeInTheDocument' does not exist on type 'Assertion<HTMLElement, any>'.

Check failure on line 718 in tests/proxySet.test.tsx

View workflow job for this annotation

GitHub Actions / test_matrix (4.6.4)

Property 'toBeInTheDocument' does not exist on type 'Assertion<HTMLElement, any>'.

Check failure on line 718 in tests/proxySet.test.tsx

View workflow job for this annotation

GitHub Actions / test_matrix (4.5.5)

Property 'toBeInTheDocument' does not exist on type 'Assertion<HTMLElement, any>'.
})
})

Expand Down
1 change: 1 addition & 0 deletions tests/setup.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import '@testing-library/jest-dom/vitest'
1 change: 1 addition & 0 deletions vitest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export default defineConfig({
// Keeping globals to true triggers React Testing Library's auto cleanup
// https://vitest.dev/guide/migration.html
globals: true,
setupFiles: ['tests/setup.ts'],
coverage: {
include: ['src/**/'],
reporter: ['text', 'json', 'html', 'text-summary'],
Expand Down

0 comments on commit d016dd4

Please sign in to comment.