// script/lib/jest.js, which package.json's test scripts run, fails a run in // which jest force-stopped a worker process because a test left an open // handle. 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 memory limit in package.json makes jest run even this one file in a // worker process. The interval keeps that worker from exiting, so jest // force-stops it after the run. const result = spawnSync( process.execPath, [ "script/lib/jest.js", "--maxWorkers=1", "--testMatch", "/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("jest force-stopped a worker process"); });