@jsenv/test 1.1.2 → 1.1.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 +4 -2
- package/package.json +3 -3
- package/src/coverage/babel_plugin_instrument.js +15 -15
- package/src/coverage/coverage_reporter_html_directory.js +10 -10
- package/src/coverage/coverage_reporter_json_file.js +7 -7
- package/src/coverage/coverage_reporter_text_log.js +8 -8
- package/src/coverage/empty_coverage_factory.js +24 -24
- package/src/coverage/file_by_file_coverage.js +10 -10
- package/src/coverage/istanbul_coverage_composition.js +16 -16
- package/src/coverage/istanbul_coverage_map_from_coverage.js +8 -8
- package/src/coverage/list_files_not_covered.js +4 -4
- package/src/coverage/missing_coverage.js +17 -17
- package/src/coverage/report_to_coverage.js +52 -52
- package/src/coverage/v8_and_istanbul.js +17 -16
- package/src/coverage/v8_coverage.js +8 -8
- package/src/coverage/v8_coverage_composition.js +12 -12
- package/src/coverage/v8_coverage_node_directory.js +42 -42
- package/src/coverage/v8_coverage_to_istanbul.js +45 -45
- package/src/execution/execute.js +21 -21
- package/src/execution/execute_steps.js +129 -129
- package/src/execution/execute_test_plan.js +72 -68
- package/src/execution/execution_colors.js +2 -2
- package/src/execution/execution_steps.js +20 -20
- package/src/execution/gc.js +5 -5
- package/src/execution/logs_file_execution.js +126 -126
- package/src/execution/logs_file_execution.test.mjs +11 -11
- package/src/execution/run.js +51 -51
- package/src/execution/web_server_param.js +24 -24
- package/src/main.js +7 -7
- package/src/runtime_browsers/chromium.js +7 -7
- package/src/runtime_browsers/firefox.js +10 -10
- package/src/runtime_browsers/middleware_istanbul.js +23 -23
- package/src/runtime_browsers/middleware_js_supervisor.js +32 -32
- package/src/runtime_browsers/using_playwright.js +186 -186
- package/src/runtime_browsers/webkit.js +11 -11
- package/src/runtime_node/child_exec_options.js +43 -43
- package/src/runtime_node/controllable_child_process.mjs +47 -47
- package/src/runtime_node/controllable_worker_thread.mjs +37 -37
- package/src/runtime_node/exec_options.js +26 -26
- package/src/runtime_node/execute_using_dynamic_import.js +26 -26
- package/src/runtime_node/exit_codes.js +4 -4
- package/src/runtime_node/importmap_node_loader.mjs +24 -24
- package/src/runtime_node/importmap_node_loader_file_url.js +1 -1
- package/src/runtime_node/kill_process_tree.js +30 -30
- package/src/runtime_node/no_experimental_warnings.cjs +4 -4
- package/src/runtime_node/no_experimental_warnings_file_url.js +1 -1
- package/src/runtime_node/node_child_process.js +128 -128
- package/src/runtime_node/node_execution_performance.js +28 -28
- package/src/runtime_node/node_worker_thread.js +108 -108
- package/src/runtime_node/profiler_v8_coverage.js +21 -21
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { writeFileSync } from "node:fs"
|
|
1
|
+
import { writeFileSync } from "node:fs";
|
|
2
2
|
|
|
3
|
-
import { startJsCoverage } from "./profiler_v8_coverage.js"
|
|
4
|
-
import { startObservingPerformances } from "./node_execution_performance.js"
|
|
3
|
+
import { startJsCoverage } from "./profiler_v8_coverage.js";
|
|
4
|
+
import { startObservingPerformances } from "./node_execution_performance.js";
|
|
5
5
|
|
|
6
6
|
export const executeUsingDynamicImport = async ({
|
|
7
7
|
rootDirectoryUrl,
|
|
@@ -12,42 +12,42 @@ export const executeUsingDynamicImport = async ({
|
|
|
12
12
|
coverageMethodForNodeJs,
|
|
13
13
|
coverageFileUrl,
|
|
14
14
|
}) => {
|
|
15
|
-
const result = {}
|
|
16
|
-
const afterImportCallbacks = []
|
|
15
|
+
const result = {};
|
|
16
|
+
const afterImportCallbacks = [];
|
|
17
17
|
if (coverageEnabled && coverageMethodForNodeJs === "Profiler") {
|
|
18
|
-
const { filterV8Coverage } = await import("../coverage/v8_coverage.js")
|
|
19
|
-
const { stopJsCoverage } = await startJsCoverage()
|
|
18
|
+
const { filterV8Coverage } = await import("../coverage/v8_coverage.js");
|
|
19
|
+
const { stopJsCoverage } = await startJsCoverage();
|
|
20
20
|
afterImportCallbacks.push(async () => {
|
|
21
|
-
const coverage = await stopJsCoverage()
|
|
21
|
+
const coverage = await stopJsCoverage();
|
|
22
22
|
const coverageLight = await filterV8Coverage(coverage, {
|
|
23
23
|
rootDirectoryUrl,
|
|
24
24
|
coverageConfig,
|
|
25
|
-
})
|
|
25
|
+
});
|
|
26
26
|
writeFileSync(
|
|
27
27
|
new URL(coverageFileUrl),
|
|
28
28
|
JSON.stringify(coverageLight, null, " "),
|
|
29
|
-
)
|
|
30
|
-
})
|
|
29
|
+
);
|
|
30
|
+
});
|
|
31
31
|
}
|
|
32
32
|
if (collectPerformance) {
|
|
33
|
-
const getPerformance = startObservingPerformances()
|
|
33
|
+
const getPerformance = startObservingPerformances();
|
|
34
34
|
afterImportCallbacks.push(async () => {
|
|
35
|
-
const performance = await getPerformance()
|
|
36
|
-
result.performance = performance
|
|
37
|
-
})
|
|
35
|
+
const performance = await getPerformance();
|
|
36
|
+
result.performance = performance;
|
|
37
|
+
});
|
|
38
38
|
}
|
|
39
|
-
const namespace = await import(fileUrl)
|
|
40
|
-
const namespaceResolved = {}
|
|
39
|
+
const namespace = await import(fileUrl);
|
|
40
|
+
const namespaceResolved = {};
|
|
41
41
|
await Promise.all(
|
|
42
42
|
Object.keys(namespace).map(async (key) => {
|
|
43
|
-
const value = await namespace[key]
|
|
44
|
-
namespaceResolved[key] = value
|
|
43
|
+
const value = await namespace[key];
|
|
44
|
+
namespaceResolved[key] = value;
|
|
45
45
|
}),
|
|
46
|
-
)
|
|
47
|
-
result.namespace = namespaceResolved
|
|
46
|
+
);
|
|
47
|
+
result.namespace = namespaceResolved;
|
|
48
48
|
await afterImportCallbacks.reduce(async (previous, afterImportCallback) => {
|
|
49
|
-
await previous
|
|
50
|
-
await afterImportCallback()
|
|
51
|
-
}, Promise.resolve())
|
|
52
|
-
return result
|
|
53
|
-
}
|
|
49
|
+
await previous;
|
|
50
|
+
await afterImportCallback();
|
|
51
|
+
}, Promise.resolve());
|
|
52
|
+
return result;
|
|
53
|
+
};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
// https://nodejs.org/api/process.html#process_signal_events
|
|
2
|
-
const SIGINT_SIGNAL_NUMBER = 2
|
|
3
|
-
const SIGABORT_SIGNAL_NUMBER = 6
|
|
4
|
-
const SIGTERM_SIGNAL_NUMBER = 15
|
|
2
|
+
const SIGINT_SIGNAL_NUMBER = 2;
|
|
3
|
+
const SIGABORT_SIGNAL_NUMBER = 6;
|
|
4
|
+
const SIGTERM_SIGNAL_NUMBER = 15;
|
|
5
5
|
export const EXIT_CODES = {
|
|
6
6
|
SIGINT: 128 + SIGINT_SIGNAL_NUMBER,
|
|
7
7
|
SIGABORT: 128 + SIGABORT_SIGNAL_NUMBER,
|
|
8
8
|
SIGTERM: 128 + SIGTERM_SIGNAL_NUMBER,
|
|
9
|
-
}
|
|
9
|
+
};
|
|
@@ -1,51 +1,51 @@
|
|
|
1
|
-
import { readFileSync } from "node:fs"
|
|
2
|
-
import { pathToFileURL } from "node:url"
|
|
3
|
-
import { normalizeImportMap, resolveImport } from "@jsenv/importmap"
|
|
1
|
+
import { readFileSync } from "node:fs";
|
|
2
|
+
import { pathToFileURL } from "node:url";
|
|
3
|
+
import { normalizeImportMap, resolveImport } from "@jsenv/importmap";
|
|
4
4
|
|
|
5
|
-
let importMap
|
|
5
|
+
let importMap;
|
|
6
6
|
|
|
7
|
-
const cwdUrl = `${String(pathToFileURL(process.cwd()))}
|
|
7
|
+
const cwdUrl = `${String(pathToFileURL(process.cwd()))}/`;
|
|
8
8
|
|
|
9
9
|
if (process.env.IMPORT_MAP) {
|
|
10
|
-
importMap = JSON.parse(process.env.IMPORT_MAP)
|
|
10
|
+
importMap = JSON.parse(process.env.IMPORT_MAP);
|
|
11
11
|
} else if (process.env.IMPORT_MAP_PATH) {
|
|
12
|
-
const importmapFileUrl = pathToFileURL(process.env.IMPORT_MAP_PATH)
|
|
13
|
-
const importmapFileContentAsString = readFileSync(importmapFileUrl, "utf8")
|
|
14
|
-
importMap = JSON.parse(importmapFileContentAsString)
|
|
12
|
+
const importmapFileUrl = pathToFileURL(process.env.IMPORT_MAP_PATH);
|
|
13
|
+
const importmapFileContentAsString = readFileSync(importmapFileUrl, "utf8");
|
|
14
|
+
importMap = JSON.parse(importmapFileContentAsString);
|
|
15
15
|
} else {
|
|
16
|
-
const importmapFileUrl = new URL("./import_map.json", cwdUrl)
|
|
17
|
-
const importmapFileContentAsString = readFileSync(importmapFileUrl, "utf8")
|
|
18
|
-
importMap = JSON.parse(importmapFileContentAsString)
|
|
16
|
+
const importmapFileUrl = new URL("./import_map.json", cwdUrl);
|
|
17
|
+
const importmapFileContentAsString = readFileSync(importmapFileUrl, "utf8");
|
|
18
|
+
importMap = JSON.parse(importmapFileContentAsString);
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
const importMapBaseUrl = process.env.IMPORT_MAP_BASE_URL || cwdUrl
|
|
22
|
-
importMap = normalizeImportMap(importMap, importMapBaseUrl)
|
|
21
|
+
const importMapBaseUrl = process.env.IMPORT_MAP_BASE_URL || cwdUrl;
|
|
22
|
+
importMap = normalizeImportMap(importMap, importMapBaseUrl);
|
|
23
23
|
|
|
24
24
|
export const resolve = (specifier, context, nextResolve) => {
|
|
25
25
|
try {
|
|
26
|
-
let mapped
|
|
27
|
-
const importer = context.parentURL ? String(context.parentURL) : undefined
|
|
26
|
+
let mapped;
|
|
27
|
+
const importer = context.parentURL ? String(context.parentURL) : undefined;
|
|
28
28
|
const resolved = resolveImport({
|
|
29
29
|
specifier,
|
|
30
30
|
importer,
|
|
31
31
|
importMap,
|
|
32
32
|
defaultExtension: ".js",
|
|
33
33
|
onImportMapping: () => {
|
|
34
|
-
mapped = true
|
|
34
|
+
mapped = true;
|
|
35
35
|
},
|
|
36
|
-
})
|
|
36
|
+
});
|
|
37
37
|
if (mapped) {
|
|
38
38
|
return {
|
|
39
39
|
shortCircuit: true,
|
|
40
40
|
url: resolved,
|
|
41
|
-
}
|
|
41
|
+
};
|
|
42
42
|
}
|
|
43
43
|
} catch (e) {
|
|
44
44
|
if (e.message.includes("bare specifier")) {
|
|
45
|
-
return nextResolve(specifier, context)
|
|
45
|
+
return nextResolve(specifier, context);
|
|
46
46
|
}
|
|
47
|
-
console.error(e)
|
|
48
|
-
return nextResolve(specifier, context)
|
|
47
|
+
console.error(e);
|
|
48
|
+
return nextResolve(specifier, context);
|
|
49
49
|
}
|
|
50
|
-
return nextResolve(specifier, context)
|
|
51
|
-
}
|
|
50
|
+
return nextResolve(specifier, context);
|
|
51
|
+
};
|
|
@@ -1,57 +1,57 @@
|
|
|
1
|
-
import { requireFromJsenv } from "@jsenv/core/src/helpers/require_from_jsenv.js"
|
|
1
|
+
import { requireFromJsenv } from "@jsenv/core/src/helpers/require_from_jsenv.js";
|
|
2
2
|
|
|
3
3
|
// see also https://github.com/sindresorhus/execa/issues/96
|
|
4
4
|
export const killProcessTree = async (
|
|
5
5
|
processId,
|
|
6
6
|
{ signal, timeout = 2000 },
|
|
7
7
|
) => {
|
|
8
|
-
const pidtree = requireFromJsenv("pidtree")
|
|
8
|
+
const pidtree = requireFromJsenv("pidtree");
|
|
9
9
|
|
|
10
|
-
let descendantProcessIds
|
|
10
|
+
let descendantProcessIds;
|
|
11
11
|
try {
|
|
12
|
-
descendantProcessIds = await pidtree(processId)
|
|
12
|
+
descendantProcessIds = await pidtree(processId);
|
|
13
13
|
} catch (e) {
|
|
14
14
|
if (e.message === "No matching pid found") {
|
|
15
|
-
descendantProcessIds = []
|
|
15
|
+
descendantProcessIds = [];
|
|
16
16
|
} else {
|
|
17
|
-
throw e
|
|
17
|
+
throw e;
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
20
|
descendantProcessIds.forEach((descendantProcessId) => {
|
|
21
21
|
try {
|
|
22
|
-
process.kill(descendantProcessId, signal)
|
|
22
|
+
process.kill(descendantProcessId, signal);
|
|
23
23
|
} catch (error) {
|
|
24
24
|
// ignore
|
|
25
25
|
}
|
|
26
|
-
})
|
|
26
|
+
});
|
|
27
27
|
|
|
28
28
|
try {
|
|
29
|
-
process.kill(processId, signal)
|
|
29
|
+
process.kill(processId, signal);
|
|
30
30
|
} catch (e) {
|
|
31
31
|
if (e.code !== "ESRCH") {
|
|
32
|
-
throw e
|
|
32
|
+
throw e;
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
-
let remainingIds = [...descendantProcessIds, processId]
|
|
36
|
+
let remainingIds = [...descendantProcessIds, processId];
|
|
37
37
|
|
|
38
38
|
const updateRemainingIds = () => {
|
|
39
39
|
remainingIds = remainingIds.filter((remainingId) => {
|
|
40
40
|
try {
|
|
41
|
-
process.kill(remainingId, 0)
|
|
42
|
-
return true
|
|
41
|
+
process.kill(remainingId, 0);
|
|
42
|
+
return true;
|
|
43
43
|
} catch (e) {
|
|
44
|
-
return false
|
|
44
|
+
return false;
|
|
45
45
|
}
|
|
46
|
-
})
|
|
47
|
-
}
|
|
46
|
+
});
|
|
47
|
+
};
|
|
48
48
|
|
|
49
|
-
let timeSpentWaiting = 0
|
|
49
|
+
let timeSpentWaiting = 0;
|
|
50
50
|
|
|
51
51
|
const check = async () => {
|
|
52
|
-
updateRemainingIds()
|
|
52
|
+
updateRemainingIds();
|
|
53
53
|
if (remainingIds.length === 0) {
|
|
54
|
-
return
|
|
54
|
+
return;
|
|
55
55
|
}
|
|
56
56
|
|
|
57
57
|
if (timeSpentWaiting > timeout) {
|
|
@@ -59,18 +59,18 @@ export const killProcessTree = async (
|
|
|
59
59
|
`timed out waiting for ${
|
|
60
60
|
remainingIds.length
|
|
61
61
|
} process to exit (${remainingIds.join(" ")})`,
|
|
62
|
-
)
|
|
63
|
-
timeoutError.code = "TIMEOUT"
|
|
64
|
-
throw timeoutError
|
|
62
|
+
);
|
|
63
|
+
timeoutError.code = "TIMEOUT";
|
|
64
|
+
throw timeoutError;
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
-
await new Promise((resolve) => setTimeout(resolve, 400))
|
|
68
|
-
timeSpentWaiting += 400
|
|
69
|
-
await check()
|
|
70
|
-
}
|
|
67
|
+
await new Promise((resolve) => setTimeout(resolve, 400));
|
|
68
|
+
timeSpentWaiting += 400;
|
|
69
|
+
await check();
|
|
70
|
+
};
|
|
71
71
|
|
|
72
72
|
await new Promise((resolve) => {
|
|
73
|
-
setTimeout(resolve, 0)
|
|
74
|
-
})
|
|
75
|
-
await check()
|
|
76
|
-
}
|
|
73
|
+
setTimeout(resolve, 0);
|
|
74
|
+
});
|
|
75
|
+
await check();
|
|
76
|
+
};
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
// see https://github.com/nodejs/node/issues/47478
|
|
2
|
-
const originalEmit = process.emit
|
|
2
|
+
const originalEmit = process.emit;
|
|
3
3
|
process.emit = (event, error) => {
|
|
4
4
|
if (event === "warning" && error.name === "ExperimentalWarning") {
|
|
5
5
|
if (
|
|
6
6
|
error.message.includes("--experimental-loader") ||
|
|
7
7
|
error.message.includes("Custom ESM Loaders is an experimental")
|
|
8
8
|
) {
|
|
9
|
-
return false
|
|
9
|
+
return false;
|
|
10
10
|
}
|
|
11
11
|
}
|
|
12
|
-
return originalEmit.call(process, event, error)
|
|
13
|
-
}
|
|
12
|
+
return originalEmit.call(process, event, error);
|
|
13
|
+
};
|