-
Notifications
You must be signed in to change notification settings - Fork 145
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Made the promise returned from Jasmine#execute usable
* An exitOnCompletion property to control whether Jasmine should make the Nnode process exit directly, rather than as a side effect of calling onComplete * The promise returned from execute is resolved to the overall status * onComplete is marked deprecated. onComplete's behavior of installing a completion handler and also preventing exit is clever, and actually what anyone using it probably wants, but it's also non-obvious. The two-step process of setting exitOnCompletion = false and then using the promise returned from execute() is not as slick, but it's probably better for an audience that increasingly (for good reason) prefers promise- or async/await-based async.
- Loading branch information
Showing
8 changed files
with
182 additions
and
12 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
const Jasmine = require('../..'); | ||
const jasmine = new Jasmine(); | ||
|
||
it('fails', function() { | ||
expect(1).toBe(2); | ||
}); | ||
|
||
jasmine.execute(); |
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 @@ | ||
const Jasmine = require('../..'); | ||
const jasmine = new Jasmine(); | ||
|
||
it('a spec', function() {}); | ||
|
||
jasmine.exitOnCompletion = false; | ||
jasmine.execute().finally(function() { | ||
setTimeout(function() { | ||
console.log("in setTimeout cb"); | ||
}); | ||
}); |
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,13 @@ | ||
const Jasmine = require('../..'); | ||
const jasmine = new Jasmine(); | ||
|
||
it('a spec', function() { | ||
expect(1).toBe(2); | ||
}); | ||
|
||
jasmine.exitOnCompletion = false; | ||
jasmine.execute().then(function(result) { | ||
if (result.overallStatus === 'failed') { | ||
console.log("Promise failure!"); | ||
} | ||
}); |
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,13 @@ | ||
const Jasmine = require('../..'); | ||
const jasmine = new Jasmine(); | ||
|
||
it('a spec', function() {}); | ||
|
||
fit('another spec', function() {}); | ||
|
||
jasmine.exitOnCompletion = false; | ||
jasmine.execute().then(function(result) { | ||
if (result.overallStatus === 'incomplete') { | ||
console.log("Promise incomplete!"); | ||
} | ||
}); |
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 @@ | ||
const Jasmine = require('../..'); | ||
const jasmine = new Jasmine(); | ||
|
||
it('a spec', function() {}); | ||
|
||
jasmine.exitOnCompletion = false; | ||
jasmine.execute().then(function(result) { | ||
if (result.overallStatus === 'passed') { | ||
console.log("Promise 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