fix(test-evidence): skip·fixme 검사가 testInfo·test.info()·별칭 호출을 본다 #82
@@ -26,6 +26,7 @@ Gitea runner에서 merge 단계를 초록으로 만들고, worker를 늘리지
|
||||
- FE-GATE-005가 `test:unit`·`test:contract`를 따로 돌지 않는다. `tests/unit`·`tests/contract`는 `test:coverage`에서 한 번 돌고, 같은 실행이 `artifacts/tests/unit.xml`·`contract.xml`을 쓴다(`scripts/lib/coverage-bundle-junit-reporter.ts`). 계약에서 command `test-unit`·`test-contract`가 빠진다. 자기 `config/ci/gates.json`의 게이트가 그 id를 부르면 지운다. `test:coverage`의 경로에서 두 폴더 중 하나를 빼거나 그 reporter를 빼면 FE-GATE-005가 실패한다. 두 package script는 작업 중에 쓰는 명령으로 남는다.
|
||||
- FE-GATE-009의 `test:a11y`가 `playwright test --config playwright.a11y.config.ts --grep @a11y`로 돌고 결과를 `artifacts/tests/a11y/`에 쓴다. 자기 `test:a11y`를 고쳐 썼으면 `--config playwright.a11y.config.ts`를 넣는다. 빠지면 008과 009가 같은 결과 경로에 써서 `tests/unit/playwright-result-paths.test.ts`(FE-GATE-005)가 실패한다(`scripts/verify.sh gate FE-GATE-005`).
|
||||
- FE-GATE-029가 `playwright test`의 `--grep-invert P` 실행마다 같은 testDir을 `--grep P`로 도는 게이트 실행을 요구한다. 자기 `test:e2e`·`test:a11y`의 패턴을 바꿨으면 두 글자를 같게 둔다. 게이트 명령에 파일 필터나 `grep`이 든 설정으로만 도는 testDir이 있으면 필터 없는 실행을 더한다. 짝이 없으면 main push의 FE-GATE-029가 그 testDir과 빠진 짝을 대며 실패한다(`scripts/verify.sh gate FE-GATE-029`).
|
||||
- `check:test-evidence`(FE-GATE-008, fixture는 029)가 skip·fixme를 구문 트리로 찾는다. `testInfo.skip()`·`test.info().skip()`·import 별칭(`strictTest.skip()`)과 `.mts`·`.cts`·`.js`·`.mjs`·`.cjs`·`.jsx` 시험 파일도 본다. 이런 호출이 quarantine 주석 없이 있으면 실패한다. 옮긴 뒤 확인: `scripts/verify.sh script check:test-evidence:source`.
|
||||
- 수동 접근성 기록(`docs/accessibility/route-reviews/`)에 WCAG 2.2 칸 둘이 생기고, `Release ID`를 릴리스 태그와 대조한다.
|
||||
- 옮기기 전: 자기 기록에 `M8`·`M9` 줄이 없으면 FE-GATE-009 형식 검사가 그 필드 이름을 대며 실패한다. release 단계를 태그 없이(브랜치에서 수동으로) 돌리면 FE-GATE-028이 `missing required environment: RELEASE_TAG`로 멈춘다.
|
||||
- 옮기는 법: 기록마다 `M8 Focus not obscured: pending`, `M9 Target size: pending` 두 줄을 더한다. 서명하는 기록의 `Release ID`는 다음 release부터 그 릴리스 태그(예 `v1.4.0`)로 적는다. release 단계는 태그 run에서 돈다.
|
||||
@@ -109,6 +110,7 @@ Gitea runner에서 merge 단계를 초록으로 만들고, worker를 늘리지
|
||||
| [계약] | FE-GATE-028이 release job env `RELEASE_TAG`(tag run이면 태그, 아니면 빈 값)를 요구하고, `review:a11y-manual`이 기록마다 `Release ID`가 그 태그와 같은지 본다. 기록 양식에 `M8 Focus not obscured`(2.4.11)·`M9 Target size`(2.5.8)가 생기고 `create:feature`도 그 줄을 쓴다. FE-GATE-028 증거 목록에 EXAMPLES_PLATFORM 기록이 들어가고, CI 계약 시험이 증거의 기록과 플랫폼 라우트가 같은지 본다. 위 "먼저 할 일" (1112/05-01, 1112/05-05, 1112/05-18) | `config/ci/gates.json`, `scripts/contracts/ci-gates.ts`, `.gitea/workflows/quality-gates.yml`, `scripts/verify-a11y-manual.ts`, `scripts/lib/manual-a11y-evidence.ts`, `scripts/create-feature.ts`, `docs/accessibility/manual-checklist.md`, `docs/accessibility/route-reviews/` | `000b5a35`, `aa4bddac`, `f1074370` |
|
||||
| [계약] | PR run은 바뀐 경로로 merge 게이트를 고른다. 경로표 `config/ci/pr-gate-selection.json`의 줄을 위에서부터 보고 처음 맞는 줄의 게이트를 늘 도는 001·002·003·010에 더한다. global 파일(`config/`, `scripts/`, `.gitea/`, 도구 설정, lockfile 등)이 하나라도 바뀌면 전부 돈다. 안 도는 게이트는 `건너뜀: <ID> — <이유>`를 찍고 성공으로 끝난다. main run과 수동 실행은 늘 전부 돈다. diff는 origin에서 인증 없이 base를 받아 잰다. 비공개 repo라 받지 못하면 이유를 찍고 전부 돈다. 경로표가 추적 파일을 모두 덮는지 시험이 본다(위 "먼저 할 일"). 시험 fixture는 PR job의 `CI_PR_BASE_REF`를 물려받지 않는다(소유자 결정 2026-11-13) | `config/ci/pr-gate-selection.json`, `scripts/lib/pr-gate-selection.ts`, `scripts/run-ci-gate.ts`, `scripts/contracts/ci-gates.ts`, `config/ci/gates.json`, `.gitea/workflows/quality-gates.yml`, `scripts/lib/fixture-node-modules.ts`, `tests/unit/pr-gate-selection.test.ts` | `9f8b2c1c`, `f0a8582c` |
|
||||
| [계약] | `check:ci:gating`(FE-GATE-029)이 경로마다 그 경로를 돌리는 runner를 본다. Vitest 경로 아래의 `*.spec.*` 파일은 어느 게이트도 돌리지 않으므로 게이트 밖으로 세어 실패한다. 자기 Vitest 시험 파일이 `.spec`이면 `.test`로 바꾼다 (0929/12-06) | `scripts/check-ci-gating.ts`, `scripts/lib/ungated-tests.ts` | `d838be54` |
|
||||
| [계약] | `check:test-evidence`의 skip·fixme 검사가 정규식에서 Babel 구문 트리로 바뀐다. 정규식은 `test.skip(` 꼴만 봐서 `testInfo.skip()`·`test.info().skip()`·import 별칭의 skip이 quarantine 없이 Playwright 시험을 뺐다. 파일은 Playwright `testMatch` 기본값의 확장자로 넓히고, 파싱이 안 되는 파일은 실패로 적는다. `test.fail()`은 그대로 허용한다 | `scripts/check-test-evidence.ts`, `tests/fixtures/test-evidence/forbidden/`, `tests/unit/test-evidence-source-rules.test.ts` | `6830ec5a` |
|
||||
| [계약] | `verify:documentation`(FE-GATE-017)이 `scripts/verify.sh`와 `python3` 명령 안의 경로·script 이름도 대조한다. 자기 문서의 `scripts/verify.sh script <이름>`·`python3 <경로>`가 낡았으면 실패하니 고친다 (1112/08-06) | `scripts/verify-documentation-readiness.ts` | `aebb7c8c` |
|
||||
| [계약] | release의 provider job 둘(vulnerability·provenance)에 FE-GATE-013과 같은 runner 요구(`hostRequirements`)를 적고, 계약이 둘이 같은지 본다. provider 감독 스크립트가 provider를 띄우기 전에 비특권 user namespace를 점검하고, 막혔으면 `test:system` 사전 점검과 같은 문구로 멈춘다 (1101/13-03) | `config/ci/gates.json`, `scripts/contracts/ci-gates.ts`, `scripts/generate-ci-workflow.ts`, `.gitea/workflows/quality-gates.yml`, `scripts/check-system-test-prerequisites.ts`, `scripts/run-and-validate-provider.ts` | `9ebd0856` |
|
||||
| [계약] | 브라우저 job 컨테이너가 `--shm-size=2g`로 뜨고, Firefox 시험 프로필을 RAM 파일시스템(`/dev/shm`)에 둔다. Firefox가 시험 context의 저장소를 디스크 프로필에 두어, 디스크가 붐비면 첫 화면 5초 대기를 넘겼다. 자리가 모자라면 디스크 프로필로 돌고 이유를 한 줄 찍는다 | `scripts/generate-ci-workflow.ts`, `.gitea/workflows/quality-gates.yml`, `tests/support/browser/browser-test.ts`, `docs/operations/ci-quality-gates.md` | `f81dda49`, `c239bdf4` |
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { parseAsync } from "@babel/core";
|
||||
import { mkdir, readFile, readdir, stat } from "node:fs/promises";
|
||||
import path from "node:path";
|
||||
import { pathToFileURL } from "node:url";
|
||||
@@ -87,6 +88,210 @@ const facts = {
|
||||
playwrightConfigs: [] as string[],
|
||||
};
|
||||
|
||||
type BabelOptions = NonNullable<Parameters<typeof parseAsync>[1]>;
|
||||
type BabelParserPlugin = NonNullable<NonNullable<BabelOptions["parserOpts"]>["plugins"]>[number];
|
||||
type SyntaxNode = { readonly type: string; readonly [key: string]: unknown };
|
||||
|
||||
// REV-FE-0003. The files Playwright runs by default (`testMatch` is
|
||||
// `**/*.@(spec|test).?(c|m)[jt]s?(x)` and playwright.config.ts does not set
|
||||
// it) and the forbidden fixtures.
|
||||
const SOURCE_FILE_PATTERN = /\.(?:[cm]?[jt]sx?|fixture|txt)$/u;
|
||||
// Code that can call skip: not text snapshots (`.txt`) or declarations (`.d.ts`).
|
||||
const SKIP_CODE_PATTERN = /(?<!\.d)\.(?:[cm]?[jt]sx?|fixture)$/u;
|
||||
const TEST_NAMES = new Set(["test", "it", "describe"]);
|
||||
// `test.describe.skip`, `test.describe.serial`, `test.step.skip`: a member of
|
||||
// a test object that is itself a test object.
|
||||
const TEST_MEMBERS = new Set([...TEST_NAMES, "serial", "parallel", "step"]);
|
||||
const SKIP_METHODS = new Set(["skip", "fixme"]);
|
||||
const SYNTAX_METADATA = new Set([
|
||||
"loc",
|
||||
"start",
|
||||
"end",
|
||||
"range",
|
||||
"extra",
|
||||
"comments",
|
||||
"leadingComments",
|
||||
"trailingComments",
|
||||
"innerComments",
|
||||
]);
|
||||
|
||||
function isSyntaxNode(value: unknown): value is SyntaxNode {
|
||||
return typeof value === "object" && value !== null && typeof (value as { type?: unknown }).type === "string";
|
||||
}
|
||||
|
||||
function syntaxChildren(node: SyntaxNode): SyntaxNode[] {
|
||||
const children: SyntaxNode[] = [];
|
||||
for (const [key, value] of Object.entries(node)) {
|
||||
if (SYNTAX_METADATA.has(key)) continue;
|
||||
for (const item of Array.isArray(value) ? value : [value]) {
|
||||
if (isSyntaxNode(item)) children.push(item);
|
||||
}
|
||||
}
|
||||
return children;
|
||||
}
|
||||
|
||||
function walkSyntax(root: SyntaxNode, visit: (node: SyntaxNode) => void): void {
|
||||
const pending = [root];
|
||||
for (let node = pending.pop(); node; node = pending.pop()) {
|
||||
visit(node);
|
||||
pending.push(...syntaxChildren(node).reverse());
|
||||
}
|
||||
}
|
||||
|
||||
/** `name`, `"name"` or `["name"]`: the name a member or an import specifier uses. */
|
||||
function staticName(node: unknown, computed = false): string | undefined {
|
||||
if (!isSyntaxNode(node)) return undefined;
|
||||
if (node.type === "Identifier" && !computed) return node["name"] as string;
|
||||
if (node.type === "StringLiteral") return node["value"] as string;
|
||||
return undefined;
|
||||
}
|
||||
|
||||
function isMember(node: SyntaxNode): boolean {
|
||||
return node.type === "MemberExpression" || node.type === "OptionalMemberExpression";
|
||||
}
|
||||
|
||||
function isCall(node: SyntaxNode): boolean {
|
||||
return node.type === "CallExpression" || node.type === "OptionalCallExpression";
|
||||
}
|
||||
|
||||
function memberName(node: SyntaxNode): string | undefined {
|
||||
return staticName(node["property"], node["computed"] === true);
|
||||
}
|
||||
|
||||
/** The identifier a chain such as `test.describe.serial(…)` or `test.info().skip` starts from. */
|
||||
function chainRoot(node: unknown): string | undefined {
|
||||
let current = node;
|
||||
while (isSyntaxNode(current)) {
|
||||
if (current.type === "Identifier") return current["name"] as string;
|
||||
if (isMember(current)) current = current["object"];
|
||||
else if (isCall(current)) current = current["callee"];
|
||||
else if (current.type === "TSNonNullExpression") current = current["expression"];
|
||||
else return undefined;
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether `node` is a test object whose `skip`·`fixme` skips a test: a test
|
||||
* name or an import alias of one, a `testInfo` parameter, `test.info()`, a
|
||||
* `test.extend(…)` result, or `test.describe`-like members of these.
|
||||
*/
|
||||
function isTestObject(node: unknown, names: ReadonlySet<string>): boolean {
|
||||
if (!isSyntaxNode(node)) return false;
|
||||
if (node.type === "Identifier") return names.has(node["name"] as string);
|
||||
if (node.type === "TSNonNullExpression") return isTestObject(node["expression"], names);
|
||||
if (isMember(node)) {
|
||||
const name = memberName(node) ?? "";
|
||||
const object = node["object"];
|
||||
// `import * as strict from "…"; strict.test.skip()`.
|
||||
if (TEST_NAMES.has(name) && isSyntaxNode(object) && object.type === "Identifier") {
|
||||
if (names.has(`* as ${object["name"] as string}`)) return true;
|
||||
}
|
||||
return TEST_MEMBERS.has(name) && isTestObject(object, names);
|
||||
}
|
||||
if (isCall(node)) {
|
||||
const callee = node["callee"];
|
||||
return (
|
||||
isSyntaxNode(callee) &&
|
||||
isMember(callee) &&
|
||||
["info", "extend"].includes(memberName(callee) ?? "") &&
|
||||
isTestObject(callee["object"], names)
|
||||
);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function isTestInfoType(parameter: SyntaxNode): boolean {
|
||||
const annotation = parameter["typeAnnotation"];
|
||||
const type = isSyntaxNode(annotation) ? annotation["typeAnnotation"] : undefined;
|
||||
return isSyntaxNode(type) && type.type === "TSTypeReference" && staticName(type["typeName"]) === "TestInfo";
|
||||
}
|
||||
|
||||
/**
|
||||
* Names that hold a test object in this file. Collected in source order,
|
||||
* so an alias is known before the calls that use it.
|
||||
*/
|
||||
function testObjectNames(root: SyntaxNode): Set<string> {
|
||||
const names = new Set([...TEST_NAMES, "testInfo"]);
|
||||
walkSyntax(root, (node) => {
|
||||
if (node.type === "ImportSpecifier") {
|
||||
const imported = staticName(node["imported"]);
|
||||
const local = staticName(node["local"]);
|
||||
if (imported && local && TEST_NAMES.has(imported)) names.add(local);
|
||||
} else if (node.type === "ImportNamespaceSpecifier" || node.type === "ImportDefaultSpecifier") {
|
||||
const local = staticName(node["local"]);
|
||||
if (local) names.add(`* as ${local}`);
|
||||
} else if (node.type === "ImportDeclaration" && staticName(node["source"]) === "@playwright/test") {
|
||||
// `import pw from "@playwright/test"`: the default export is `test` itself.
|
||||
for (const specifier of (node["specifiers"] as unknown[] | undefined) ?? []) {
|
||||
if (!isSyntaxNode(specifier) || specifier.type !== "ImportDefaultSpecifier") continue;
|
||||
const local = staticName(specifier["local"]);
|
||||
if (local) names.add(local);
|
||||
}
|
||||
} else if (node.type === "VariableDeclarator") {
|
||||
const local = staticName(node["id"]);
|
||||
if (local && isTestObject(node["init"], names)) names.add(local);
|
||||
} else if (/Function|Method/u.test(node.type)) {
|
||||
for (const parameter of (node["params"] as unknown[] | undefined) ?? []) {
|
||||
const local = isSyntaxNode(parameter) ? staticName(parameter) : undefined;
|
||||
if (local && isSyntaxNode(parameter) && isTestInfoType(parameter)) names.add(local);
|
||||
}
|
||||
} else if (isCall(node) && isTestCallee(node["callee"], names)) {
|
||||
// `test(title, async ({ page }, testInfo) => …)`, `test.beforeEach(…)`:
|
||||
// the second parameter of a test callback is its TestInfo. Not
|
||||
// `it.each(rows)(title, (a, b) => …)`, whose parameters are table data.
|
||||
for (const argument of (node["arguments"] as unknown[] | undefined) ?? []) {
|
||||
if (!isSyntaxNode(argument) || !/Function/u.test(argument.type)) continue;
|
||||
const local = staticName((argument["params"] as unknown[] | undefined)?.[1]);
|
||||
if (local) names.add(local);
|
||||
}
|
||||
}
|
||||
});
|
||||
return names;
|
||||
}
|
||||
|
||||
function isTestCallee(callee: unknown, names: ReadonlySet<string>): boolean {
|
||||
if (!isSyntaxNode(callee) || isCall(callee)) return false;
|
||||
if (names.has(chainRoot(callee) ?? "")) return true;
|
||||
// `strict.test(…)`, `strict.test.beforeEach(…)` after `import * as strict`,
|
||||
// but not `db.withCursor(…)` after `import * as db`.
|
||||
for (let current: unknown = callee; isSyntaxNode(current) && isMember(current); current = current["object"]) {
|
||||
if (isTestObject(current, names)) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function parserPlugins(file: string): BabelParserPlugin[] {
|
||||
if (/\.[cm]?jsx?$/u.test(file)) return ["jsx"];
|
||||
if (/\.[cm]?tsx$/u.test(file)) return ["typescript", "jsx"];
|
||||
return ["typescript"];
|
||||
}
|
||||
|
||||
/** Each `skip`·`fixme` call on a test object, as `<callee> at line <n>` (e.g. `testInfo.skip at line 3`). */
|
||||
async function skipCalls(file: string, source: string): Promise<string[]> {
|
||||
const syntaxTree = await parseAsync(source, {
|
||||
filename: file,
|
||||
babelrc: false,
|
||||
configFile: false,
|
||||
sourceType: "unambiguous",
|
||||
parserOpts: { plugins: parserPlugins(file) },
|
||||
});
|
||||
if (!isSyntaxNode(syntaxTree)) throw new Error("Babel returned no syntax tree");
|
||||
const names = testObjectNames(syntaxTree);
|
||||
const calls: string[] = [];
|
||||
walkSyntax(syntaxTree, (node) => {
|
||||
if (!isCall(node)) return;
|
||||
const callee = node["callee"];
|
||||
if (!isSyntaxNode(callee) || !isMember(callee)) return;
|
||||
const method = memberName(callee);
|
||||
if (!method || !SKIP_METHODS.has(method) || !isTestObject(callee["object"], names)) return;
|
||||
const line = (node["loc"] as { start?: { line?: number } } | undefined)?.start?.line ?? 0;
|
||||
const text = source.slice(callee["start"] as number, callee["end"] as number).replace(/\s+/gu, "");
|
||||
calls.push(`${text.slice(0, 60)} at line ${line}`);
|
||||
});
|
||||
return calls;
|
||||
}
|
||||
|
||||
async function filesBelow(target: string): Promise<string[]> {
|
||||
try {
|
||||
const metadata = await stat(target);
|
||||
@@ -291,21 +496,33 @@ if (!scenarioOnly) {
|
||||
);
|
||||
const today = new Date().toISOString().slice(0, 10);
|
||||
for (const file of sourceFiles) {
|
||||
if (!/\.(?:ts|tsx|fixture|txt)$/.test(file)) continue;
|
||||
if (!SOURCE_FILE_PATTERN.test(file)) continue;
|
||||
const source = await readFile(file, "utf8");
|
||||
facts.scannedFiles += 1;
|
||||
if (/\b(?:test|it|describe)(?:\.describe)?\.only\s*\(/.test(source)) {
|
||||
failures.push(`${file}: focused test (.only) runs alone and hides the rest of the suite`);
|
||||
}
|
||||
const skipPattern = /\b(?:test|it|describe)(?:\.describe)?\.(?:skip|fixme)\s*\(/g;
|
||||
if (skipPattern.test(source)) {
|
||||
// REV-FE-0003. A regular expression saw only `test.skip(`; it missed
|
||||
// `testInfo.skip(`, `test.info().skip(` and `strictTest.skip(` after
|
||||
// `import { test as strictTest }`. The syntax tree sees each call.
|
||||
let skips: string[] = [];
|
||||
if (SKIP_CODE_PATTERN.test(file) && /\b(?:skip|fixme)\b/u.test(source)) {
|
||||
try {
|
||||
skips = await skipCalls(file, source);
|
||||
} catch (error) {
|
||||
failures.push(
|
||||
`${file}: cannot parse to look for skip/fixme: ${error instanceof Error ? error.message : String(error)}`,
|
||||
);
|
||||
}
|
||||
}
|
||||
if (skips.length > 0) {
|
||||
const quarantines = [
|
||||
...source.matchAll(
|
||||
/quarantine\(owner=[^)]+,\s*defect=[^)]+,\s*expires=(\d{4}-\d{2}-\d{2})\)/g,
|
||||
),
|
||||
];
|
||||
if (quarantines.length === 0) {
|
||||
failures.push(`${file}: skip/fixme lacks owned expiring quarantine`);
|
||||
failures.push(`${file}: skip/fixme lacks owned expiring quarantine (${skips.join(", ")})`);
|
||||
}
|
||||
for (const [, expires = ""] of quarantines) {
|
||||
if (expires < today) failures.push(`${file}: quarantine expired on ${expires}`);
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
import { test as strictTest } from "../support/browser/strict-browser-test.ts";
|
||||
|
||||
strictTest("probe", async ({ page }) => {
|
||||
strictTest.skip(true, "probe");
|
||||
await page.goto("/");
|
||||
});
|
||||
@@ -0,0 +1,13 @@
|
||||
import type { TestInfo } from "@playwright/test";
|
||||
import { test as base } from "@playwright/test";
|
||||
|
||||
const strictTest = base.extend({});
|
||||
|
||||
function skipOnWebKit(info: TestInfo) {
|
||||
info.skip(true, "probe");
|
||||
}
|
||||
|
||||
strictTest.skip(true, "probe");
|
||||
base.describe.serial.skip("probe", () => {});
|
||||
base.describe.parallel.fixme("probe", () => {});
|
||||
base.step.skip("probe", async () => {});
|
||||
@@ -0,0 +1,8 @@
|
||||
import * as strict from "../support/browser/strict-browser-test.ts";
|
||||
import pw from "@playwright/test";
|
||||
|
||||
strict.test("probe", async ({ page }) => {
|
||||
strict.test.skip(true, "probe");
|
||||
pw.skip(true, "probe");
|
||||
await page.goto("/");
|
||||
});
|
||||
@@ -0,0 +1,4 @@
|
||||
test("probe", async ({ page }) => {
|
||||
test.info().skip(true, "probe");
|
||||
await page.goto("/");
|
||||
});
|
||||
@@ -0,0 +1,9 @@
|
||||
test.beforeEach(async ({ page }, info) => {
|
||||
info.skip(true, "probe");
|
||||
await page.goto("/");
|
||||
});
|
||||
|
||||
test("probe", async ({ page }, testInfo) => {
|
||||
testInfo.skip(true, "probe");
|
||||
await page.goto("/");
|
||||
});
|
||||
@@ -92,6 +92,75 @@ describe("test evidence source rules", () => {
|
||||
expect(result.stderr).toContain("lacks owned expiring quarantine");
|
||||
}, childProcessTimeout(1_188));
|
||||
|
||||
// REV-FE-0003. A regular expression saw only `test.skip(`, so these three
|
||||
// skipped a Playwright test with no quarantine and FE-GATE-008 stayed green.
|
||||
it.each([
|
||||
["testinfo-skip.fixture", "info.skip at line 2, testInfo.skip at line 7"],
|
||||
["test-info-skip.fixture", "test.info().skip at line 2"],
|
||||
["aliased-skip.fixture", "strictTest.skip at line 4"],
|
||||
["namespace-skip.fixture", "strict.test.skip at line 5, pw.skip at line 6"],
|
||||
[
|
||||
"more-skip-forms.fixture",
|
||||
[
|
||||
"info.skip at line 7",
|
||||
"strictTest.skip at line 10",
|
||||
"base.describe.serial.skip at line 11",
|
||||
"base.describe.parallel.fixme at line 12",
|
||||
"base.step.skip at line 13",
|
||||
].join(", "),
|
||||
],
|
||||
])("rejects an unquarantined skip in %s", (fixture, call) => {
|
||||
const result = checkSource(`${FORBIDDEN}/${fixture}`);
|
||||
expect(result.status).toBe(1);
|
||||
expect(result.stderr).toContain(`skip/fixme lacks owned expiring quarantine (${call})`);
|
||||
}, childProcessTimeout(955));
|
||||
|
||||
// REV-FE-0003. Playwright's default testMatch also runs `.mts`, `.cts`,
|
||||
// `.js` and `.mjs` specs, and the checker read only `ts|tsx`. Written at
|
||||
// run time so no runner or typecheck picks the probe up.
|
||||
it("reads a .spec.mts file and accepts test.fail()", async () => {
|
||||
const root = await mkdtemp(path.join(tmpdir(), "test-evidence-extensions-"));
|
||||
roots.push(root);
|
||||
const fixme = ["test", "fixme"].join(".");
|
||||
await writeFile(path.join(root, "probe.spec.mts"), `${fixme}("probe", async () => {});\n`);
|
||||
const rejected = checkSource(path.join(root, "probe.spec.mts"));
|
||||
expect(rejected.status).toBe(1);
|
||||
expect(rejected.stderr).toContain("probe.spec.mts: skip/fixme lacks owned expiring quarantine");
|
||||
|
||||
// test.fail() runs the test and expects it to fail; the rule names only
|
||||
// skip and fixme, and tests/e2e/preload-use.spec.ts uses it.
|
||||
await writeFile(
|
||||
path.join(root, "expected-failure.spec.ts"),
|
||||
'test("fails on purpose", async () => {\n // Not a skip: the words make the checker parse this file.\n test.fail();\n});\n',
|
||||
);
|
||||
const accepted = checkSource(path.join(root, "expected-failure.spec.ts"));
|
||||
expect(accepted.stderr).toBe("");
|
||||
expect(accepted.status).toBe(0);
|
||||
|
||||
// A file the parser cannot read fails instead of passing unchecked;
|
||||
// `it.each` table data named like a TestInfo is not a skip.
|
||||
const skipCall = ["it", "skip"].join(".");
|
||||
await writeFile(path.join(root, "broken.spec.ts"), `${skipCall}("unclosed", () => {\n`);
|
||||
const broken = checkSource(path.join(root, "broken.spec.ts"));
|
||||
expect(broken.status).toBe(1);
|
||||
expect(broken.stderr).toContain("broken.spec.ts: cannot parse to look for skip/fixme");
|
||||
await writeFile(
|
||||
path.join(root, "table.test.ts"),
|
||||
'it.each([[1, 2]])("skips %i rows", (input, cursor) => {\n cursor.skip(input);\n});\n',
|
||||
);
|
||||
const table = checkSource(path.join(root, "table.test.ts"));
|
||||
expect(table.stderr).toBe("");
|
||||
expect(table.status).toBe(0);
|
||||
// Nor the callback of any other namespace import.
|
||||
await writeFile(
|
||||
path.join(root, "cursor.test.ts"),
|
||||
'import * as db from "./db.ts";\n\ndb.withCursor("q", (error, cursor) => cursor.skip(10));\n',
|
||||
);
|
||||
const cursor = checkSource(path.join(root, "cursor.test.ts"));
|
||||
expect(cursor.stderr).toBe("");
|
||||
expect(cursor.status).toBe(0);
|
||||
}, childProcessTimeout(1_287));
|
||||
|
||||
it("accepts a skip under an unexpired quarantine", async () => {
|
||||
const root = await mkdtemp(path.join(tmpdir(), "test-evidence-quarantine-"));
|
||||
roots.push(root);
|
||||
|
||||
Reference in New Issue
Block a user