Last active
June 5, 2018 02:57
-
-
Save bohde/2c4e5e865a855272c13cbb72f0b7b260 to your computer and use it in GitHub Desktop.
example webpack & mocha project
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// a simple module | |
exports.add = function(a, b) { | |
return a + b; | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html> | |
<head> | |
<title>Getting Started</title> | |
</head> | |
<body> | |
<script src="dist/index.js"></script> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// our app entry point. | |
var add = require('./add').add; | |
function component() { | |
var element = document.createElement('div'); | |
element.innerHTML = add(1, 2); | |
return element; | |
} | |
document.body.appendChild(component()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "webpack-mocha-example", | |
"version": "1.0.0", | |
"description": "", | |
"private": true, | |
"dependencies": {}, | |
"devDependencies": { | |
"mocha": "^5.2.0", | |
"webpack": "^4.10.2", | |
"webpack-cli": "^3.0.2" | |
}, | |
"scripts": { | |
"build": "webpack --entry . -o dist/index.js", | |
"test": "mocha" | |
}, | |
"author": "", | |
"license": "ISC" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# setup | |
npm install | |
# run tests | |
npm test | |
# build and view in browser | |
npm run build && browse index.html |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// a simple test of our module | |
var assert = require('assert'), | |
add = require('./add').add; | |
describe('add', function() { | |
it('1 + 1 = 2', function() { | |
assert.equal(add(1, 1), 2); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment