Skip to content

Commit

Permalink
fix: apply source-maps to test errors
Browse files Browse the repository at this point in the history
When we got rid of ts-node in #602, we also unintentionally dropped
the code modifying error stack traces to point to original TypeScript
sources instead of the transpiled JavaScript output.

As a result, assertion failures contained stack traces pointing to code
that we are not familiar with, which made troubleshooing difficult.

This commits add source-map-support as a dependency of our projects
and modifies shared `mocha.opts` to register it at runtime.
  • Loading branch information
bajtos committed Jan 22, 2018
1 parent 0227f2d commit 3e171d6
Show file tree
Hide file tree
Showing 16 changed files with 31 additions and 15 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
"node": ">=6"
},
"license": "MIT",
"dependencies": {},
"devDependencies": {
"@commitlint/cli": "^5.2.5",
"@commitlint/config-conventional": "^6.0.2",
Expand All @@ -19,7 +18,8 @@
"coveralls": "^3.0.0",
"cz-conventional-changelog": "^2.1.0",
"lerna": "^2.5.1",
"mocha": "^4.0.0"
"mocha": "^4.0.0",
"source-map-support": "^0.5.2"
},
"scripts": {
"bootstrap": "npm i && lerna bootstrap",
Expand Down
3 changes: 2 additions & 1 deletion packages/authentication/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@
"@loopback/testlab": "^4.0.0-alpha.19",
"@types/passport": "^0.4.0",
"@types/passport-http": "^0.3.3",
"passport-http": "^0.3.0"
"passport-http": "^0.3.0",
"source-map-support": "^0.5.2"
},
"keywords": [
"LoopBack",
Expand Down
1 change: 1 addition & 0 deletions packages/build/mocha.opts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
--recursive
--exit
--reporter dot
--require source-map-support/register
5 changes: 3 additions & 2 deletions packages/build/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,11 @@
"prettier:check": "npm run prettier:cli -- -l",
"prettier:fix": "npm run prettier:cli -- --write",
"test": "npm run mocha",
"mocha": "node bin/select-dist mocha --timeout 30000 --opts mocha.opts \"test/integration/*.js\"",
"mocha": "node bin/select-dist mocha --timeout 30000 \"test/integration/*.js\"",
"posttest": "npm run lint"
},
"devDependencies": {
"fs-extra": "^5.0.0"
"fs-extra": "^5.0.0",
"source-map-support": "^0.5.2"
}
}
1 change: 1 addition & 0 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"nsp": "^3.1.0",
"rimraf": "^2.6.2",
"sinon": "^4.1.2",
"source-map-support": "^0.5.2",
"yeoman-assert": "^3.1.0",
"yeoman-test": "^1.7.0"
},
Expand Down
3 changes: 2 additions & 1 deletion packages/context/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@
"@loopback/testlab": "^4.0.0-alpha.19",
"@types/bluebird": "^3.5.18",
"@types/debug": "^0.0.30",
"bluebird": "^3.5.0"
"bluebird": "^3.5.0",
"source-map-support": "^0.5.2"
},
"keywords": [
"LoopBack",
Expand Down
3 changes: 2 additions & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@
},
"devDependencies": {
"@loopback/build": "^4.0.0-alpha.9",
"@loopback/testlab": "^4.0.0-alpha.19"
"@loopback/testlab": "^4.0.0-alpha.19",
"source-map-support": "^0.5.2"
},
"files": [
"README.md",
Expand Down
1 change: 1 addition & 0 deletions packages/example-codehub/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
},
"devDependencies": {
"@loopback/testlab": "^4.0.0-alpha.19",
"source-map-support": "^0.5.2",
"ts-node": "^3.3.0"
}
}
1 change: 1 addition & 0 deletions packages/example-getting-started/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
"@types/mocha": "^2.2.46",
"@types/node": "^8.5.8",
"mocha": "^4.1.0",
"source-map-support": "^0.5.2",
"typescript": "^2.5.2"
},
"keywords": [
Expand Down
3 changes: 2 additions & 1 deletion packages/metadata/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@
"@loopback/build": "^4.0.0-alpha.9",
"@loopback/testlab": "^4.0.0-alpha.19",
"@types/debug": "^0.0.30",
"@types/lodash": "^4.14.87"
"@types/lodash": "^4.14.87",
"source-map-support": "^0.5.2"
},
"keywords": [
"LoopBack",
Expand Down
3 changes: 2 additions & 1 deletion packages/openapi-spec-builder/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@
"@loopback/openapi-spec": "^4.0.0-alpha.20"
},
"devDependencies": {
"@loopback/build": "^4.0.0-alpha.9"
"@loopback/build": "^4.0.0-alpha.9",
"source-map-support": "^0.5.2"
},
"files": [
"README.md",
Expand Down
6 changes: 4 additions & 2 deletions packages/openapi-spec/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
"node": ">=6"
},
"devDependencies": {
"@loopback/build": "^4.0.0-alpha.9"
"@loopback/build": "^4.0.0-alpha.9",
"source-map-support": "^0.5.2"
},
"scripts": {
"build": "npm run build:dist && npm run build:dist6",
Expand Down Expand Up @@ -39,5 +40,6 @@
"repository": {
"type": "git",
"url": "https://github.com/strongloop/loopback-next.git"
}
},
"dependencies": {}
}
3 changes: 2 additions & 1 deletion packages/openapi-v2/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
"devDependencies": {
"@loopback/build": "^4.0.0-alpha.9",
"@loopback/openapi-spec-builder": "^4.0.0-alpha.17",
"@loopback/testlab": "^4.0.0-alpha.19"
"@loopback/testlab": "^4.0.0-alpha.19",
"source-map-support": "^0.5.2"
},
"scripts": {
"build": "npm run build:dist && npm run build:dist6",
Expand Down
3 changes: 2 additions & 1 deletion packages/repository/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
"devDependencies": {
"@loopback/build": "^4.0.0-alpha.9",
"@loopback/core": "^4.0.0-alpha.28",
"@loopback/testlab": "^4.0.0-alpha.19"
"@loopback/testlab": "^4.0.0-alpha.19",
"source-map-support": "^0.5.2"
},
"dependencies": {
"@loopback/context": "^4.0.0-alpha.26",
Expand Down
3 changes: 2 additions & 1 deletion packages/rest/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@
"@loopback/openapi-spec-builder": "^4.0.0-alpha.17",
"@loopback/testlab": "^4.0.0-alpha.19",
"@types/js-yaml": "^3.9.1",
"@types/lodash": "^4.14.85"
"@types/lodash": "^4.14.85",
"source-map-support": "^0.5.2"
},
"files": [
"README.md",
Expand Down
3 changes: 2 additions & 1 deletion packages/testlab/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@
"swagger-parser": "^4.0.1"
},
"devDependencies": {
"@loopback/build": "^4.0.0-alpha.9"
"@loopback/build": "^4.0.0-alpha.9",
"source-map-support": "^0.5.2"
},
"files": [
"README.md",
Expand Down

0 comments on commit 3e171d6

Please sign in to comment.