Skip to content
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

Merged
merged 1 commit into from
Oct 28, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 4 additions & 3 deletions lib/frameworks/mocha.js
Original file line number Diff line number Diff line change
Expand Up @@ -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']
};

/**
Expand All @@ -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') {
Copy link
Author

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.

Copy link
Member

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?

Copy link
Author

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.

config.mochaOpts.ui = 'bdd';
}

Expand Down Expand Up @@ -46,7 +47,7 @@ module.exports.run = function(config, specs, capabilities) {
/**
* enable generators if supported
*/
if(hasES6Support) {
if(hasES6Support && interfaces[config.mochaOpts.ui]) {
Copy link
Author

Choose a reason for hiding this comment

The 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.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why did you add qunit in the interface at all?

Copy link
Author

Choose a reason for hiding this comment

The 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));
});
Expand Down