Skip to content

Commit

Permalink
Merge branch 'main' into 991
Browse files Browse the repository at this point in the history
  • Loading branch information
overthemike authored Nov 9, 2024
2 parents ed0c0de + bb8fe84 commit f5f48f4
Show file tree
Hide file tree
Showing 7 changed files with 114 additions and 26 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",
"testing-library",
"eslint-plugin-react-compiler"
],
"parser": "@typescript-eslint/parser",
Expand Down Expand Up @@ -109,6 +110,7 @@
},
"overrides": [
{
"extends": ["plugin:testing-library/react"],
"files": ["tests/**/*.ts", "tests/**/*.tsx"],
"rules": {
"import/extensions": ["error", "never"],
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@
"eslint-plugin-react": "^7.37.2",
"eslint-plugin-react-compiler": "19.0.0-beta-8a03594-20241020",
"eslint-plugin-react-hooks": "^5.0.0",
"eslint-plugin-testing-library": "^6.4.0",
"eslint-plugin-vitest": "^0.5.4",
"jest-leak-detector": "^29.7.0",
"jsdom": "^25.0.1",
Expand Down
92 changes: 92 additions & 0 deletions pnpm-lock.yaml

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

12 changes: 6 additions & 6 deletions tests/basic.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -516,16 +516,16 @@ it('stable snapshot object (#985)', async () => {
)
}

const { getByText, findByText } = render(<TestComponent />)
render(<TestComponent />)

await findByText('count: 0')
await screen.findByText('count: 0')
expect(effectCount).toBe(1)

fireEvent.click(getByText('button'))
await findByText('count: 1')
fireEvent.click(screen.getByText('button'))
await screen.findByText('count: 1')
expect(effectCount).toBe(1)

fireEvent.click(getByText('button'))
await findByText('count: 2')
fireEvent.click(screen.getByText('button'))
await screen.findByText('count: 2')
expect(effectCount).toBe(1)
})
25 changes: 10 additions & 15 deletions tests/proxySet.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -641,16 +641,15 @@ describe('ui updates - useSnapshot', async () => {
)
}

const { getByText } = render(
render(
<StrictMode>
<TestComponent />
</StrictMode>,
)

fireEvent.click(getByText('Add Item'))
await waitFor(() => {
getByText('1')
})
fireEvent.click(screen.getByText('Add Item'))

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

it('should be reactive to changes when using keys method', async () => {
Expand All @@ -676,16 +675,14 @@ describe('ui updates - useSnapshot', async () => {
)
}

const { getByText } = render(
render(
<StrictMode>
<TestComponent />
</StrictMode>,
)

fireEvent.click(getByText('Add Item'))
await waitFor(() => {
getByText('item key: 1')
})
fireEvent.click(screen.getByText('Add Item'))
expect(await screen.findByText('item key: 1')).toBeDefined()
})

it('should be reactive to changes when using entries method', async () => {
Expand All @@ -711,16 +708,14 @@ describe('ui updates - useSnapshot', async () => {
)
}

const { getByText } = render(
render(
<StrictMode>
<TestComponent />
</StrictMode>,
)

fireEvent.click(getByText('Add Item'))
await waitFor(() => {
getByText('key: 1; value: 1')
})
fireEvent.click(screen.getByText('Add Item'))
expect(await screen.findByText('key: 1; value: 1')).toBeDefined()
})
})

Expand Down
4 changes: 0 additions & 4 deletions tests/setup.ts

This file was deleted.

4 changes: 3 additions & 1 deletion vitest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ export default defineConfig({
},
test: {
name: 'valtio',
setupFiles: './tests/setup.ts',
// Keeping globals to true triggers React Testing Library's auto cleanup
// https://vitest.dev/guide/migration.html
globals: true,
coverage: {
include: ['src/**/'],
reporter: ['text', 'json', 'html', 'text-summary'],
Expand Down

0 comments on commit f5f48f4

Please sign in to comment.