-
-
Notifications
You must be signed in to change notification settings - Fork 39
/
run-fixture.js
31 lines (25 loc) · 962 Bytes
/
run-fixture.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
/* global describe, it */
const toIstanbul = require('../../')
const t = require('tap')
const semver = require('semver')
t.mochaGlobals()
require('should')
module.exports = async (fixture) => {
const script = toIstanbul(fixture.coverageV8.url)
await script.load()
if (fixture.maxNodeVersion && !semver.lt(process.version, fixture.maxNodeVersion)) {
console.info(`skipping "${fixture.describe}" fixture maxNodeVersion = ${fixture.maxNodeVersion}`)
return
}
script.applyCoverage(fixture.coverageV8.functions)
let coverageIstanbul = script.toIstanbul()
// the top level object is keyed on filename, grab the inner
// object which is easier to assert against.
coverageIstanbul = coverageIstanbul[Object.keys(coverageIstanbul)[0]]
describe(fixture.describe, () => {
it('matches snapshot', () => {
delete coverageIstanbul.path
t.matchSnapshot(coverageIstanbul, `must match ${fixture.describe} snapshot`)
})
})
}