mirror of
https://github.com/a-nyx/maputnik-with-pmtiles.git
synced 2024-12-28 15:21:20 +01:00
e34c1ca4be
It required converting mocha tests code into async since [@wdio/sync is deprecated](https://webdriver.io/docs/sync-vs-async/) starting with node v16. It removed the dependency on fibers and on [node-gyp + python](https:// webdriver.io/docs/sync-vs-async/#common-issues-in-sync-mode) indirectly though which is a great thing. Also moved away from node-sass to sass since [node-sass is deprecated] (https://sass-lang.com/blog/libsass-is-deprecated).
56 lines
1.7 KiB
JavaScript
56 lines
1.7 KiB
JavaScript
var artifacts = require("../../artifacts");
|
|
var fs = require("fs");
|
|
var istanbulCov = require('istanbul-lib-coverage');
|
|
|
|
var COVERAGE_PATH = artifacts.pathSync("/coverage");
|
|
|
|
|
|
var coverage = istanbulCov.createCoverageMap({});
|
|
|
|
// Capture the coverage after each test
|
|
afterEach(async function() {
|
|
// Code coverage
|
|
var results = await browser.execute(function() {
|
|
return window.__coverage__;
|
|
});
|
|
|
|
if (results) {
|
|
coverage.merge(results);
|
|
}
|
|
})
|
|
|
|
// Dump the coverage to a file
|
|
after(function() {
|
|
|
|
// Sometimes istanbul copies same location entry with null values
|
|
// crashing the final coverage step. This is just a workaround for now,
|
|
// since istanbul will be replaced by nyc.
|
|
const coverageJson = JSON.stringify(coverage, null, 2);
|
|
let newCoverage = JSON.parse(coverageJson);
|
|
|
|
Object.values(newCoverage).forEach(fileCov => {
|
|
if (fileCov.branchMap) {
|
|
Object.values(fileCov.branchMap).forEach(branchMapEntry => {
|
|
let prevLocation = {};
|
|
branchMapEntry.locations.forEach(curLocation => {
|
|
if (curLocation.start && curLocation.end &&
|
|
curLocation.start.column && curLocation.start.line &&
|
|
curLocation.end.column && curLocation.end.line)
|
|
{
|
|
prevLocation = curLocation;
|
|
}
|
|
else
|
|
{
|
|
curLocation.start.column = prevLocation.start.column;
|
|
curLocation.start.line = prevLocation.start.line;
|
|
curLocation.end.column = prevLocation.end.column;
|
|
curLocation.end.line = prevLocation.end.line;
|
|
}
|
|
})
|
|
})
|
|
}
|
|
})
|
|
|
|
const newCoverageJson = JSON.stringify(newCoverage, null, 2);
|
|
fs.writeFileSync(COVERAGE_PATH+"/coverage.json", newCoverageJson);
|
|
})
|