Skip to content

Commit 2d2a5b3

Browse files
alexander-turnerclaude
authored andcommitted
refactor: flatten walk() with early continues
https://claude.ai/code/session_018SbTXFCAujDRRjBFtMTFXU
1 parent 830ff9e commit 2d2a5b3

File tree

1 file changed

+22
-19
lines changed

1 file changed

+22
-19
lines changed

packages/jest-circus/src/legacy-code-todo-rewrite/jestAdapterInit.ts

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -158,26 +158,29 @@ export const collectTestsWithoutRunning = async ({
158158
for (const child of block.children) {
159159
if (child.type === 'describeBlock') {
160160
walk(child, [...ancestors, child.name]);
161-
} else if (child.type === 'test') {
162-
if (!testNamePattern || testNamePattern.test(getTestID(child))) {
163-
const title = child.name;
164-
assertionResults.push({
165-
ancestorTitles: [...ancestors],
166-
duration: null,
167-
failing: false,
168-
failureDetails: [],
169-
failureMessages: [],
170-
fullName: [...ancestors, title].join(' '),
171-
invocations: 0,
172-
location: null,
173-
numPassingAsserts: 0,
174-
retryReasons: [],
175-
startAt: null,
176-
status: 'pending' as Status,
177-
title,
178-
});
179-
}
161+
continue;
180162
}
163+
164+
if (testNamePattern && !testNamePattern.test(getTestID(child))) {
165+
continue;
166+
}
167+
168+
const title = child.name;
169+
assertionResults.push({
170+
ancestorTitles: [...ancestors],
171+
duration: null,
172+
failing: false,
173+
failureDetails: [],
174+
failureMessages: [],
175+
fullName: [...ancestors, title].join(' '),
176+
invocations: 0,
177+
location: null,
178+
numPassingAsserts: 0,
179+
retryReasons: [],
180+
startAt: null,
181+
status: 'pending' as Status,
182+
title,
183+
});
181184
}
182185
};
183186
walk(rootDescribeBlock, []);

0 commit comments

Comments
 (0)