Skip to content

Commit e1042ca

Browse files
mantonifatso83
authored andcommitted
Hacky coverage
1 parent dd5abde commit e1042ca

File tree

3 files changed

+72
-2
lines changed

3 files changed

+72
-2
lines changed

coverage.cjs

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
"use strict";
2+
3+
const esbuild = require("esbuild");
4+
const { esbuildPluginIstanbul } = require("esbuild-plugin-istanbul");
5+
6+
(async function () {
7+
const { default: getStdin } = await import("get-stdin");
8+
const plugins = [
9+
esbuildPluginIstanbul({
10+
filter: /\.js$/,
11+
loader: "js",
12+
name: "istanbul-loader-js",
13+
}),
14+
];
15+
const stdin = {
16+
contents: await getStdin(),
17+
resolveDir: process.cwd(),
18+
sourcefile: "tests.js",
19+
loader: "js",
20+
};
21+
22+
const context = await esbuild.context({
23+
absWorkingDir: process.cwd(),
24+
entryPoints: [],
25+
write: false,
26+
bundle: true,
27+
sourcemap: "inline",
28+
sourcesContent: true,
29+
define: { global: "window", "process.env.NODE_DEBUG": '""' },
30+
external: ["fs"],
31+
target: "es2022",
32+
plugins,
33+
color: true,
34+
stdin,
35+
});
36+
37+
const { outputFiles } = await context.rebuild();
38+
const js = outputFiles[0].text;
39+
40+
context.dispose();
41+
42+
process.stdout.write(js);
43+
})();

package-lock.json

Lines changed: 25 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
"test-node": "mocha --recursive -R dot \"test/**/*-test.js\"",
3535
"test-dev": "npm run test-node -- -n watch -n watch-path=test --node-option watch-path=lib -R min",
3636
"test-headless": "mochify --driver puppeteer",
37-
"test-coverage": "nyc npm run test-headless -- --transform [ babelify --ignore [ test ] --plugins [ babel-plugin-istanbul ] ]",
37+
"test-coverage": "nyc nyc --exclude-after-remap false mochify --driver puppeteer --bundle 'node coverage.cjs'",
3838
"test-cloud": "npm run test-headless -- --wd",
3939
"test-webworker": "mochify --driver puppeteer --serve . test/webworker/webworker-support-assessment.js",
4040
"test-esm-support": "mocha test/es2015/module-support-assessment-test.mjs",
@@ -94,16 +94,18 @@
9494
"@mochify/driver-puppeteer": "^0.4.0",
9595
"@mochify/driver-webdriver": "^0.2.1",
9696
"@sinonjs/eslint-config": "^5.0.3",
97-
"@sinonjs/referee-sinon": "12.0.0",
9897
"@sinonjs/eslint-plugin-no-prototype-methods": "^0.1.1",
9998
"@sinonjs/referee": "^11.0.1",
99+
"@sinonjs/referee-sinon": "12.0.0",
100100
"@studio/changes": "^3.0.0",
101101
"babel-plugin-istanbul": "^6.1.1",
102102
"babelify": "^10.0.0",
103103
"browserify": "^16.5.2",
104104
"debug": "^4.3.4",
105105
"dependency-check": "^4.1.0",
106106
"esbuild": "^0.23.1",
107+
"esbuild-plugin-istanbul": "^0.3.0",
108+
"get-stdin": "^9.0.0",
107109
"lint-staged": "^15.2.2",
108110
"mocha": "^10.4.0",
109111
"nyc": "^15.1.0",

0 commit comments

Comments
 (0)