@jsenv/test 1.2.2 → 1.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/jsenv_test.js
CHANGED
|
@@ -15,7 +15,7 @@ import { applyBabelPlugins } from "@jsenv/ast";
|
|
|
15
15
|
import { createId } from "@paralleldrive/cuid2";
|
|
16
16
|
import { runInNewContext } from "node:vm";
|
|
17
17
|
import wrapAnsi from "wrap-ansi";
|
|
18
|
-
import { injectSupervisorIntoHTML, supervisorFileUrl } from "@jsenv/plugin-supervisor
|
|
18
|
+
import { injectSupervisorIntoHTML, supervisorFileUrl } from "@jsenv/plugin-supervisor";
|
|
19
19
|
import { SOURCEMAP, generateSourcemapDataUrl } from "@jsenv/sourcemap";
|
|
20
20
|
import { fork } from "node:child_process";
|
|
21
21
|
import { findFreePort } from "@jsenv/server";
|
|
@@ -2959,10 +2959,10 @@ const babelPluginInstrument = (api, {
|
|
|
2959
2959
|
name: "transform-instrument",
|
|
2960
2960
|
visitor: {
|
|
2961
2961
|
Program: {
|
|
2962
|
-
enter(path) {
|
|
2962
|
+
enter(path, state) {
|
|
2963
2963
|
const {
|
|
2964
2964
|
file
|
|
2965
|
-
} =
|
|
2965
|
+
} = state;
|
|
2966
2966
|
const {
|
|
2967
2967
|
opts
|
|
2968
2968
|
} = file;
|
|
@@ -2973,19 +2973,23 @@ const babelPluginInstrument = (api, {
|
|
|
2973
2973
|
} else {
|
|
2974
2974
|
inputSourceMap = opts.inputSourceMap;
|
|
2975
2975
|
}
|
|
2976
|
-
|
|
2976
|
+
const __dv__ = programVisitor(types, opts.filenameRelative || opts.filename, {
|
|
2977
2977
|
coverageVariable: "__coverage__",
|
|
2978
2978
|
inputSourceMap
|
|
2979
2979
|
});
|
|
2980
|
-
|
|
2980
|
+
__dv__.enter(path);
|
|
2981
|
+
file.metadata.__dv__ = __dv__;
|
|
2981
2982
|
},
|
|
2982
|
-
exit(path) {
|
|
2983
|
-
|
|
2983
|
+
exit(path, state) {
|
|
2984
|
+
const {
|
|
2985
|
+
__dv__
|
|
2986
|
+
} = state.file.metadata;
|
|
2987
|
+
if (!__dv__) {
|
|
2984
2988
|
return;
|
|
2985
2989
|
}
|
|
2986
|
-
const object =
|
|
2990
|
+
const object = __dv__.exit(path);
|
|
2987
2991
|
// object got two properties: fileCoverage and sourceMappingURL
|
|
2988
|
-
|
|
2992
|
+
state.file.metadata.coverage = object.fileCoverage;
|
|
2989
2993
|
}
|
|
2990
2994
|
}
|
|
2991
2995
|
}
|
|
@@ -3008,10 +3012,9 @@ const relativeUrlToEmptyCoverage = async (relativeUrl, {
|
|
|
3008
3012
|
metadata
|
|
3009
3013
|
} = await applyBabelPlugins({
|
|
3010
3014
|
babelPlugins: [babelPluginInstrument],
|
|
3011
|
-
|
|
3012
|
-
|
|
3013
|
-
|
|
3014
|
-
}
|
|
3015
|
+
input: content,
|
|
3016
|
+
inputIsJsModule: false,
|
|
3017
|
+
inputUrl: fileUrl
|
|
3015
3018
|
});
|
|
3016
3019
|
const {
|
|
3017
3020
|
coverage
|
|
@@ -4597,14 +4600,12 @@ const initIstanbulMiddleware = async (page, {
|
|
|
4597
4600
|
try {
|
|
4598
4601
|
const result = await applyBabelPlugins({
|
|
4599
4602
|
babelPlugins: [babelPluginInstrument],
|
|
4600
|
-
|
|
4601
|
-
|
|
4602
|
-
|
|
4603
|
-
|
|
4604
|
-
|
|
4605
|
-
|
|
4606
|
-
content: originalBody
|
|
4607
|
-
}
|
|
4603
|
+
input: originalBody,
|
|
4604
|
+
// jsenv server could send info to know it's a js module or js classic
|
|
4605
|
+
// but in the end it's not super important
|
|
4606
|
+
// - it's ok to parse js classic as js module considering it's only for istanbul instrumentation
|
|
4607
|
+
inputIsJsModule: true,
|
|
4608
|
+
inputUrl: fileUrl
|
|
4608
4609
|
});
|
|
4609
4610
|
let code = result.code;
|
|
4610
4611
|
code = SOURCEMAP.writeComment({
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jsenv/test",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.4",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "https://github.com/jsenv/core",
|
|
8
|
-
"directory": "packages/
|
|
8
|
+
"directory": "packages/related/test"
|
|
9
9
|
},
|
|
10
10
|
"publishConfig": {
|
|
11
11
|
"access": "public"
|
|
@@ -34,10 +34,10 @@
|
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"@jsenv/abort": "4.2.4",
|
|
37
|
-
"@jsenv/ast": "4.0.
|
|
37
|
+
"@jsenv/ast": "4.0.3",
|
|
38
38
|
"@jsenv/filesystem": "4.2.3",
|
|
39
39
|
"@jsenv/log": "3.3.5",
|
|
40
|
-
"@jsenv/plugin-supervisor": "1.0
|
|
40
|
+
"@jsenv/plugin-supervisor": "1.1.0",
|
|
41
41
|
"@jsenv/urls": "2.0.0",
|
|
42
42
|
"@jsenv/url-meta": "8.1.0",
|
|
43
43
|
"@jsenv/uneval": "1.6.0",
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"istanbul-reports": "3.1.5",
|
|
50
50
|
"@paralleldrive/cuid2": "2.2.0",
|
|
51
51
|
"@c88/v8-coverage": "0.1.1",
|
|
52
|
-
"strip-ansi": "7.0
|
|
52
|
+
"strip-ansi": "7.1.0",
|
|
53
53
|
"wrap-ansi": "8.1.0",
|
|
54
54
|
"pidtree": "0.6.0"
|
|
55
55
|
}
|
|
@@ -10,8 +10,8 @@ export const babelPluginInstrument = (api, { useInlineSourceMaps = false }) => {
|
|
|
10
10
|
name: "transform-instrument",
|
|
11
11
|
visitor: {
|
|
12
12
|
Program: {
|
|
13
|
-
enter(path) {
|
|
14
|
-
const { file } =
|
|
13
|
+
enter(path, state) {
|
|
14
|
+
const { file } = state;
|
|
15
15
|
const { opts } = file;
|
|
16
16
|
let inputSourceMap;
|
|
17
17
|
if (useInlineSourceMaps) {
|
|
@@ -23,7 +23,7 @@ export const babelPluginInstrument = (api, { useInlineSourceMaps = false }) => {
|
|
|
23
23
|
} else {
|
|
24
24
|
inputSourceMap = opts.inputSourceMap;
|
|
25
25
|
}
|
|
26
|
-
|
|
26
|
+
const __dv__ = programVisitor(
|
|
27
27
|
types,
|
|
28
28
|
opts.filenameRelative || opts.filename,
|
|
29
29
|
{
|
|
@@ -31,16 +31,18 @@ export const babelPluginInstrument = (api, { useInlineSourceMaps = false }) => {
|
|
|
31
31
|
inputSourceMap,
|
|
32
32
|
},
|
|
33
33
|
);
|
|
34
|
-
|
|
34
|
+
__dv__.enter(path);
|
|
35
|
+
file.metadata.__dv__ = __dv__;
|
|
35
36
|
},
|
|
36
37
|
|
|
37
|
-
exit(path) {
|
|
38
|
-
|
|
38
|
+
exit(path, state) {
|
|
39
|
+
const { __dv__ } = state.file.metadata;
|
|
40
|
+
if (!__dv__) {
|
|
39
41
|
return;
|
|
40
42
|
}
|
|
41
|
-
const object =
|
|
43
|
+
const object = __dv__.exit(path);
|
|
42
44
|
// object got two properties: fileCoverage and sourceMappingURL
|
|
43
|
-
|
|
45
|
+
state.file.metadata.coverage = object.fileCoverage;
|
|
44
46
|
},
|
|
45
47
|
},
|
|
46
48
|
},
|
|
@@ -20,10 +20,9 @@ export const relativeUrlToEmptyCoverage = async (
|
|
|
20
20
|
operation.throwIfAborted();
|
|
21
21
|
const { metadata } = await applyBabelPlugins({
|
|
22
22
|
babelPlugins: [babelPluginInstrument],
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
},
|
|
23
|
+
input: content,
|
|
24
|
+
inputIsJsModule: false,
|
|
25
|
+
inputUrl: fileUrl,
|
|
27
26
|
});
|
|
28
27
|
const { coverage } = metadata;
|
|
29
28
|
if (!coverage) {
|
|
@@ -30,14 +30,12 @@ export const initIstanbulMiddleware = async (
|
|
|
30
30
|
try {
|
|
31
31
|
const result = await applyBabelPlugins({
|
|
32
32
|
babelPlugins: [babelPluginInstrument],
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
content: originalBody,
|
|
40
|
-
},
|
|
33
|
+
input: originalBody,
|
|
34
|
+
// jsenv server could send info to know it's a js module or js classic
|
|
35
|
+
// but in the end it's not super important
|
|
36
|
+
// - it's ok to parse js classic as js module considering it's only for istanbul instrumentation
|
|
37
|
+
inputIsJsModule: true,
|
|
38
|
+
inputUrl: fileUrl,
|
|
41
39
|
});
|
|
42
40
|
let code = result.code;
|
|
43
41
|
code = SOURCEMAP.writeComment({
|
|
@@ -3,7 +3,7 @@ import { urlToExtension } from "@jsenv/urls";
|
|
|
3
3
|
import {
|
|
4
4
|
injectSupervisorIntoHTML,
|
|
5
5
|
supervisorFileUrl,
|
|
6
|
-
} from "@jsenv/plugin-supervisor
|
|
6
|
+
} from "@jsenv/plugin-supervisor";
|
|
7
7
|
|
|
8
8
|
export const initJsSupervisorMiddleware = async (
|
|
9
9
|
page,
|