Skip to content

Commit

Permalink
Add source maps to the test build
Browse files Browse the repository at this point in the history
This way, if a test assertion fails, we know what line of code the
assertion was originally on
  • Loading branch information
andyhaskell committed Dec 26, 2018
1 parent b5a69f8 commit 0085f47
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
3 changes: 2 additions & 1 deletion package.json
Expand Up @@ -5,7 +5,7 @@
"license": "MIT",
"scripts": {
"build": "webpack",
"test": "TESTBUILD=true webpack && mocha test-dist/main.js && rm -rf test-dist"
"test": "TESTBUILD=true webpack && mocha test-dist/main.js --require source-map-support/register && rm -rf test-dist"
},
"devDependencies": {
"babel-core": "^6.26.3",
Expand All @@ -14,6 +14,7 @@
"chai": "^4.2.0",
"jquery": "^3.3.1",
"mocha": "^5.2.0",
"source-map-support": "^0.5.9",
"webpack": "^4.28.2",
"webpack-cli": "^3.1.2"
}
Expand Down
3 changes: 3 additions & 0 deletions webpack.config.js
Expand Up @@ -2,9 +2,11 @@ let glob = require("glob");

let entry = __dirname + "/app/src/page.js";
let outputPath = __dirname + "/dist/";
let devtool = "";
if (process.env.TESTBUILD) {
entry = glob.sync(__dirname + "/app/test/**/*.test.js");
outputPath = __dirname + "/test-dist/";
devtool = "source-map";
}

module.exports = {
Expand All @@ -28,4 +30,5 @@ module.exports = {
},
],
},
devtool: devtool,
};
2 changes: 1 addition & 1 deletion yarn.lock
Expand Up @@ -3178,7 +3178,7 @@ source-map-support@^0.4.15:
dependencies:
source-map "^0.5.6"

source-map-support@~0.5.6:
source-map-support@^0.5.9, source-map-support@~0.5.6:
version "0.5.9"
resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.5.9.tgz#41bc953b2534267ea2d605bccfa7bfa3111ced5f"
integrity sha512-gR6Rw4MvUlYy83vP0vxoVNzM6t8MUXqNuRsuBmBHQDu1Fh6X015FrLdgoDKcNdkwGubozq0P4N0Q37UyFVr1EA==
Expand Down

0 comments on commit 0085f47

Please sign in to comment.