-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Warn that suites cannot return a value (#3550)
* Give a `DeprecationWarning` on suite callback returning any value. * Deprecation warning: Show a message only once; use `process.nextTick` when falling back to `console.warn` * Add a test for `utils.deprecate` * style: Make prettier happy * test(deprecate.spec.js): Make PR requested changes for approval (per @boneskull)
- Loading branch information
Showing
6 changed files
with
91 additions
and
8 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
'use strict'; | ||
|
||
var assert = require('assert'); | ||
var run = require('./helpers').runMocha; | ||
var args = []; | ||
|
||
describe('utils.deprecate test', function() { | ||
it('should print unique deprecation only once', function(done) { | ||
run('deprecate.fixture.js', args, function(err, res) { | ||
if (err) { | ||
return done(err); | ||
} | ||
var result = res.output.match(/deprecated thing/g) || []; | ||
assert.equal(result.length, 2); | ||
done(); | ||
}); | ||
}); | ||
}); |
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,9 @@ | ||
'use strict'; | ||
|
||
var utils = require("../../../lib/utils"); | ||
|
||
it('consolidates identical calls to deprecate', function() { | ||
utils.deprecate("suite foo did a deprecated thing"); | ||
utils.deprecate("suite foo did a deprecated thing"); | ||
utils.deprecate("suite bar did a deprecated thing"); | ||
}); |
5 changes: 5 additions & 0 deletions
5
test/integration/fixtures/suite/suite-returning-value.fixture.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,5 @@ | ||
'use strict'; | ||
|
||
describe('a suite returning a value', function () { | ||
return Promise.resolve(); | ||
}); |
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