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

Globals for TDD frameworks (mocha, jasmine) #1330

Closed
deniswolf opened this issue Oct 27, 2013 · 8 comments
Closed

Globals for TDD frameworks (mocha, jasmine) #1330

deniswolf opened this issue Oct 27, 2013 · 8 comments

Comments

@deniswolf
Copy link

Since contribution guide requires issue before commit && because I want to get approval first:

It seems like every JS project created since 2010 has to add describe, it etc to global.
Can we add globals for Jasmine and Mocha to whitelist, please?
Or, if you don't want to pollute globals, some generic 'tdd' option with at least describe and it could be great.

@valueof
Copy link
Member

valueof commented Oct 30, 2013

If there are only two globals, I suggest using the /*global describe, it */. Besides jQuery we've been pretty strict about adding options with only a couple of globals.

@xverges
Copy link

xverges commented Dec 17, 2013

It's usually more than just two globals with jasmine. I usually have this

/*global beforeEach, afterEach, describe, expect, it, spyOn, xdescribe, xit */

The most annoying part is that, if you work with unused:true , you may need to update this list as you add/remove your test code.

@davidagee
Copy link

I think this issue was closed prematurely. IMO, a code-quality tool should do it's best to support testing frameworks. This is a sample globals block for Jasmine, as you can see it's quite cumbersome to set up for each project:

    "globals": {
        "describe": false,
        "xdescribe": false,
        "ddescribe": false,
        "it": false,
        "xit": false,
        "iit": false,
        "beforeEach": false,
        "afterEach": false,
        "expect": false,
        "pending": false,
        "spyOn": false
    }

@rwaldron
Copy link
Member

@davidagee I don't disagree with you, but your case is better made with a pull request containing a patch with tests.

@caitp
Copy link
Member

caitp commented Sep 15, 2014

I dunno, is it really that bad? these days you can just inherit your base .jshintrc and extend it with the globals your tests need, so you don't have to maintain two lists, which is nice.

Here's the thing, some day jasmine or mocha or qunit or mjsunit or whateverunit will decide they want to add assertIsArrayLikeWithPancakes() and then jshint will have to maintain this list of items and add this new one, basically whenever someone files a bug about it, which gets cumbersome.

In other words, there's a maintenance cost to these lists.

@rwaldron
Copy link
Member

Here's the thing, some day jasmine or mocha or qunit or mjsunit or whateverunit will decide they want to add assertIsArrayLikeWithPancakes() and then jshint will have to maintain this list of items and add this new one, basically whenever someone files a bug about it, which gets cumbersome.

Yeah, this is too compelling. Previous statement retracted, no patches welcome.

@nschonni
Copy link
Contributor

@davidagee both these options are already available in 2.5.1+

jshint/src/vars.js

Lines 649 to 679 in 54c2900

exports.mocha = {
// BDD
describe : false,
it : false,
before : false,
after : false,
beforeEach : false,
afterEach : false,
// TDD
suite : false,
test : false,
setup : false,
teardown : false
};
exports.jasmine = {
jasmine : false,
describe : false,
it : false,
xit : false,
beforeEach : false,
afterEach : false,
setFixtures : false,
loadFixtures: false,
spyOn : false,
expect : false,
// Jasmine 1.3
runs : false,
waitsFor : false,
waits : false
};

@ajssd
Copy link

ajssd commented Jan 6, 2015

The trouble with the mocha global (describe, it, etc.) is that it combines TDD and BDD.

If you follow the official recommendation of selenium-webdriver and Mocha here
https://code.google.com/p/selenium/wiki/WebDriverJs#Writing_Tests

you will get a lint error on "test = require('selenium-webdriver/testing')" because "test" is being redefined. It's defined once using the "mocha" global in .jshintrc, and again here. This could be solved if the TDD and BDD globals were made distinct, e.g. "mocha-bdd": true.
ss

dgeb added a commit to ember-cli/ember-cli-mocha that referenced this issue Feb 1, 2015
In jshint 2.5.1+, Mocha vars are included with jshint.
See jshint/jshint#1330
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants