-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Run tests with React 19 RC.1 and adjust tests accordingly #12140
Merged
Merged
Changes from all commits
Commits
Show all changes
60 commits
Select commit
Hold shift + click to select a range
110e5e3
bump react to 19 rc.1
phryneas 3226c83
patch `REACT_FALLBACK_THROTTLE_MS`
phryneas db33a3b
swap sync usages of `render` to their async counterparts
phryneas 2a7df4f
bump dep
phryneas 1f6af4f
adjust delay and `REACT_FALLBACK_THROTTLE_MS`
phryneas 7da06c2
fix up a bunch of tests
phryneas 102d382
fixup
phryneas dbb4f7b
disable patch until all tests work
phryneas 3c83984
add delay to all mocks I could find
phryneas b84508b
more rendercounts
phryneas d04889f
down to one failing `useSuspenseQuery` test...
phryneas cccfae9
`useSuspenseQuery` not failing anymore
phryneas ca0a751
add this to a lot more test files
phryneas 203aaaa
useBackgroundQuery
phryneas 670eafe
useQuery
phryneas 3f1a659
fix up async calls
phryneas bcf52df
disable act environment for all render stream tests
phryneas 852e33e
remove & forbid wrong act calls
phryneas 651a3d2
simplify lint rules
phryneas 0ae48ce
undo for a second
phryneas 1d0c877
slow down a few select tests
phryneas f02f1a2
work around one weird test
phryneas 4e8253c
format
phryneas b1af798
use modern version of testing library for React 17
phryneas c7b13af
remove patch
phryneas 8a4738a
fix most React 17 tests
phryneas a7d9f66
Merge branch 'main' into pr/react-19-rc.1
phryneas 161c540
update RRSTL
phryneas ddcf14c
undo some React17 specific changes
phryneas cf5ebd7
inline actAsync
phryneas b6c8fae
inline `renderAsync`
phryneas a608302
inline `renderHookAsync`
phryneas 2e937e6
revert `@testing-library/react` to npm
phryneas bc34409
adjust patch
phryneas 4394675
forgot an import
phryneas 34a6051
don't use `userEventWithoutAct`
phryneas 3842150
bump
phryneas 5ff137e
bump delay a bit
phryneas 71bab96
remove `disableActWarnings` tool
phryneas 99bc011
await rerender
phryneas 763d65b
missing actAsync
phryneas 5aa78f1
some more type updates
phryneas 92a8250
some more act calls
phryneas c9d918a
don't patch React
phryneas 5cf5930
`actAsync` for React 17
phryneas eb9b49f
actAsync -> act
phryneas e29c31d
update dep
phryneas 09240a7
fix React 17 specific act quirk
phryneas 28b705e
remove `renderToRenderStream`
phryneas 35e3f7f
enable `@typescript-eslint/no-floating-promises` lint rule
phryneas c58a07d
some more await/void
phryneas 56b1bb9
update rrstl dependency
phryneas 4087349
remove unneccessary await - oops
phryneas a81e42e
PR feedback
phryneas 1e5fdea
Update src/testing/internal/scenarios/index.ts
phryneas 6d308a7
Update src/testing/internal/rtl/actAsync.ts
phryneas a3d4455
Update src/testing/internal/rtl/renderAsync.ts
phryneas 0247ac7
fix typo
phryneas 143609b
Merge branch 'main' into pr/react-19-rc.1
phryneas 1507630
make overriding intentional via an argument
phryneas 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
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 |
---|---|---|
|
@@ -173,7 +173,7 @@ workflows: | |
- "@types/[email protected] @types/[email protected]" | ||
- "@types/react@17 @types/react-dom@17" | ||
- "@types/react@18 @types/react-dom@18" | ||
- "@types/react@npm:[email protected].0 @types/react-dom@npm:[email protected].0" | ||
- "@types/react@npm:[email protected].1 @types/react-dom@npm:[email protected].1" | ||
- "typescript@next" | ||
security-scans: | ||
jobs: | ||
|
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
56 changes: 56 additions & 0 deletions
56
eslint-local-rules/forbid-act-in-disabled-act-environment.test.ts
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 |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import { rule } from "./forbid-act-in-disabled-act-environment"; | ||
import { ruleTester } from "./testSetup"; | ||
|
||
ruleTester.run("forbid-act-in-disabled-act-environment", rule, { | ||
valid: [ | ||
` | ||
() => { | ||
using _disabledAct = disableActEnvironment(); | ||
} | ||
() => { | ||
act(() => {}) | ||
} | ||
`, | ||
` | ||
() => { | ||
using _disabledAct = disableActEnvironment(); | ||
} | ||
() => { | ||
actAsync(() => {}) | ||
} | ||
`, | ||
], | ||
invalid: [ | ||
` | ||
() => { | ||
using _disabledAct = disableActEnvironment(); | ||
act(() => {}) | ||
} | ||
`, | ||
` | ||
() => { | ||
using _disabledAct = disableActEnvironment(); | ||
actAsync(() => {}) | ||
} | ||
`, | ||
` | ||
() => { | ||
using _disabledAct = disableActEnvironment(); | ||
() => { | ||
act(() => {}) | ||
} | ||
} | ||
`, | ||
` | ||
() => { | ||
using _disabledAct = disableActEnvironment(); | ||
() => { | ||
actAsync(() => {}) | ||
} | ||
} | ||
`, | ||
].map((code) => ({ | ||
code, | ||
errors: [{ messageId: "forbiddenActInNonActEnvironment" }], | ||
})), | ||
}); |
63 changes: 63 additions & 0 deletions
63
eslint-local-rules/forbid-act-in-disabled-act-environment.ts
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 |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import { ESLintUtils } from "@typescript-eslint/utils"; | ||
|
||
export const rule = ESLintUtils.RuleCreator.withoutDocs({ | ||
create(context) { | ||
let depth = 1; | ||
let disabledDepth: number | false = false; | ||
|
||
function EnterFn() { | ||
depth++; | ||
} | ||
function ExitFn() { | ||
depth--; | ||
if (disabledDepth !== false && disabledDepth > depth) { | ||
disabledDepth = false; | ||
} | ||
} | ||
|
||
return { | ||
CallExpression(node) { | ||
const directCallee = | ||
node.callee.type === "Identifier" ? node.callee | ||
: node.callee.type === "MemberExpression" ? node.callee.property | ||
: null; | ||
|
||
if ( | ||
directCallee?.type === "Identifier" && | ||
directCallee.name === "disableActEnvironment" | ||
) { | ||
if (disabledDepth === false) { | ||
disabledDepth = depth; | ||
} | ||
} | ||
|
||
if ( | ||
directCallee?.type === "Identifier" && | ||
(directCallee.name === "act" || directCallee.name === "actAsync") | ||
) { | ||
if (disabledDepth !== false) { | ||
context.report({ | ||
messageId: "forbiddenActInNonActEnvironment", | ||
node: node, | ||
}); | ||
} | ||
} | ||
}, | ||
ArrowFunctionExpression: EnterFn, | ||
FunctionExpression: EnterFn, | ||
FunctionDeclaration: EnterFn, | ||
"ArrowFunctionExpression:exit": ExitFn, | ||
"FunctionExpression:exit": ExitFn, | ||
"FunctionDeclaration:exit": ExitFn, | ||
}; | ||
}, | ||
meta: { | ||
messages: { | ||
forbiddenActInNonActEnvironment: | ||
"`act` should not be called in a `disableActEnvironment`.", | ||
}, | ||
type: "problem", | ||
schema: [], | ||
}, | ||
defaultOptions: [], | ||
}); |
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
120 changes: 120 additions & 0 deletions
120
eslint-local-rules/require-disable-act-environment.test.ts
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 |
---|---|---|
@@ -0,0 +1,120 @@ | ||
import { rule } from "./require-disable-act-environment"; | ||
import { ruleTester } from "./testSetup"; | ||
|
||
ruleTester.run("require-disable-act-environment", rule, { | ||
valid: [ | ||
` | ||
() => { | ||
using _disabledAct = disableActEnvironment(); | ||
const { takeRender } = someCall() | ||
const {} = takeRender() | ||
} | ||
`, | ||
` | ||
() => { | ||
using _disabledAct = disableActEnvironment(); | ||
const {} = renderStream.takeRender() | ||
} | ||
`, | ||
` | ||
() => { | ||
using _disabledAct = disableActEnvironment(); | ||
const { takeSnapshot } = someCall() | ||
const {} = takeSnapshot() | ||
} | ||
`, | ||
` | ||
() => { | ||
using _disabledAct = disableActEnvironment(); | ||
const {} = renderStream.takeSnapshot() | ||
} | ||
`, | ||
` | ||
using _disabledAct = disableActEnvironment(); | ||
() => { | ||
const { takeRender } = someCall() | ||
const {} = takeRender() | ||
} | ||
`, | ||
` | ||
using _disabledAct = disableActEnvironment(); | ||
() => { | ||
const {} = renderStream.takeRender() | ||
} | ||
`, | ||
` | ||
using _disabledAct = disableActEnvironment(); | ||
() => { | ||
const { takeSnapshot } = someCall() | ||
const {} = takeSnapshot() | ||
} | ||
`, | ||
` | ||
using _disabledAct = disableActEnvironment(); | ||
() => { | ||
const {} = renderStream.takeSnapshot() | ||
} | ||
`, | ||
], | ||
invalid: [ | ||
` | ||
() => { | ||
using _disabledAct = disableActEnvironment(); | ||
} | ||
() => { | ||
const { takeRender } = someCall() | ||
takeRender() | ||
} | ||
`, | ||
` | ||
() => { | ||
using _disabledAct = disableActEnvironment(); | ||
} | ||
() => { | ||
renderStream.takeRender() | ||
} | ||
`, | ||
` | ||
() => { | ||
using _disabledAct = disableActEnvironment(); | ||
} | ||
() => { | ||
const { takeSnapshot } = someCall() | ||
takeSnapshot() | ||
} | ||
`, | ||
` | ||
() => { | ||
using _disabledAct = disableActEnvironment(); | ||
} | ||
() => { | ||
renderStream.takeSnapshot() | ||
} | ||
`, | ||
` | ||
() => { | ||
const { takeRender } = someCall() | ||
takeRender() | ||
} | ||
`, | ||
` | ||
() => { | ||
renderStream.takeRender() | ||
} | ||
`, | ||
` | ||
() => { | ||
const { takeSnapshot } = someCall() | ||
takeSnapshot() | ||
} | ||
`, | ||
` | ||
() => { | ||
renderStream.takeSnapshot() | ||
} | ||
`, | ||
].map((code) => ({ | ||
code, | ||
errors: [{ messageId: "missingDisableActEnvironment" }], | ||
})), | ||
}); |
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 |
---|---|---|
@@ -0,0 +1,83 @@ | ||
import { ESLintUtils, ASTUtils } from "@typescript-eslint/utils"; | ||
import type { TSESTree as AST } from "@typescript-eslint/types"; | ||
|
||
type Fn = | ||
| AST.FunctionDeclaration | ||
| AST.ArrowFunctionExpression | ||
| AST.FunctionExpression; | ||
|
||
export const rule = ESLintUtils.RuleCreator.withoutDocs({ | ||
create(context) { | ||
let depth = 1; | ||
let disabledDepth: number | false = false; | ||
|
||
function EnterFn() { | ||
depth++; | ||
} | ||
function ExitFn() { | ||
depth--; | ||
if (disabledDepth !== false && disabledDepth > depth) { | ||
disabledDepth = false; | ||
} | ||
} | ||
|
||
return { | ||
CallExpression(node) { | ||
const directCallee = | ||
node.callee.type === "Identifier" ? node.callee | ||
: node.callee.type === "MemberExpression" ? node.callee.property | ||
: null; | ||
|
||
if ( | ||
directCallee?.type === "Identifier" && | ||
directCallee.name === "disableActEnvironment" | ||
) { | ||
if (disabledDepth === false) { | ||
disabledDepth = depth; | ||
} | ||
} | ||
|
||
if ( | ||
directCallee?.type === "Identifier" && | ||
(directCallee.name === "takeRender" || | ||
directCallee.name === "takeSnapshot") | ||
) { | ||
if (disabledDepth === false) { | ||
context.report({ | ||
messageId: "missingDisableActEnvironment", | ||
node: node, | ||
}); | ||
} | ||
} | ||
}, | ||
ArrowFunctionExpression: EnterFn, | ||
FunctionExpression: EnterFn, | ||
FunctionDeclaration: EnterFn, | ||
"ArrowFunctionExpression:exit": ExitFn, | ||
"FunctionExpression:exit": ExitFn, | ||
"FunctionDeclaration:exit": ExitFn, | ||
}; | ||
}, | ||
meta: { | ||
messages: { | ||
missingDisableActEnvironment: | ||
"Tests using a render stream should call `disableActEnvironment`.", | ||
}, | ||
type: "problem", | ||
schema: [], | ||
}, | ||
defaultOptions: [], | ||
}); | ||
|
||
function findParentFunction(node: AST.Node): Fn | undefined { | ||
let parentFunction: AST.Node | undefined = node; | ||
while ( | ||
parentFunction != null && | ||
parentFunction.type !== "FunctionDeclaration" && | ||
parentFunction.type !== "FunctionExpression" && | ||
parentFunction.type !== "ArrowFunctionExpression" | ||
) { | ||
parentFunction = parentFunction.parent; | ||
} | ||
return parentFunction; | ||
} |
Oops, something went wrong.
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.
🎉