diff --git a/packages/paperclip-runner/scripts/check-bare-real-process-waits.test.mjs b/packages/paperclip-runner/scripts/check-bare-real-process-waits.test.mjs index b16c74de80f..24eaf6f0c6a 100644 --- a/packages/paperclip-runner/scripts/check-bare-real-process-waits.test.mjs +++ b/packages/paperclip-runner/scripts/check-bare-real-process-waits.test.mjs @@ -194,6 +194,18 @@ test("rejects a vi.waitFor( that follows a regex literal with a quantifier's ope ]); }); +test("rejects a vi.waitFor( that follows an await-prefixed regex literal with a closing brace inside a template literal interpolation", () => { + const source = [ + "async function example() {", + " const message = `status: ${await /}/.test(x) ? await vi.waitFor(() => expect(x).toBe(1)) : false}`;", + "}", + ].join("\n"); + + assert.deepEqual(findBareRealProcessWaits(source), [ + { line: 2, pattern: "vi.waitFor(" }, + ]); +}); + test("ignores a vi.waitFor( written inside a regex literal's own text, inside a template literal interpolation", () => { const source = [ "async function example() {", diff --git a/packages/paperclip-runner/scripts/lib/bare-real-process-wait.mjs b/packages/paperclip-runner/scripts/lib/bare-real-process-wait.mjs index 62ecf21ce93..f76d8e15346 100644 --- a/packages/paperclip-runner/scripts/lib/bare-real-process-wait.mjs +++ b/packages/paperclip-runner/scripts/lib/bare-real-process-wait.mjs @@ -59,7 +59,7 @@ async function collectSourceFiles(target) { // state; this heuristic only needs to hold for the code this guard scans. const REGEX_PRECEDING_KEYWORDS = new Set([ "return", "typeof", "instanceof", "in", "of", "new", "delete", "void", - "yield", "case", "throw", "do", "else", + "yield", "case", "throw", "do", "else", "await", ]); function isRegexLiteralStart(source, index) {