diff --git a/Gruntfile.js b/Gruntfile.js index 9a04fccb..dea60397 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -30,9 +30,9 @@ module.exports = function(grunt) { function() { verifyNoGlobals(() => require('./lib/jasmine-core.js').noGlobals()); const done = this.async(), - Jasmine = require('jasmine'), - jasmineCore = require('./lib/jasmine-core.js'), - jasmine = new Jasmine({jasmineCore: jasmineCore}); + Jasmine = require('jasmine'), + jasmineCore = require('./lib/jasmine-core.js'), + jasmine = new Jasmine({jasmineCore: jasmineCore}); jasmine.loadConfigFile('./spec/support/jasmine.json'); jasmine.exitOnCompletion = false; @@ -40,12 +40,44 @@ module.exports = function(grunt) { result => done(result.overallStatus === 'passed'), err => { console.error(err); - exit(1); + done(false); } ); } ); + grunt.registerTask("execSpecsInParallel", + "Run Jasmine core specs in parallel in Node.js", + function() { + // Need to require this here rather than at the top of the file + // so that we don't break verifyNoGlobals above by loading jasmine-core + // too early + const ParallelRunner = require('jasmine/parallel'); + + console.log('parallel runner pid:', process.pid); + const done = this.async(); + // TODO use this core instead of the one imported by jasmine/parallel + // const jasmineCore = require('./lib/jasmine-core.js'); + const runner = new ParallelRunner({ + // TODO: + // jasmineCore, + // numWorkers: require('os').cpus().length + }); + + runner.loadConfigFile('./spec/support/jasmine.json') + .then(() => { + runner.exitOnCompletion = false; + return runner.execute(); + }).then( + jasmineDoneInfo => done(jasmineDoneInfo.overallStatus === 'passed'), + err => { + console.error(err); + done(false); + } + ); + } + ); + grunt.registerTask("execSpecsInNode:performance", "Run Jasmine performance specs in Node.js", function() { diff --git a/spec/core/AsyncExpectationSpec.js b/spec/core/AsyncExpectationSpec.js index a0117be9..8d47e439 100644 --- a/spec/core/AsyncExpectationSpec.js +++ b/spec/core/AsyncExpectationSpec.js @@ -29,7 +29,7 @@ describe('AsyncExpectation', function() { it('converts a fail to a pass', function() { const addExpectationResult = jasmine.createSpy('addExpectationResult'), - actual = Promise.reject(), + actual = Promise.reject(new Error('nope')), expectation = jasmineUnderTest.Expectation.asyncFactory({ matchersUtil: new jasmineUnderTest.MatchersUtil({ pp: function() {} @@ -138,7 +138,7 @@ describe('AsyncExpectation', function() { } }, addExpectationResult = jasmine.createSpy('addExpectationResult'), - actual = Promise.reject(), + actual = Promise.reject(new Error('nope')), expectation = jasmineUnderTest.Expectation.asyncFactory({ actual: actual, addExpectationResult: addExpectationResult, diff --git a/spec/core/baseSpec.js b/spec/core/baseSpec.js index e0c828c5..8de92396 100644 --- a/spec/core/baseSpec.js +++ b/spec/core/baseSpec.js @@ -145,7 +145,7 @@ describe('base helpers', function() { }); it('returns a promise that resolves to false when the promise is rejected', function() { - const promise = Promise.reject(); + const promise = Promise.reject(new Error('nope')); return expectAsync(jasmineUnderTest.isPending_(promise)).toBeResolvedTo( false ); diff --git a/spec/core/integration/MatchersSpec.js b/spec/core/integration/MatchersSpec.js index 1ce62c9f..9e6994fc 100755 --- a/spec/core/integration/MatchersSpec.js +++ b/spec/core/integration/MatchersSpec.js @@ -349,7 +349,7 @@ describe('Matchers (Integration)', function() { }); verifyFailsAsync(function(env) { - return env.expectAsync(Promise.reject()).toBeResolved(); + return env.expectAsync(Promise.reject(new Error('nope'))).toBeResolved(); }); });