Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
fix: make --all work for transpiled code (#1047)
* cache source maps globally
- Loading branch information
1 parent
b7e16cd
commit 18e04ba
Showing
2 changed files
with
31 additions
and
12 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/* global describe, it */ | ||
|
||
require('chai').should() | ||
require('tap').mochaGlobals() | ||
|
||
const { readFileSync } = require('fs') | ||
const SourceMaps = require('../self-coverage/lib/source-maps') | ||
|
||
describe('source-maps', function () { | ||
it('caches source maps globally', function () { | ||
const sm = new SourceMaps({}) | ||
// load a source map into cache. | ||
const sourceFile = require.resolve('./fixtures/source-maps/instrumented/s1.min.js') | ||
sm.extractAndRegister(readFileSync(sourceFile, 'utf8'), sourceFile, 'abc123') | ||
// create a new SourceMaps instance. | ||
const sm2 = new SourceMaps({}) | ||
// the two instances of SourceMaps should share a cache. | ||
sm._sourceMapCache.should.deep.equal(sm2._sourceMapCache) | ||
}) | ||
}) |