Skip to content

Commit 046b984

Browse files
test(lint): a pass-through frame executor inside a mock is the fake's implementation
Macroscope review on #22561. Co-Authored-By: Claude Fable 5.1 <[email protected]>
1 parent 8da6bed commit 046b984

2 files changed

Lines changed: 5 additions & 1 deletion

File tree

‎oxlint-plugin-t3code/rules/no-frame-waits-in-browser-tests.test.ts‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@ describe("t3code/no-frame-waits-in-browser-tests", () => {
5555
"rejects window.requestAnimationFrame",
5656
"window.requestAnimationFrame(() => undefined);",
5757
);
58+
browserTest.valid(
59+
"allows a pass-through frame executor inside a mock implementation",
60+
"const paint = vi.fn(() => new Promise(requestAnimationFrame));",
61+
);
5862
browserTest.invalid(
5963
"rejects setTimeout passed straight through as the promise executor",
6064
"await new Promise(setTimeout);",

‎oxlint-plugin-t3code/rules/no-frame-waits-in-browser-tests.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ export default defineRule({
127127

128128
return {
129129
NewExpression(node) {
130-
if (!isPromiseConstructor(node)) return;
130+
if (!isPromiseConstructor(node) || isInsideMock(node)) return;
131131
const executor = node.arguments[0];
132132
// `new Promise(setTimeout)` resolves on the next macrotask; `new Promise(requestAnimationFrame)`
133133
// on the next frame. Both are the same wait with the function passed straight through.

0 commit comments

Comments
 (0)