// 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", "/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", ); });