Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/webpack-contrib/mocha-loader
Mocha Loader
https://github.com/webpack-contrib/mocha-loader
mocha webpack-loader
Last synced: 13 days ago
JSON representation
Mocha Loader
- Host: GitHub
- URL: https://github.com/webpack-contrib/mocha-loader
- Owner: webpack-contrib
- License: mit
- Archived: true
- Created: 2012-11-13T11:51:34.000Z (about 12 years ago)
- Default Branch: master
- Last Pushed: 2020-12-22T14:30:48.000Z (about 4 years ago)
- Last Synced: 2024-11-16T14:36:14.405Z (3 months ago)
- Topics: mocha, webpack-loader
- Language: JavaScript
- Homepage:
- Size: 1.81 MB
- Stars: 146
- Watchers: 11
- Forks: 51
- Open Issues: 8
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: .github/CONTRIBUTING.md
- Funding: .github/FUNDING.yml
- License: LICENSE
- Codeowners: .github/CODEOWNERS
Awesome Lists containing this project
README
# DEPRECATED
If you would like to continue to support/maintenance this package please contact me https://twitter.com/alexander_akait
[![npm][npm]][npm-url]
[![node][node]][node-url]
[![deps][deps]][deps-url]
[![tests][tests]][tests-url]
[![coverage][cover]][cover-url]
[![chat][chat]][chat-url]
[![size][size]][size-url]# mocha-loader
Allows [Mocha](https://mochajs.org/) tests to be loaded and run via webpack.
## Getting Started
To begin, you'll need to install `mocha-loader` and `mocha`:
```console
npm install --save-dev mocha-loader mocha
```Then add the plugin to your `webpack` config. For example:
**file.js**
```js
import test from './test.js';
```**webpack.config.js**
```js
module.exports = {
entry: './entry.js',
output: {
path: __dirname,
filename: 'bundle.js',
},
module: {
rules: [
{
test: /test\.js$/,
use: 'mocha-loader',
exclude: /node_modules/,
},
],
},
};
```And run `webpack` via your preferred method.
Alternative usage (without configuration):
```js
import test from 'mocha-loader!./test.js';
```No options for loader.
## Examples
### Basic
**file.js**
```js
module.exports = true;
```**test.js**
```js
describe('Test', () => {
it('should succeed', (done) => {
setTimeout(done, 1000);
});it('should fail', () => {
setTimeout(() => {
throw new Error('Failed');
}, 1000);
});it('should randomly fail', () => {
if (require('./module')) {
throw new Error('Randomly failed');
}
});
});
```## Contributing
Please take a moment to read our contributing guidelines if you haven't yet done so.
[CONTRIBUTING](./.github/CONTRIBUTING.md)
## License
[MIT](./LICENSE)
[npm]: https://img.shields.io/npm/v/mocha-loader.svg
[npm-url]: https://npmjs.com/package/mocha-loader
[node]: https://img.shields.io/node/v/mocha-loader.svg
[node-url]: https://nodejs.org
[deps]: https://david-dm.org/webpack-contrib/mocha-loader.svg
[deps-url]: https://david-dm.org/webpack-contrib/mocha-loader
[tests]: https://github.com/webpack-contrib/mocha-loader/workflows/mocha-loader/badge.svg
[tests-url]: https://github.com/webpack-contrib/mocha-loader/actions
[cover]: https://codecov.io/gh/webpack-contrib/mocha-loader/branch/master/graph/badge.svg
[cover-url]: https://codecov.io/gh/webpack-contrib/mocha-loader
[chat]: https://badges.gitter.im/webpack/webpack.svg
[chat-url]: https://gitter.im/webpack/webpack
[size]: https://packagephobia.now.sh/badge?p=mocha-loader
[size-url]: https://packagephobia.now.sh/result?p=mocha-loader