Skip to content

Commit

Permalink
fix(controller): add entropy to default dir (#469)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
codymikol committed Jan 29, 2021
1 parent 57b131e commit ea3dabe
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -73,7 +73,7 @@ const defaultWebpackOptions = {
mode: 'development',
output: {
filename: '[name].js',
path: path.join(os.tmpdir(), '_karma_webpack_'),
path: path.join(os.tmpdir(), '_karma_webpack_') + Math.floor(Math.random() * 1000000),
},
stats: {
modules: false,
Expand Down
3 changes: 2 additions & 1 deletion lib/KarmaWebpackController.js
Expand Up @@ -36,7 +36,8 @@ const defaultWebpackOptions = {
mode: 'development',
output: {
filename: '[name].js',
path: path.join(os.tmpdir(), '_karma_webpack_'),
// eslint-disable-next-line prettier/prettier
path: path.join(os.tmpdir(), '_karma_webpack_') + Math.floor(Math.random() * 1000000),
},
stats: {
modules: false,
Expand Down
10 changes: 5 additions & 5 deletions test/integration/scenarios/basic-setup/basic-setup.test.js
Expand Up @@ -39,14 +39,14 @@ describe('A basic karma-webpack setup', () => {
ScenarioUtils.run(config)
.then((res) => {
scenario = res;
done();
})
.catch((err) => {
jest.fail('Karma run has failed with an error', err);
done();
});
.finally(() => done());
}, KARMA_SERVER_TIMEOUT);

it('should have an exit code of 1 because it contains a failing test', () => {
expect(scenario.exitCode).toBe(1);
})

it('should have three successful test runs', () => {
expect(scenario.success).toBe(3);
});
Expand Down

0 comments on commit ea3dabe

Please sign in to comment.