@jsenv/test 3.0.4 → 3.0.6
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 +2417 -2411
- package/package.json +3 -4
- package/src/coverage/report_coverage_as_json.js +2 -2
- package/src/coverage/v8_and_istanbul.js +1 -1
- package/src/coverage/v8_coverage_node_directory.js +1 -1
- package/src/execution/execute.js +1 -1
- package/src/execution/execute_test_plan.js +1 -1
- package/src/execution/format_error_for_terminal.js +2 -3
- package/src/execution/reporters/reporter_list.js +13 -8
- package/src/execution/run.js +9 -3
- package/src/runtime_browsers/using_playwright.js +1 -1
- package/src/runtime_node/child_exec_options.js +1 -1
- package/src/runtime_node/node_child_process.js +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jsenv/test",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.6",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -40,9 +40,8 @@
|
|
|
40
40
|
"@jsenv/abort": "4.3.0",
|
|
41
41
|
"@jsenv/ast": "6.0.2",
|
|
42
42
|
"@jsenv/filesystem": "4.6.3",
|
|
43
|
-
"@jsenv/github-check-run": "0.1.
|
|
44
|
-
"@jsenv/
|
|
45
|
-
"@jsenv/log": "3.5.2",
|
|
43
|
+
"@jsenv/github-check-run": "0.1.9",
|
|
44
|
+
"@jsenv/humanize": "1.0.0",
|
|
46
45
|
"@jsenv/plugin-supervisor": "1.4.2",
|
|
47
46
|
"@jsenv/url-meta": "8.4.0",
|
|
48
47
|
"@jsenv/urls": "2.2.2",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { urlToFileSystemPath } from "@jsenv/urls";
|
|
2
2
|
import { writeFileSync } from "@jsenv/filesystem";
|
|
3
|
-
import {
|
|
3
|
+
import { humanizeFileSize } from "@jsenv/humanize";
|
|
4
4
|
|
|
5
5
|
export const reportCoverageAsJson = (
|
|
6
6
|
testPlanResult,
|
|
@@ -18,7 +18,7 @@ export const reportCoverageAsJson = (
|
|
|
18
18
|
writeFileSync(fileUrl, coverageAsText);
|
|
19
19
|
if (logs) {
|
|
20
20
|
console.log(
|
|
21
|
-
`-> ${urlToFileSystemPath(fileUrl)} (${
|
|
21
|
+
`-> ${urlToFileSystemPath(fileUrl)} (${humanizeFileSize(
|
|
22
22
|
Buffer.byteLength(coverageAsText),
|
|
23
23
|
)})`,
|
|
24
24
|
);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { readFileSync, readdirSync } from "node:fs";
|
|
2
2
|
import { assertAndNormalizeDirectoryUrl } from "@jsenv/filesystem";
|
|
3
|
-
import { createDetailedMessage } from "@jsenv/
|
|
3
|
+
import { createDetailedMessage } from "@jsenv/humanize";
|
|
4
4
|
import { Abort } from "@jsenv/abort";
|
|
5
5
|
|
|
6
6
|
export const readNodeV8CoverageDirectory = async ({
|
package/src/execution/execute.js
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
|
|
13
13
|
import { Abort, raceProcessTeardownEvents } from "@jsenv/abort";
|
|
14
14
|
import { assertAndNormalizeDirectoryUrl } from "@jsenv/filesystem";
|
|
15
|
-
import { createLogger } from "@jsenv/
|
|
15
|
+
import { createLogger } from "@jsenv/humanize";
|
|
16
16
|
|
|
17
17
|
import { assertAndNormalizeWebServer } from "./web_server_param.js";
|
|
18
18
|
import { run } from "./run.js";
|
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
assertAndNormalizeDirectoryUrl,
|
|
14
14
|
collectFiles,
|
|
15
15
|
} from "@jsenv/filesystem";
|
|
16
|
-
import { createLogger, createDetailedMessage, UNICODE } from "@jsenv/
|
|
16
|
+
import { createLogger, createDetailedMessage, UNICODE } from "@jsenv/humanize";
|
|
17
17
|
import {
|
|
18
18
|
startGithubCheckRun,
|
|
19
19
|
readGitHubWorkflowEnv,
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { readFileSync } from "node:fs";
|
|
2
|
-
import {
|
|
2
|
+
import { generateContentFrame, ANSI } from "@jsenv/humanize";
|
|
3
3
|
import { urlToFileSystemPath } from "@jsenv/urls";
|
|
4
|
-
import { ANSI } from "@jsenv/log";
|
|
5
4
|
|
|
6
5
|
export const formatErrorForTerminal = (
|
|
7
6
|
error,
|
|
@@ -25,7 +24,7 @@ export const formatErrorForTerminal = (
|
|
|
25
24
|
typeof error.site.line === "number"
|
|
26
25
|
) {
|
|
27
26
|
const content = readFileSync(new URL(error.site.url), "utf8");
|
|
28
|
-
text +=
|
|
27
|
+
text += generateContentFrame({
|
|
29
28
|
content,
|
|
30
29
|
line: error.site.line,
|
|
31
30
|
column: error.site.column,
|
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
import { memoryUsage } from "node:process";
|
|
2
2
|
import stripAnsi from "strip-ansi";
|
|
3
3
|
import { writeFileSync } from "@jsenv/filesystem";
|
|
4
|
-
import {
|
|
5
|
-
|
|
4
|
+
import {
|
|
5
|
+
createDynamicLog,
|
|
6
|
+
humanizeDuration,
|
|
7
|
+
humanizeMemoryUsage,
|
|
8
|
+
ANSI,
|
|
9
|
+
UNICODE,
|
|
10
|
+
} from "@jsenv/humanize";
|
|
6
11
|
|
|
7
12
|
import { formatErrorForTerminal } from "../format_error_for_terminal.js";
|
|
8
13
|
|
|
@@ -106,14 +111,14 @@ export const reporterList = ({
|
|
|
106
111
|
|
|
107
112
|
const msEllapsed = Date.now() - startMs;
|
|
108
113
|
const infos = [];
|
|
109
|
-
const duration =
|
|
114
|
+
const duration = humanizeDuration(msEllapsed, {
|
|
110
115
|
short: true,
|
|
111
116
|
decimals: 0,
|
|
112
117
|
rounded: false,
|
|
113
118
|
});
|
|
114
119
|
infos.push(ANSI.color(duration, ANSI.GREY));
|
|
115
120
|
const memoryHeapUsed = memoryUsage().heapUsed;
|
|
116
|
-
const memoryHeapUsedFormatted =
|
|
121
|
+
const memoryHeapUsedFormatted = humanizeMemoryUsage(memoryHeapUsed, {
|
|
117
122
|
short: true,
|
|
118
123
|
decimals: 0,
|
|
119
124
|
});
|
|
@@ -288,13 +293,13 @@ const renderExecutionLabel = (execution, logOptions) => {
|
|
|
288
293
|
const duration = timings.executionEnd - timings.executionStart;
|
|
289
294
|
const durationFormatted = logOptions.mockFluctuatingValues
|
|
290
295
|
? `<mock>ms`
|
|
291
|
-
:
|
|
296
|
+
: humanizeDuration(duration, { short: true });
|
|
292
297
|
infos.push(ANSI.color(durationFormatted, ANSI.GREY));
|
|
293
298
|
}
|
|
294
299
|
if (logOptions.showMemoryUsage && typeof memoryUsage === "number") {
|
|
295
300
|
const memoryUsageFormatted = logOptions.mockFluctuatingValues
|
|
296
301
|
? `<mock>MB`
|
|
297
|
-
:
|
|
302
|
+
: humanizeMemoryUsage(memoryUsage, { short: true });
|
|
298
303
|
infos.push(ANSI.color(memoryUsageFormatted, ANSI.GREY));
|
|
299
304
|
}
|
|
300
305
|
if (infos.length) {
|
|
@@ -572,7 +577,7 @@ export const renderOutro = (testPlanResult, logOptions = {}) => {
|
|
|
572
577
|
if (logOptions.mockFluctuatingValues) {
|
|
573
578
|
durationLog += "<mock>s";
|
|
574
579
|
} else {
|
|
575
|
-
durationLog +=
|
|
580
|
+
durationLog += humanizeDuration(timings.end, { short: true });
|
|
576
581
|
const namedTimings = {
|
|
577
582
|
setup: timings.executionStart,
|
|
578
583
|
execution: timings.executionEnd,
|
|
@@ -584,7 +589,7 @@ export const renderOutro = (testPlanResult, logOptions = {}) => {
|
|
|
584
589
|
const timingDetails = [];
|
|
585
590
|
for (const key of Object.keys(namedTimings)) {
|
|
586
591
|
const value = namedTimings[key];
|
|
587
|
-
const timingDuration =
|
|
592
|
+
const timingDuration = humanizeDuration(value, { short: true });
|
|
588
593
|
const timingString = `${ANSI.color(`${key}:`, ANSI.GREY)} ${ANSI.color(
|
|
589
594
|
timingDuration,
|
|
590
595
|
ANSI.GREY,
|
package/src/execution/run.js
CHANGED
|
@@ -39,8 +39,8 @@ export const run = async ({
|
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
const timingsOrigin = Date.now();
|
|
42
|
-
const takeTiming = (
|
|
43
|
-
return
|
|
42
|
+
const takeTiming = () => {
|
|
43
|
+
return Date.now() - timingsOrigin;
|
|
44
44
|
};
|
|
45
45
|
const result = {
|
|
46
46
|
status: "pending",
|
|
@@ -132,7 +132,7 @@ export const run = async ({
|
|
|
132
132
|
onConsole: (log) => onConsoleRef.current(log),
|
|
133
133
|
onRuntimeStarted: () => {
|
|
134
134
|
runtimeStatus = "started";
|
|
135
|
-
result.timings.runtimeStart =
|
|
135
|
+
result.timings.runtimeStart = takeTiming();
|
|
136
136
|
},
|
|
137
137
|
onRuntimeStopped: () => {
|
|
138
138
|
if (runtimeStatus === "stopped") return; // ignore double calls
|
|
@@ -174,6 +174,12 @@ export const run = async ({
|
|
|
174
174
|
const diff = timings.origin - result.timings.origin;
|
|
175
175
|
result.timings.executionStart = timings.start + diff;
|
|
176
176
|
result.timings.executionEnd = timings.end + diff;
|
|
177
|
+
|
|
178
|
+
if (result.timings.executionStart < result.timings.runtimeStart) {
|
|
179
|
+
// can happen for browsers where navigationStart can be earlier
|
|
180
|
+
// than when node.js calls runtimeStarted()
|
|
181
|
+
result.timings.runtimeStart = result.timings.executionStart;
|
|
182
|
+
}
|
|
177
183
|
}
|
|
178
184
|
result.memoryUsage =
|
|
179
185
|
typeof memoryUsage === "number"
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { writeFileSync, readFileSync } from "node:fs";
|
|
2
|
-
import { createDetailedMessage } from "@jsenv/
|
|
2
|
+
import { createDetailedMessage } from "@jsenv/humanize";
|
|
3
3
|
import { Abort, raceCallbacks } from "@jsenv/abort";
|
|
4
4
|
import { urlIsInsideOf } from "@jsenv/urls";
|
|
5
5
|
import { memoize } from "@jsenv/utils/src/memoize/memoize.js";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { fork } from "node:child_process";
|
|
2
2
|
import { fileURLToPath } from "node:url";
|
|
3
3
|
import { Abort, raceCallbacks } from "@jsenv/abort";
|
|
4
|
-
import { createDetailedMessage } from "@jsenv/
|
|
4
|
+
import { createDetailedMessage } from "@jsenv/humanize";
|
|
5
5
|
import { memoize } from "@jsenv/utils/src/memoize/memoize.js";
|
|
6
6
|
|
|
7
7
|
import { createChildExecOptions } from "./child_exec_options.js";
|