package
Mocha loader for webpack
npm install mocha-loaderGitHub-flavored package documentation.
Across all versions.
Download trend unavailable.
Runtime metadata.
Tagged topics.
Allows Mocha tests to be loaded and run via webpack.
To begin, you'll need to install mocha-loader and mocha:
npm install --save-dev mocha-loader mochaThen add the plugin to your webpack config. For example:
file.js
import test from './test.js';webpack.config.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):
import test from 'mocha-loader!./test.js';No options for loader.
file.js
module.exports = true;test.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');
}
Please take a moment to read our contributing guidelines if you haven't yet done so.
sokra
tobias.koppers@googlemail.com
Estimated unpacked size across 25 packages.
2.7 MB
Includes dependencies.
4 direct · 4 outdated
^5.0.0
7.1.5
^2.0.0
3.3.1
^3.0.0
4.8.3
^2.0.0
4.0.0