Skip to content

Commit

Permalink
fix lint and cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
jeysal committed Apr 5, 2021
1 parent baa0b34 commit 0c8f158
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,28 +15,23 @@ import runJest from '../runJest';

const DIR = path.resolve(tmpdir(), 'inspector');

beforeEach(() => cleanup(DIR));
afterAll(() => cleanup(DIR));
afterEach(() => cleanup(DIR));

test('fails a test which causes an infinite loop', () => {
const testFiles = {
...generateTestFilesToForceUsingWorkers(),
'package.json': `{
"testEnvironment": "node"
}`,
};
it('fails a test which causes an infinite loop', () => {
const testFiles = generateTestFilesToForceUsingWorkers();

writeFiles(DIR, {
...testFiles,
'__tests__/inspector.test.js': `
test('infinite loop error', () => {
while(true) {}
});
`,
test('infinite loop error', () => {
while(true) {}
});
`,
'package.json': '{}',
});

const {exitCode, stderr} = runJest(DIR, ['--maxWorkers=2']);

expect(exitCode).toBe(1);
expect(stderr).toContain('Error: Test worker was unresponsive');
expect(stderr).toMatch(/worker.+unresponsive/);
});
4 changes: 2 additions & 2 deletions packages/jest-haste-map/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -727,11 +727,11 @@ export default class HasteMap extends EventEmitter {
exposedMethods: ['getSha1', 'worker'],
maxRetries: 3,
numWorkers: this._options.maxWorkers,
}) as Promise<WorkerInterface>;
});
}
}

return this._worker;
return this._worker!;
}

private _crawl(hasteMap: InternalHasteMap) {
Expand Down

0 comments on commit 0c8f158

Please sign in to comment.