Skip to content

Commit

Permalink
Sourcemaps (#3458)
Browse files Browse the repository at this point in the history
* Allow transformers to specify source maps even if not using coverage

* Test the new source map behavior

Under the new transformer rules, if the transformer provides us a
sourcemap, we'll take it, regardless of the coverage settings. This
means source maps are cached alongside the originals, and `Runtime`
will populate its `_sourceMapRegistry`

* Install source-map-support into jasmine runtime

* Add tests for sourcemap support

* update source map cache test to use writeFileAtomic

* move up source-map-support to top-level dependency

It was already included as a transitive dependency:
babel-core -> babel-register -> source-map-support

* Update snapshot

* Fix lint errors

* move source-map-support into jest-jasmine2 package.json

* remove hash from coverage_remapping integration test snapshot

See #3458 (comment)
  • Loading branch information
felipeochoa authored and cpojer committed Oct 9, 2017
1 parent c8b68bb commit 87d12e6
Show file tree
Hide file tree
Showing 11 changed files with 198 additions and 60 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
exports[`maps code coverage against original source 1`] = `
Object {
"covered.ts": Object {
"_coverageSchema": "332fd63041d2c1bcb487cc26dd0d5f7d97098a6c",
"b": Object {
"0": Array [
1,
Expand All @@ -24,149 +25,153 @@ Object {
},
"branchMap": Object {
"0": Object {
"line": 4,
"loc": Object {
"end": Object {
"column": 9,
"line": 5,
"column": 11,
"line": 6,
},
"start": Object {
"column": 8,
"line": 5,
"column": 18,
"line": 4,
},
},
"locations": Array [
Object {
"end": Object {
"column": 9,
"column": 11,
"line": 5,
},
"start": Object {
"column": 8,
"column": 10,
"line": 5,
},
},
Object {
"end": Object {
"column": 9,
"column": 11,
"line": 6,
},
"start": Object {
"column": 8,
"column": 10,
"line": 6,
},
},
],
"type": "cond-expr",
},
"1": Object {
"line": 7,
"loc": Object {
"end": Object {
"column": 37,
"column": 30,
"line": 7,
},
"start": Object {
"column": 36,
"column": 18,
"line": 7,
},
},
"locations": Array [
Object {
"end": Object {
"column": 37,
"column": 26,
"line": 7,
},
"start": Object {
"column": 36,
"column": 25,
"line": 7,
},
},
Object {
"end": Object {
"column": 41,
"column": 30,
"line": 7,
},
"start": Object {
"column": 40,
"column": 29,
"line": 7,
},
},
],
"type": "cond-expr",
},
"2": Object {
"line": 8,
"loc": Object {
"end": Object {
"column": 33,
"column": 39,
"line": 8,
},
"start": Object {
"column": 29,
"column": 18,
"line": 8,
},
},
"locations": Array [
Object {
"end": Object {
"column": 33,
"column": 22,
"line": 8,
},
"start": Object {
"column": 29,
"column": 18,
"line": 8,
},
},
Object {
"end": Object {
"column": 41,
"column": 30,
"line": 8,
},
"start": Object {
"column": 37,
"column": 26,
"line": 8,
},
},
Object {
"end": Object {
"column": 50,
"column": 39,
"line": 8,
},
"start": Object {
"column": 45,
"column": 34,
"line": 8,
},
},
],
"type": "binary-expr",
},
"3": Object {
"line": 9,
"loc": Object {
"end": Object {
"column": 42,
"column": 79,
"line": 9,
},
"start": Object {
"column": 32,
"column": 13,
"line": 9,
},
},
"locations": Array [
Object {
"end": Object {
"column": 42,
"column": 48,
"line": 9,
},
"start": Object {
"column": 32,
"column": 20,
"line": 9,
},
},
Object {
"end": Object {
"column": 55,
"column": 79,
"line": 9,
},
"start": Object {
"column": 45,
"column": 51,
"line": 9,
},
},
Expand All @@ -183,21 +188,22 @@ Object {
"0": Object {
"decl": Object {
"end": Object {
"column": 28,
"column": 36,
"line": 3,
},
"start": Object {
"column": 9,
"column": 26,
"line": 3,
},
},
"line": 3,
"loc": Object {
"end": Object {
"column": 1,
"line": 12,
"line": 11,
},
"start": Object {
"column": 49,
"column": 43,
"line": 3,
},
},
Expand All @@ -206,17 +212,18 @@ Object {
"1": Object {
"decl": Object {
"end": Object {
"column": 37,
"column": 21,
"line": 9,
},
"start": Object {
"column": 32,
"column": 20,
"line": 9,
},
},
"line": 9,
"loc": Object {
"end": Object {
"column": 42,
"column": 48,
"line": 9,
},
"start": Object {
Expand All @@ -229,21 +236,22 @@ Object {
"2": Object {
"decl": Object {
"end": Object {
"column": 50,
"column": 52,
"line": 9,
},
"start": Object {
"column": 45,
"column": 51,
"line": 9,
},
},
"line": 9,
"loc": Object {
"end": Object {
"column": 55,
"column": 79,
"line": 9,
},
"start": Object {
"column": 45,
"column": 63,
"line": 9,
},
},
Expand All @@ -264,8 +272,8 @@ Object {
"statementMap": Object {
"0": Object {
"end": Object {
"column": 1,
"line": 12,
"column": 2,
"line": 11,
},
"start": Object {
"column": 0,
Expand All @@ -274,72 +282,72 @@ Object {
},
"1": Object {
"end": Object {
"column": 9,
"column": 11,
"line": 6,
},
"start": Object {
"column": 29,
"column": 18,
"line": 4,
},
},
"2": Object {
"end": Object {
"column": 41,
"column": 30,
"line": 7,
},
"start": Object {
"column": 29,
"column": 18,
"line": 7,
},
},
"3": Object {
"end": Object {
"column": 50,
"column": 39,
"line": 8,
},
"start": Object {
"column": 29,
"column": 18,
"line": 8,
},
},
"4": Object {
"end": Object {
"column": 55,
"column": 79,
"line": 9,
},
"start": Object {
"column": 25,
"column": 13,
"line": 9,
},
},
"5": Object {
"end": Object {
"column": 42,
"column": 46,
"line": 9,
},
"start": Object {
"column": 38,
"column": 34,
"line": 9,
},
},
"6": Object {
"end": Object {
"column": 55,
"column": 77,
"line": 9,
},
"start": Object {
"column": 51,
"column": 65,
"line": 9,
},
},
"7": Object {
"end": Object {
"column": 17,
"line": 11,
"line": 10,
},
"start": Object {
"column": 4,
"line": 11,
"line": 10,
},
},
},
Expand Down
1 change: 1 addition & 0 deletions integration_tests/__tests__/coverage_remapping.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ it('maps code coverage against original source', () => {
// reduce absolute paths embedded in the coverage map to just filenames
Object.keys(coverageMap).forEach(filename => {
coverageMap[filename].path = path.basename(coverageMap[filename].path);
delete coverageMap[filename].hash;
coverageMap[path.basename(filename)] = coverageMap[filename];
delete coverageMap[filename];
});
Expand Down
3 changes: 2 additions & 1 deletion packages/jest-jasmine2/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
"jest-matcher-utils": "^21.2.1",
"jest-message-util": "^21.2.1",
"jest-snapshot": "^21.2.1",
"p-cancelable": "^0.3.0"
"p-cancelable": "^0.3.0",
"source-map-support": "^0.5.0"
},
"devDependencies": {
"jest-runtime": "^21.2.1"
Expand Down
Loading

0 comments on commit 87d12e6

Please sign in to comment.