-
Notifications
You must be signed in to change notification settings - Fork 250
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(karma-runner): force bail = true in all cases
Force "bail" (or "failFast") for jasmine and mocha test frameworks. This should improve performance.
- Loading branch information
Showing
13 changed files
with
154 additions
and
113 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
packages/karma-runner/test/integration/read-config.it.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import path = require('path'); | ||
|
||
import { testInjector, factory, assertions } from '@stryker-mutator/test-helpers'; | ||
import { TestStatus } from '@stryker-mutator/api/test_runner2'; | ||
import { expect } from 'chai'; | ||
|
||
import KarmaTestRunner from '../../src/KarmaTestRunner'; | ||
import StrykerReporter from '../../src/karma-plugins/StrykerReporter'; | ||
|
||
describe('read config integration', () => { | ||
afterEach(() => { | ||
StrykerReporter.instance.removeAllListeners(); | ||
}); | ||
it('should not override client options in a mocha project', async () => { | ||
testInjector.options.karma = { | ||
configFile: path.resolve(__dirname, '..', '..', 'testResources', 'configs', 'mocha-client-options-karma.conf.js'), | ||
}; | ||
const runner = testInjector.injector.injectClass(KarmaTestRunner); | ||
await runner.init(); | ||
const dryRunResult = await runner.dryRun(factory.dryRunOptions()); | ||
assertions.expectCompleted(dryRunResult); | ||
expect(dryRunResult.tests).lengthOf(2); | ||
const [test1, test2] = dryRunResult.tests; | ||
expect(test1.status).eq(TestStatus.Success); | ||
expect(test1.id).eq('mocha client options should not override client options'); | ||
assertions.expectFailed(test2); | ||
expect(test2.id).eq('mocha client options should override bail'); | ||
expect(test2.failureMessage).contains('Expected exception'); | ||
}); | ||
it('should not override client options in a jasmine project', async () => { | ||
testInjector.options.karma = { | ||
configFile: path.resolve(__dirname, '..', '..', 'testResources', 'configs', 'jasmine-client-options-karma.conf.js'), | ||
}; | ||
const runner = testInjector.injector.injectClass(KarmaTestRunner); | ||
await runner.init(); | ||
const dryRunResult = await runner.dryRun(factory.dryRunOptions()); | ||
assertions.expectCompleted(dryRunResult); | ||
expect(dryRunResult.tests).lengthOf(3); | ||
const [test1, test2, test3] = dryRunResult.tests; | ||
expect([test1.name, test2.name, test3.name]).deep.eq([ | ||
'jasmine client options should not override client options', | ||
'jasmine client options should override "random" options', | ||
'jasmine client options should override "failFast" options', | ||
]); | ||
expect(test1.status).eq(TestStatus.Success); | ||
expect(test2.status).eq(TestStatus.Success); | ||
expect(test3.status).eq(TestStatus.Success); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 0 additions & 64 deletions
64
packages/karma-runner/testResources/configs/example-karma.conf.js
This file was deleted.
Oops, something went wrong.
12 changes: 0 additions & 12 deletions
12
packages/karma-runner/testResources/configs/files-karma.conf.js
This file was deleted.
Oops, something went wrong.
11 changes: 11 additions & 0 deletions
11
packages/karma-runner/testResources/configs/jasmine-client-options-echo-ui.spec.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
describe('jasmine client options', () => { | ||
it('should not override client options', function() { | ||
expect(jasmine.getEnv().configuration().oneFailurePerSpec).toBe(true); | ||
}); | ||
it('should override "random" options', function() { | ||
expect(jasmine.getEnv().configuration().random).toBe(false); | ||
}); | ||
it('should override "failFast" options', function() { | ||
expect(jasmine.getEnv().configuration().failFast).toBe(true); | ||
}); | ||
}) |
18 changes: 18 additions & 0 deletions
18
packages/karma-runner/testResources/configs/jasmine-client-options-karma.conf.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
module.exports = function (config) { | ||
config.set({ | ||
frameworks: ['jasmine'], | ||
browsers: ['ChromeHeadless'], | ||
files: [ | ||
require.resolve('./jasmine-client-options-echo-ui.spec.js') | ||
], | ||
client: { | ||
jasmine: { | ||
random: true, | ||
oneFailurePerSpec: true, | ||
failFast: false, | ||
timeoutInterval: 1000 | ||
} | ||
}, | ||
singleRun: true | ||
}); | ||
}; |
10 changes: 10 additions & 0 deletions
10
packages/karma-runner/testResources/configs/mocha-client-options-echo-ui.spec.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
suite('mocha client options', () => { | ||
test('should not override client options', async function() { | ||
expect(mocha.options.global).include('jQuery'); | ||
}); | ||
test('should override bail', async () => { | ||
throw new Error('Expected exception'); | ||
}); | ||
test('should not execute this test', async () => { | ||
}); | ||
}) |
17 changes: 17 additions & 0 deletions
17
packages/karma-runner/testResources/configs/mocha-client-options-karma.conf.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
module.exports = function (config) { | ||
config.set({ | ||
frameworks: ['mocha', 'chai'], | ||
browsers: ['ChromeHeadless'], | ||
files: [ | ||
require.resolve('./mocha-client-options-echo-ui.spec.js') | ||
], | ||
client: { | ||
mocha: { | ||
global: ['jQuery'], | ||
ui: 'tdd', | ||
bail: false // should be overridden by Stryker | ||
} | ||
}, | ||
singleRun: true | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters