Skip to content
This repository has been archived by the owner on Dec 22, 2020. It is now read-only.

Commit

Permalink
test: refactor to improve stability (#111)
Browse files Browse the repository at this point in the history
- webpack's watchfilesystem uses an interval to manage stuff.
- if not purged, jest randomly warns about left-over open handles.
- increase test timeout to 30s.
- cleanup test in reverse setup order to avoid race conditions.
- use default (ws) transport of puppeteer.
  • Loading branch information
AviVahl authored Oct 9, 2020
1 parent 98dc1e4 commit 707706c
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions test/loader.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,19 @@ describe('mocha-loader', () => {
const disposables = new Set();

afterEach(async () => {
await Promise.all(Array.from(disposables).map((d) => d()));
for (const dispose of Array.from(disposables).reverse()) {
// eslint-disable-next-line no-await-in-loop
await dispose();
}
disposables.clear();
});

it('executes mocha tests when evaluating bundle in browser', async () => {
// bundle using loader
const compiler = getCompiler(`${loaderPath}!${testFileFixturePath}`);
if (compiler.inputFileSystem.purge) {
disposables.add(() => compiler.inputFileSystem.purge());
}
const stats = await compile(compiler);

const { errors, warnings } = stats.compilation;
Expand All @@ -51,7 +57,6 @@ describe('mocha-loader', () => {
const browser = await puppeteer.launch({
devtools: false,
timeout: 15000,
pipe: true,
});
disposables.add(() => browser.close());

Expand All @@ -70,5 +75,5 @@ describe('mocha-loader', () => {

expect(passes).toContain('passes: 1');
expect(failed).toContain('failures: 1');
}, 20000);
}, 30000);
});

0 comments on commit 707706c

Please sign in to comment.