diff --git a/jest.config.js b/jest.config.js index 21c7f32f..e3070358 100644 --- a/jest.config.js +++ b/jest.config.js @@ -1,6 +1,7 @@ module.exports = { preset: 'ts-jest', testEnvironment: 'node', + setupFilesAfterEnv: ['./jest.setup.ts'], collectCoverageFrom: [ 'src/*.{js,jsx}', '!**/node_modules/**', diff --git a/jest.setup.ts b/jest.setup.ts new file mode 100644 index 00000000..e32a924a --- /dev/null +++ b/jest.setup.ts @@ -0,0 +1 @@ +jest.setTimeout(20e3); diff --git a/src/__tests__/index.test.js b/src/__tests__/index.test.js index 46ba69db..c6a628db 100644 --- a/src/__tests__/index.test.js +++ b/src/__tests__/index.test.js @@ -143,12 +143,12 @@ describe('PendingXHR', () => { setTimeout(() => { request1Resolver([200, 'first xhr finished']); }); - await sleep(10); + await sleep(1000); expect(pendingXHR.pendingXhrCount()).toEqual(1); setTimeout(() => { request2Resolver([200, 'second xhr finished']); }); - await sleep(10); + await sleep(1000); expect(pendingXHR.pendingXhrCount()).toEqual(0); }); });