diff --git a/e2e/test/hit-limit/.mocharc.json b/e2e/test/hit-limit/.mocharc.json index 60c67f45ec..a17ebe5b50 100644 --- a/e2e/test/hit-limit/.mocharc.json +++ b/e2e/test/hit-limit/.mocharc.json @@ -1,3 +1,3 @@ { - "spec": "test/**.mocha.spec.js" + "require": ["test/chai-setup.js"] } diff --git a/e2e/test/hit-limit/jasmine.json b/e2e/test/hit-limit/jasmine.json deleted file mode 100644 index a196889531..0000000000 --- a/e2e/test/hit-limit/jasmine.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "spec_dir": "test", - "spec_files": ["**/*.jasmine.spec.js"] -} diff --git a/e2e/test/hit-limit/karma.conf.js b/e2e/test/hit-limit/karma.conf.js index a6ab56e361..970e6705ee 100644 --- a/e2e/test/hit-limit/karma.conf.js +++ b/e2e/test/hit-limit/karma.conf.js @@ -3,7 +3,7 @@ module.exports = function(config) { frameworks: ['jasmine'], files: [ 'src/*.js', - 'test/*.karma.spec.js' + 'test/*.spec.js' ], reporters: ['progress'], colors: true, diff --git a/e2e/test/hit-limit/package.json b/e2e/test/hit-limit/package.json index 2a08585eb8..3607603a50 100644 --- a/e2e/test/hit-limit/package.json +++ b/e2e/test/hit-limit/package.json @@ -6,7 +6,7 @@ "main": "index.js", "scripts": { "test:mocha": "mocha", - "test:jasmine": "jasmine --config=jasmine.json", + "test:jasmine": "jasmine", "test:karma": "karma start", "test": "mocha --no-package --timeout 60000 --require \"../../tasks/ts-node-register.js\" verify/verify.ts" }, diff --git a/e2e/test/hit-limit/spec/support/jasmine.json b/e2e/test/hit-limit/spec/support/jasmine.json new file mode 100644 index 0000000000..67fbf562e7 --- /dev/null +++ b/e2e/test/hit-limit/spec/support/jasmine.json @@ -0,0 +1,8 @@ +{ + "spec_dir": "spec", + "spec_files": [ + "../test/*.spec.js" + ], + "stopSpecOnExpectationFailure": false, + "random": true +} diff --git a/e2e/test/hit-limit/stryker.conf.json b/e2e/test/hit-limit/stryker.conf.json index 93b882c52a..8a3865ebd1 100644 --- a/e2e/test/hit-limit/stryker.conf.json +++ b/e2e/test/hit-limit/stryker.conf.json @@ -9,6 +9,5 @@ "configFile": "karma.conf.js", "config": {} }, - "jasmineConfigFile": "jasmine.json", "concurrency": 1 } diff --git a/e2e/test/hit-limit/test/chai-setup.js b/e2e/test/hit-limit/test/chai-setup.js new file mode 100644 index 0000000000..38e9e0f335 --- /dev/null +++ b/e2e/test/hit-limit/test/chai-setup.js @@ -0,0 +1,6 @@ +const chai = require('chai'); + +chai.util.addMethod(chai.Assertion.prototype, 'toEqual', function (expected) { + var obj = chai.util.flag(this, 'object'); + new chai.Assertion(obj).to.deep.equal(expected); +}); diff --git a/e2e/test/hit-limit/test/loop.jasmine.spec.js b/e2e/test/hit-limit/test/loop.jasmine.spec.js deleted file mode 100644 index 97f8947ccb..0000000000 --- a/e2e/test/hit-limit/test/loop.jasmine.spec.js +++ /dev/null @@ -1,9 +0,0 @@ -const { loop } = require('../src/loop'); - -describe('loop', () => { - it('should result in 15 for n=5 and a sum function', () => { - let result = 0; - loop(5, (n) => (result += n)); - expect(result).toBe(15); - }); -}); diff --git a/e2e/test/hit-limit/test/loop.karma.spec.js b/e2e/test/hit-limit/test/loop.karma.spec.js deleted file mode 100644 index eb5f809cb2..0000000000 --- a/e2e/test/hit-limit/test/loop.karma.spec.js +++ /dev/null @@ -1,7 +0,0 @@ -describe('loop', () => { - it('should result in 15 for n=5 and a sum function', () => { - let result = 0; - loop(5, n => result += n); - expect(result).toBe(15); - }); -}); diff --git a/e2e/test/hit-limit/test/loop.mocha.spec.js b/e2e/test/hit-limit/test/loop.mocha.spec.js deleted file mode 100644 index 7cc39e2485..0000000000 --- a/e2e/test/hit-limit/test/loop.mocha.spec.js +++ /dev/null @@ -1,10 +0,0 @@ -const { loop } = require('../src/loop'); -const { expect } = require('chai'); - -describe('loop', () => { - it('should result in 15 for n=5 and a sum function', () => { - let result = 0; - loop(5, (n) => (result += n)); - expect(result).to.eq(15); - }); -}); diff --git a/e2e/test/hit-limit/test/loop.spec.js b/e2e/test/hit-limit/test/loop.spec.js new file mode 100644 index 0000000000..0b386c7ecc --- /dev/null +++ b/e2e/test/hit-limit/test/loop.spec.js @@ -0,0 +1,14 @@ +if (typeof require === 'function') { + loop = require('../src/loop').loop; +} +if (typeof expect === 'undefined') { + globalThis.expect = require('chai').expect; +} + +describe('loop', () => { + it('should result in 15 for n=5 and a sum function', () => { + let result = 0; + loop(5, (n) => (result += n)); + expect(result).toEqual(15); + }); +}); diff --git a/packages/jasmine-runner/test/integration/timeout-on-infinite-loop.it.spec.ts b/packages/jasmine-runner/test/integration/timeout-on-infinite-loop.it.spec.ts index 8e4ab06db0..b17ee60be1 100644 --- a/packages/jasmine-runner/test/integration/timeout-on-infinite-loop.it.spec.ts +++ b/packages/jasmine-runner/test/integration/timeout-on-infinite-loop.it.spec.ts @@ -16,42 +16,20 @@ describe('Infinite loop', () => { await sut.dispose(); }); - it.skip('should report a timeout eventually and be able to recover from it', async function () { - // TODO Mocha runner doesn't seem to detect timeout in infinite loop - this.timeout(1000); - - // This is a slow test, so I decided to put 2 tests into one 🤷‍♀️ - // Act - const result = await sut.mutantRun(factory.mutantRunOptions()); - - // Assert - assertions.expectTimeout(result); - - // Second test, should be recovered by now. - const secondResult = await sut.mutantRun(factory.mutantRunOptions({ testFilter: ['spec1'] })); - assertions.expectSurvived(secondResult); - expect(secondResult.nrOfTests).eq(1); - }); - it('should be able to recover using a hit counter', async () => { - // Time this test, this should be fairly stable because there is large margin - const startTime = new Date(); - const maxTestDurationMS = 5000; + // Arrange + const options = factory.mutantRunOptions({ + activeMutant: factory.mutant({ id: '19' }), + testFilter: ['spec2'], + hitLimit: 10, + }); - const result = await sut.mutantRun( - factory.mutantRunOptions({ - activeMutant: factory.mutant({ id: '19' }), - testFilter: ['spec2'], - hitLimit: 10, - }) - ); + // Act + const result = await sut.mutantRun(options); // Assert assertions.expectTimeout(result); expect(result.reason).contains('Hit limit reached'); - expect(new Date().valueOf() - startTime.valueOf(), 'Test took longer than 3 sec to complete, was the hit counter malfunctioning?').lt( - maxTestDurationMS - ); }); it('should reset hit counter state correctly between runs', async () => {