Files
AutistMask/tests/jestRunner.test.js
T
sneak 4cb61d1a10
check / check (push) Waiting to run
e2e / e2e-chrome (push) Waiting to run
e2e / e2e-firefox (push) Waiting to run
test: run jest in one process, fail on an open handle (closes #766)
Jest force-stopped worker processes that could not exit within 500 ms on
a starved CPU, failing runs where every test passed. The test scripts now
pass --runInBand. script/lib/jest.js fails the run at once when jest
warns that it did not exit one second after the run, instead of
hanging. The Dockerfile test stage drops its 90-second timeout.

tests/jestRunner.test.js runs the runner on a fixture that leaves an
interval running and expects exit status 1.

Model: opus-5-5
2026-11-11 05:21:01 +00:00

30 lines
1009 B
JavaScript

// script/lib/jest.js, which package.json's test scripts run, fails a run in
// which a test left an open handle, instead of hanging on it.
const { spawnSync } = require("child_process");
const path = require("path");
const root = path.join(__dirname, "..");
test("a test that leaves an interval running fails the run", () => {
// The run ends about one second after its last test. Without the check in
// script/lib/jest.js it would never end, and the timeout stops it.
const result = spawnSync(
process.execPath,
[
"script/lib/jest.js",
"--runInBand",
"--testMatch",
"<rootDir>/tests/fixtures/leavesIntervalRunning.js",
],
{ cwd: root, encoding: "utf8", timeout: 20000 },
);
expect(result.signal).toBeNull();
expect(result.status).toBe(1);
expect(result.stderr).toContain("1 passed");
expect(result.stderr).toContain(
"a test left a timer or another open handle running",
);
});