Skip to content

Commit ea3dabe

Browse files
authored
fix(controller): add entropy to default dir (#469)
This adds a random number to the end of the default karma_webpack directory. This will prevent projects running multiple instances of karma webpack in parallel from stepping on one another. Fixes #465
1 parent 57b131e commit ea3dabe

File tree

3 files changed

+8
-7
lines changed

3 files changed

+8
-7
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ const defaultWebpackOptions = {
7373
mode: 'development',
7474
output: {
7575
filename: '[name].js',
76-
path: path.join(os.tmpdir(), '_karma_webpack_'),
76+
path: path.join(os.tmpdir(), '_karma_webpack_') + Math.floor(Math.random() * 1000000),
7777
},
7878
stats: {
7979
modules: false,

lib/KarmaWebpackController.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ const defaultWebpackOptions = {
3636
mode: 'development',
3737
output: {
3838
filename: '[name].js',
39-
path: path.join(os.tmpdir(), '_karma_webpack_'),
39+
// eslint-disable-next-line prettier/prettier
40+
path: path.join(os.tmpdir(), '_karma_webpack_') + Math.floor(Math.random() * 1000000),
4041
},
4142
stats: {
4243
modules: false,

test/integration/scenarios/basic-setup/basic-setup.test.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,14 @@ describe('A basic karma-webpack setup', () => {
3939
ScenarioUtils.run(config)
4040
.then((res) => {
4141
scenario = res;
42-
done();
4342
})
44-
.catch((err) => {
45-
jest.fail('Karma run has failed with an error', err);
46-
done();
47-
});
43+
.finally(() => done());
4844
}, KARMA_SERVER_TIMEOUT);
4945

46+
it('should have an exit code of 1 because it contains a failing test', () => {
47+
expect(scenario.exitCode).toBe(1);
48+
})
49+
5050
it('should have three successful test runs', () => {
5151
expect(scenario.success).toBe(3);
5252
});

0 commit comments

Comments
 (0)