Files
reverse-engineering-anything/tests/boundary/process/javascriptSourceModes.test.ts
T
84990f9777 test: remove fixed child-process deadlines from tests
239 literal timeoutMs values on cli.run and processes.run only restated
a guess at host speed. On hosted runners with four workers, cliOutput's
3-second value failed while the command still produced correct output.
Deadlines that are the behavior under test, derived from an operation
budget, or that bound a regression's wait remain.

Co-Authored-By: gensokyo-dev <342580529+gensokyo-dev@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-14 13:21:13 +08:00

40 lines
1.2 KiB
TypeScript

import { expect } from "vitest";
import { parseJavaScriptSource } from "../../../src/domain/javascript/javascriptSourceParser.js";
import { processTest } from "../../support/process/processFixture.js";
for (const source of [
"return;",
"void new.target;",
"var await = 1; return;",
"with ({ value: 1 }) { void value; } void new.target;",
]) {
processTest(
`accepts Node CommonJS syntax while retaining module errors: ${source}`,
async ({ processes }) => {
const commonjs = await processes.run(
process.execPath,
["--check", "--input-type=commonjs"],
{ input: source },
);
expect(commonjs.exitCode).toBe(0);
const module = await processes.run(
process.execPath,
["--check", "--input-type=module"],
{ input: source },
);
expect(module.exitCode).not.toBe(0);
const parsed = parseJavaScriptSource(source, "main.cjs");
expect(parsed).not.toBeNull();
expect(parsed?.errors).toEqual([]);
expect(
parseJavaScriptSource(source, "main.mjs")?.errors.length,
).toBeGreaterThan(0);
expect(
parseJavaScriptSource(source, "main.mts")?.errors.length,
).toBeGreaterThan(0);
},
);
}