https://github.com/stealjs/steal-mocha
Starts Mocha tests automatically after main has loaded
https://github.com/stealjs/steal-mocha
Last synced: 6 months ago
JSON representation
Starts Mocha tests automatically after main has loaded
- Host: GitHub
- URL: https://github.com/stealjs/steal-mocha
- Owner: stealjs
- License: mit
- Created: 2015-03-23T16:04:47.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2020-05-23T11:44:16.000Z (about 5 years ago)
- Last Synced: 2024-11-10T15:48:01.600Z (7 months ago)
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/steal-mocha
- Size: 39.1 KB
- Stars: 7
- Watchers: 16
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
[](https://travis-ci.org/stealjs/steal-mocha)
[](http://badge.fury.io/js/steal-mocha)# steal-mocha
Provides an easy way to automatically run Mocha tests using [StealJS](http://stealjs.com).
## Use
Add the Steal tag to your page
```html
```
This will do the equivalent of
```js
mocha.setup("bdd");
```and your tests will automatically be ran.
## Writing tests
When you write tests just be sure to import `steal-mocha`.
```js
import "steal-mocha";describe("Foo", function(){
it("bar", function(){
assert("yay!");
});
});
```## Use with Bower / manually
If you are not using NPM the following configuration is necessary:
```js
System.config({
"paths": {
"steal-mocha": "path/to/steal-mocha/steal-mocha.js",
"steal-mocha/*": "path/to/steal-mocha/*.js",
"mocha": "path/to/mocha/mocha.js",
"mocha/mocha.css": "path/to/mocha/mocha.css"
},
"meta": {
"mocha": {
"format": "global",
"exports": "mocha",
"deps": [
"steal-mocha/add-dom"
]
}
}
});
```## mocha.opts
Mocha's runner allows for a [mocha.opts](https://mochajs.org/#mochaopts) file,
specifying addition options such as `checkLeaks()`. `steal-mocha` does not parsed
a `mocha.opts` file, however allows the specification of a startup script.This is similar to the `--require` option in `mocha.opts`.
```html
```
_The path in `data-mocha-require` is a module name._
__test/setup.js__
```js
const chai = require('chai');
const sinon = require('sinon');module.exports = function(mocha) {
sinon.assert.expose(chai.assert, { prefix: '' });
};
```_The above example extends Chai's assertion library with SinonJS assertions._
## License
MIT