Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

fix(ci): scan template interpolations for browser test skips

Steven Enamakelc255785265ea
diff --git a/scripts/__tests__/browser-test-skips.test.mjs b/scripts/__tests__/browser-test-skips.test.mjs
index 936d135b7b..55a24a3359 100644
--- a/scripts/__tests__/browser-test-skips.test.mjs
+++ b/scripts/__tests__/browser-test-skips.test.mjs
@@ -23,15 +23,21 @@ test("requires a same-line URL for direct, qualified, and runtime skip calls", (
]);
});
-test("ignores comments, strings, templates, and removed examples containing skip syntax", () => {
+test("ignores inert text but scans executable template interpolations", () => {
const source = [
"// test.skip('comment')",
"/* test.skip('block comment') */",
"const example = \"it.skip('string')\";",
"const template = `describe.skip('template')`;",
+ "const interpolated = `raw test.skip('ignored') ${test.skip('missing')}`;",
+ `const linked = \`raw describe.skip('ignored') \${test.skip('tracked')}\`; // ${url}`,
+ "const nested = `outer ${({ value: `inner ${this.skip()}` })}`;",
"const removed = '- test.skip(\\\"old\\\")';",
`test.skip('real'); // ${url}`,
].join("\n");
- assert.deepEqual(untrackedSkipLines(source), []);
+ assert.deepEqual(untrackedSkipLines(source), [
+ "5: const interpolated = `raw test.skip('ignored') ${test.skip('missing')}`;",
+ "7: const nested = `outer ${({ value: `inner ${this.skip()}` })}`;",
+ ]);
});
diff --git a/scripts/ci/check-browser-test-skips.mjs b/scripts/ci/check-browser-test-skips.mjs
index a1ce11328d..25b5ded977 100644
--- a/scripts/ci/check-browser-test-skips.mjs
+++ b/scripts/ci/check-browser-test-skips.mjs
@@ -13,9 +13,18 @@ function tokenize(source) {
const advance = (end) => {
while (index < end) if (source[index++] === "\n") line++;
};
-
- while (index < source.length) {
+ const scan = (templateExpression = false) => {
+ let braces = 0;
+ while (index < source.length) {
const char = source[index];
+ if (templateExpression && char === "}") {
+ if (braces === 0) {
+ index++;
+ return;
+ }
+ braces--;
+ }
+ if (templateExpression && char === "{") braces++;
if (/\s/.test(char)) {
advance(index + 1);
continue;
@@ -30,7 +39,7 @@ function tokenize(source) {
advance(close < 0 ? source.length : close + 2);
continue;
}
- if (char === "'" || char === '"' || char === "`") {
+ if (char === "'") {
const quote = char;
const start = index;
const tokenLine = line;
@@ -49,6 +58,44 @@ function tokenize(source) {
tokens.push({ value: "<string>", start, end: index, line: tokenLine });
continue;
}
+ if (char === '"') {
+ const start = index;
+ const tokenLine = line;
+ index++;
+ while (index < source.length) {
+ if (source[index] === "\\") {
+ advance(Math.min(index + 2, source.length));
+ continue;
+ }
+ if (source[index++] === '"') break;
+ if (source[index - 1] === "\n") line++;
+ }
+ tokens.push({ value: "<string>", start, end: index, line: tokenLine });
+ continue;
+ }
+ if (char === "`") {
+ const start = index;
+ const tokenLine = line;
+ index++;
+ while (index < source.length) {
+ if (source[index] === "\\") {
+ advance(Math.min(index + 2, source.length));
+ continue;
+ }
+ if (source[index] === "`") {
+ index++;
+ break;
+ }
+ if (source[index] === "$" && source[index + 1] === "{") {
+ advance(index + 2);
+ scan(true);
+ continue;
+ }
+ advance(index + 1);
+ }
+ tokens.push({ value: "<template>", start, end: index, line: tokenLine });
+ continue;
+ }
const start = index;
const tokenLine = line;
if (/[A-Za-z_$]/.test(char)) {
@@ -63,7 +110,9 @@ function tokenize(source) {
end: index,
line: tokenLine,
});
- }
+ }
+ };
+ scan();
return tokens;
}