@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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jsenv/test",
3
- "version": "3.0.4",
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.8",
44
- "@jsenv/inspect": "2.0.0",
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 { inspectFileSize } from "@jsenv/inspect";
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)} (${inspectFileSize(
21
+ `-> ${urlToFileSystemPath(fileUrl)} (${humanizeFileSize(
22
22
  Buffer.byteLength(coverageAsText),
23
23
  )})`,
24
24
  );
@@ -1,4 +1,4 @@
1
- import { createDetailedMessage } from "@jsenv/log";
1
+ import { createDetailedMessage } from "@jsenv/humanize";
2
2
 
3
3
  export const composeV8AndIstanbul = (
4
4
  v8FileByFileCoverage,
@@ -1,6 +1,6 @@
1
1
  import { readFileSync, readdirSync } from "node:fs";
2
2
  import { assertAndNormalizeDirectoryUrl } from "@jsenv/filesystem";
3
- import { createDetailedMessage } from "@jsenv/log";
3
+ import { createDetailedMessage } from "@jsenv/humanize";
4
4
  import { Abort } from "@jsenv/abort";
5
5
 
6
6
  export const readNodeV8CoverageDirectory = async ({
@@ -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/log";
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/log";
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 { inspectFileContent } from "@jsenv/inspect";
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 += inspectFileContent({
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 { inspectDuration, inspectMemoryUsage } from "@jsenv/inspect";
5
- import { createDynamicLog, ANSI, UNICODE } from "@jsenv/log";
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 = inspectDuration(msEllapsed, {
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 = inspectMemoryUsage(memoryHeapUsed, {
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
- : inspectDuration(duration, { short: true });
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
- : inspectMemoryUsage(memoryUsage, { short: true });
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 += inspectDuration(timings.end, { short: true });
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 = inspectDuration(value, { short: true });
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,
@@ -39,8 +39,8 @@ export const run = async ({
39
39
  }
40
40
 
41
41
  const timingsOrigin = Date.now();
42
- const takeTiming = (ms = Date.now()) => {
43
- return ms - timingsOrigin;
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 = Math.max(takeTiming(), 0);
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/log";
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,6 +1,6 @@
1
1
  import { findFreePort } from "@jsenv/server";
2
2
 
3
- import { createDetailedMessage } from "@jsenv/log";
3
+ import { createDetailedMessage } from "@jsenv/humanize";
4
4
  import { ExecOptions } from "./exec_options.js";
5
5
 
6
6
  export const createChildExecOptions = async ({
@@ -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/log";
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";