Skip to content

Instantly share code, notes, and snippets.

@ampedandwired
Created July 11, 2014 01:57
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ampedandwired/ffee80734382123a3b14 to your computer and use it in GitHub Desktop.
Save ampedandwired/ffee80734382123a3b14 to your computer and use it in GitHub Desktop.
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
Copy link
Author

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