-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove console-testing-library
#4603
Open
aryaemami59
wants to merge
22
commits into
reduxjs:master
Choose a base branch
from
aryaemami59:remove-console-testing-library
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+10,203
−7,476
Open
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
e034d5b
Fix `console` spy related issues in `devWarnings.test.tsx`
aryaemami59 858047d
Fix `console` spy related issues in `createApi.test.ts`
aryaemami59 db2380a
Fix `console` spy related issues in `injectEndpoints.test.tsx`
aryaemami59 bfaa88d
Fix issues related to `console` spies in `createSlice.test.ts`
aryaemami59 df18c84
Fix issues related to `console` spies in `serializableStateInvariantM…
aryaemami59 dd325c6
Fix issues related to `console` spies in `immutableStateInvariantMidd…
aryaemami59 c14f407
Fix `console` spy related issues in `fakeBaseQuery.test.tsx`
aryaemami59 fe04ad6
Fix issues related to `console` spies in `createAsyncThunk.test.ts`
aryaemami59 6729bda
Fix issues related to `console` spies in `createReducer.test.ts`
aryaemami59 3818755
Fix `console` spy related issues in `queryFn.test.tsx`
aryaemami59 90c2d01
Remove `vi.resetAllMocks()` call from `utils.spec.ts`
aryaemami59 15a0718
Fix `console` spy related issues in `effectScenarios.test.ts`
aryaemami59 ef44b7f
Fix `console` spy related issues in `listenerMiddleware.test.ts`
aryaemami59 692a529
Fix issue with `console` spy inside `buildHooks.test.tsx`
aryaemami59 36e5e74
Fix issues related to spies and stubbing environments in `utils.spec.ts`
aryaemami59 ff7a3b9
Fix issues related to stubbing envs in `createReducer.test.ts`
aryaemami59 2a738d9
Fix issues related to stubbing envs in `createSlice.test.ts`
aryaemami59 0ad3729
Fix issues related to stubbing envs in `createAsyncThunk.test.ts`
aryaemami59 e773192
Fix issues related to stubbing envs in `getDefaultMiddleware.test.ts`
aryaemami59 da9ae2f
Remove `satisfies` operators in `queryFn.test.tsx`
aryaemami59 bd04abd
Remove `console-testing-library` as it is no longer needed
aryaemami59 bb729ff
Remove `jest-snapshot` from `resolutions` field of root `package.json`
aryaemami59 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
68 changes: 0 additions & 68 deletions
68
.yarn/patches/console-testing-library-npm-0.6.1-4d9957d402.patch
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,66 +1,71 @@ | ||
import { vi } from 'vitest' | ||
import { noop } from '@internal/listenerMiddleware/utils' | ||
import { AClockworkOrange } from './fixtures/book' | ||
|
||
describe('Entity utils', () => { | ||
describe(`selectIdValue()`, () => { | ||
const OLD_ENV = process.env | ||
const consoleWarnSpy = vi.spyOn(console, 'warn').mockImplementation(noop) | ||
|
||
beforeEach(() => { | ||
vi.resetModules() // this is important - it clears the cache | ||
process.env = { ...OLD_ENV, NODE_ENV: 'development' } | ||
vi.stubEnv('NODE_ENV', 'development') | ||
}) | ||
|
||
afterEach(() => { | ||
process.env = OLD_ENV | ||
vi.resetAllMocks() | ||
consoleWarnSpy.mockClear() | ||
vi.unstubAllEnvs() | ||
}) | ||
|
||
afterAll(() => { | ||
consoleWarnSpy.mockRestore() | ||
}) | ||
|
||
it('should not warn when key does exist', async () => { | ||
const { selectIdValue } = await import('../utils') | ||
const spy = vi.spyOn(console, 'warn') | ||
|
||
selectIdValue(AClockworkOrange, (book: any) => book.id) | ||
expect(spy).not.toHaveBeenCalled() | ||
expect(consoleWarnSpy).not.toHaveBeenCalled() | ||
}) | ||
|
||
it('should warn when key does not exist in dev mode', async () => { | ||
const { selectIdValue } = await import('../utils') | ||
const spy = vi.spyOn(console, 'warn') | ||
|
||
expect(process.env.NODE_ENV).toBe('development') | ||
|
||
selectIdValue(AClockworkOrange, (book: any) => book.foo) | ||
|
||
expect(spy).toHaveBeenCalled() | ||
expect(consoleWarnSpy).toHaveBeenCalledOnce() | ||
}) | ||
|
||
it('should warn when key is undefined in dev mode', async () => { | ||
const { selectIdValue } = await import('../utils') | ||
const spy = vi.spyOn(console, 'warn') | ||
|
||
expect(process.env.NODE_ENV).toBe('development') | ||
|
||
const undefinedAClockworkOrange = { ...AClockworkOrange, id: undefined } | ||
selectIdValue(undefinedAClockworkOrange, (book: any) => book.id) | ||
|
||
expect(spy).toHaveBeenCalled() | ||
expect(consoleWarnSpy).toHaveBeenCalledOnce() | ||
}) | ||
|
||
it('should not warn when key does not exist in prod mode', async () => { | ||
process.env.NODE_ENV = 'production' | ||
vi.stubEnv('NODE_ENV', 'production') | ||
|
||
const { selectIdValue } = await import('../utils') | ||
const spy = vi.spyOn(console, 'warn') | ||
|
||
selectIdValue(AClockworkOrange, (book: any) => book.foo) | ||
|
||
expect(spy).not.toHaveBeenCalled() | ||
expect(consoleWarnSpy).not.toHaveBeenCalled() | ||
}) | ||
|
||
it('should not warn when key is undefined in prod mode', async () => { | ||
process.env.NODE_ENV = 'production' | ||
vi.stubEnv('NODE_ENV', 'production') | ||
|
||
const { selectIdValue } = await import('../utils') | ||
const spy = vi.spyOn(console, 'warn') | ||
|
||
const undefinedAClockworkOrange = { ...AClockworkOrange, id: undefined } | ||
selectIdValue(undefinedAClockworkOrange, (book: any) => book.id) | ||
|
||
expect(spy).not.toHaveBeenCalled() | ||
expect(consoleWarnSpy).not.toHaveBeenCalled() | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just wanted to suggest that we do
inside the tests that actually need this, and skip the
mockClear
andmockRestore
calls, but I'm not sure ifvitest
actually returns aDisposable
here. I knowjest
does (because I added the functionality there) - could you check ifvitest
has that now, too?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure I can try it. The type tests will probably fail, so I'll probably exclude the runtime tests from the type tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like
vitest
doesn't return aDisposable
, though I might try to submit a PR to add that functionality forvitest
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will definitely be a win in the long run, even if it's not applicable to this PR in the end :)