-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support for mocha's 'qunit' interface #833
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,8 @@ var q = require('q'), | |
hasES6Support = require('../helpers/detectHarmony'), | ||
interfaces = { | ||
bdd: ['before', 'beforeEach', 'it', 'after', 'afterEach'], | ||
tdd: ['suiteSetup', 'setup', 'test', 'suiteTeardown', 'teardown'] | ||
tdd: ['suiteSetup', 'setup', 'test', 'suiteTeardown', 'teardown'], | ||
qunit: ['before', 'beforeEach', 'test', 'after', 'afterEach'] | ||
}; | ||
|
||
/** | ||
|
@@ -18,7 +19,7 @@ module.exports.run = function(config, specs, capabilities) { | |
requires = config.mochaOpts.require, | ||
runner; | ||
|
||
if(typeof config.mochaOpts.ui !== 'string' || !config.mochaOpts.ui.match(/(bdd|tdd)/i)) { | ||
if(typeof config.mochaOpts.ui !== 'string') { | ||
config.mochaOpts.ui = 'bdd'; | ||
} | ||
|
||
|
@@ -46,7 +47,7 @@ module.exports.run = function(config, specs, capabilities) { | |
/** | ||
* enable generators if supported | ||
*/ | ||
if(hasES6Support) { | ||
if(hasES6Support && interfaces[config.mochaOpts.ui]) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This prevents the above changes from breaking anything for interfaces you don't support. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why did you add qunit in the interface at all? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Mocha has 5 interfaces. https://mochajs.org/#interfaces One of my projects uses one that you (without this PR) don't support. |
||
mocha.suite.on('pre-require', function() { | ||
interfaces[config.mochaOpts.ui].forEach(runInGenerator.bind(null, config.mochaOpts.ui)); | ||
}); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mocha may have new interfaces added to it in the future. This sort of thing shouldn't be hard-coded.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if we have it hard coded in the
interfaces
object why not here?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because writing it this way makes it so that the worst that happens for interfaces you don't support is that generators won't work. The worst case for the way you wrote it is that it reverts to an entirely different interface.