{"library":"mocha-loader","title":"mocha-loader","description":"A webpack loader that allows Mocha tests to be bundled and run via webpack. Current stable version is 5.1.5 (October 2020), supporting mocha ^5.0.0 to ^8.0.0 and webpack ^4.0.0 || ^5.0.0. It is maintained under the webpack-contrib organization. Key differentiator: integrates Mocha testing into the webpack build pipeline, enabling module resolution, loaders, and plugins for test files. No options are needed; simply apply the loader to test files. Note: v5.0.0 dropped support for the node target (only works in browser-like environments). Release cadence is sporadic; last release over 3 years ago.","language":"javascript","status":"maintenance","last_verified":"Sat Apr 25","install":{"commands":["npm install mocha-loader"],"cli":null},"imports":["import test from 'mocha-loader!./test.js'","module.exports = { module: { rules: [ { test: /\\.test\\.js$/, use: 'mocha-loader' } ] } }","import 'mocha-loader!./test.js'"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"// Install\nnpm install --save-dev mocha-loader mocha webpack\n\n// webpack.config.js\nmodule.exports = {\n  entry: './entry.js',\n  output: { path: __dirname, filename: 'bundle.js' },\n  module: {\n    rules: [\n      { test: /\\.test\\.js$/, use: 'mocha-loader', exclude: /node_modules/ },\n    ],\n  },\n};\n\n// entry.js\nimport './test.test.js';\n\n// test.test.js\ndescribe('Test', () => {\n  it('should pass', () => {});\n});\n\n// Build and run (in browser)\n// webpack\n// open index.html (which includes bundle.js)","lang":"javascript","description":"Shows a minimal setup: install dependencies, configure webpack rule, write a test file, and build. Tests run when the bundle is loaded in a browser.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}