Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Webpack mocha loader runs multiple times
expect = require('chai').expect;
describe('arithmetic', function() {
it("adds numbers", function() {
expect(1 + 1).to.eql(2);
});
});
{
"name": "mochatest",
"version": "1.0.0",
"devDependencies": {
"chai": "^1",
"mocha": "^1",
"mocha-loader": "^0.6",
"script-loader": "^0.5",
"webpack": "^1"
}
}
expect = require('chai').expect;
describe('strings', function() {
it("concatenates", function() {
expect("foo" + "bar").to.eql("foobar");
});
});
<!DOCTYPE html>
<html>
<head>
<meta http-equiv='Content-type' content='text/html; charset=utf-8'>
<title>Mocha Tests</title>
</head>
<body>
<script src="test_bundle.js"></script>
</body>
</html>
module.exports = {
entry: ["mocha!./NumberSpec.js", "mocha!./StringSpec.js"],
output: {
filename: 'test_bundle.js'
}
}
@ampedandwired

This comment has been minimized.

Copy link
Owner Author

ampedandwired commented Jul 11, 2014

Run "webpack" and open test.html in a browser. Tests are run twice.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.