Skip to content
This repository has been archived by the owner on Mar 5, 2021. It is now read-only.

Support requiring assertion libs #12

Closed
wants to merge 1 commit into from
Closed

Conversation

geddski
Copy link

@geddski geddski commented Jan 7, 2013

Mocha's CLI allows you to pass a --require option for including your assertion library (should, chai, expect etc) so you don't have to require it in every single test.

Mocha's programmatic interface currently doesn't do anything with the "require" option. This pull request shims in support for loading your assertion lib by setting the require option. In the future if/when Mocha supports this option, we can drop these few lines and stay completely backwards compatible.

Closes #11

Mocha's CLI allows you to pass a `--require` option for including your assertion library (should, chai, expect etc) so you don't have to require it in every single test.

Mocha's programmatic interface currently doesn't do anything with the "require" option. This pull request shims in support for loading your assertion lib by setting the `require` option. In the future if/when Mocha supports this option, we can drop these few lines and stay completely backwards compatible.
@ghost ghost assigned yaymukund Jan 10, 2013
@yaymukund
Copy link
Owner

You're just calling addFile. How about something like:

simplemocha: {
  all: {
    src: [
      // require should...
      'node_modules/should/lib/should.js',

      // This test can use it!
      'tests/my_test.js'
    ]
  }
}

I'm hesitant to add special code for should, chai, and expect. I'm with visionmedia that there's usually no need to encourage using a lot of globals.

@geddski
Copy link
Author

geddski commented Jan 29, 2013

Good call, that's simpler. Thx.

@geddski geddski closed this Jan 29, 2013
@steida
Copy link

steida commented Feb 3, 2013

Correction: 'node_modules/should/lib/should' should be 'node_modules/should/lib/should.js'

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

--require option not working
3 participants