@jsenv/test 3.3.12 → 3.3.13

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.
Files changed (32) hide show
  1. package/dist/js/execute_using_dynamic_import.js +58 -58
  2. package/dist/jsenv_test.js +1458 -1458
  3. package/dist/node_child_process_controlled.mjs +1 -1
  4. package/dist/node_worker_thread_controlled.mjs +2 -2
  5. package/package.json +8 -8
  6. package/src/coverage/empty_coverage_factory.js +2 -2
  7. package/src/coverage/file_by_file_coverage.js +1 -1
  8. package/src/coverage/generate_coverage.js +6 -6
  9. package/src/coverage/missing_coverage.js +1 -1
  10. package/src/coverage/report_coverage_as_html.js +3 -3
  11. package/src/coverage/report_coverage_as_json.js +1 -1
  12. package/src/coverage/v8_coverage_node_directory.js +2 -2
  13. package/src/coverage/v8_coverage_to_istanbul.js +1 -1
  14. package/src/execution/exception.js +1 -1
  15. package/src/execution/execute.js +1 -1
  16. package/src/execution/execute_test_plan.js +20 -20
  17. package/src/execution/format_error_for_terminal.js +2 -2
  18. package/src/execution/reporters/reporter_list.js +3 -3
  19. package/src/execution/run.js +1 -1
  20. package/src/execution/web_server/start_using_command.js +1 -1
  21. package/src/execution/web_server_param.js +3 -3
  22. package/src/helpers/cpu_usage.test_manual.js +1 -1
  23. package/src/helpers/web_url_converter.js +1 -1
  24. package/src/main.js +4 -2
  25. package/src/runtime_browsers/middleware_istanbul.js +2 -2
  26. package/src/runtime_browsers/middleware_js_supervisor.js +2 -2
  27. package/src/runtime_browsers/using_playwright.js +5 -5
  28. package/src/runtime_node/execute_using_dynamic_import.js +2 -2
  29. package/src/runtime_node/importmap_hooks.mjs +1 -1
  30. package/src/runtime_node/node_child_process.js +4 -4
  31. package/src/runtime_node/node_worker_thread.js +3 -3
  32. package/src/runtime_node/node_worker_thread_controlled.mjs +1 -1
@@ -2,8 +2,8 @@ import { memoryUsage } from "node:process";
2
2
  import { createException } from "./js/exception.js";
3
3
  import { executeUsingDynamicImport } from "./js/execute_using_dynamic_import.js";
4
4
  import "node:fs";
5
- import "node:inspector";
6
5
  import "node:perf_hooks";
6
+ import "node:inspector";
7
7
 
8
8
  let memoryHeapUsedAtStart;
9
9
  if (process.env.MEASURE_MEMORY_AT_START) {
@@ -1,12 +1,12 @@
1
- import { parentPort } from "node:worker_threads";
2
1
  import { memoryUsage } from "node:process";
3
2
  import { setFlagsFromString } from "node:v8";
4
3
  import { runInNewContext } from "node:vm";
4
+ import { parentPort } from "node:worker_threads";
5
5
  import { createException } from "./js/exception.js";
6
6
  import { executeUsingDynamicImport } from "./js/execute_using_dynamic_import.js";
7
7
  import "node:fs";
8
- import "node:inspector";
9
8
  import "node:perf_hooks";
9
+ import "node:inspector";
10
10
 
11
11
  setFlagsFromString("--expose_gc");
12
12
  global.gc = runInNewContext("gc");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jsenv/test",
3
- "version": "3.3.12",
3
+ "version": "3.3.13",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",
@@ -38,14 +38,14 @@
38
38
  "dependencies": {
39
39
  "@c88/v8-coverage": "0.1.1",
40
40
  "@jsenv/abort": "4.3.0",
41
- "@jsenv/ast": "6.2.4",
42
- "@jsenv/filesystem": "4.8.1",
43
- "@jsenv/github-check-run": "0.1.22",
44
- "@jsenv/humanize": "1.2.4",
45
- "@jsenv/plugin-supervisor": "1.5.5",
46
- "@jsenv/sourcemap": "1.2.15",
41
+ "@jsenv/ast": "6.2.5",
42
+ "@jsenv/filesystem": "4.8.2",
43
+ "@jsenv/github-check-run": "0.1.23",
44
+ "@jsenv/humanize": "1.2.5",
45
+ "@jsenv/plugin-supervisor": "1.5.6",
46
+ "@jsenv/sourcemap": "1.2.16",
47
47
  "@jsenv/url-meta": "8.4.2",
48
- "@jsenv/urls": "2.3.0",
48
+ "@jsenv/urls": "2.3.1",
49
49
  "@jsenv/utils": "2.1.1",
50
50
  "errorstacks": "2.4.1",
51
51
  "he": "1.2.0",
@@ -1,7 +1,7 @@
1
- import { readFile } from "@jsenv/filesystem";
2
- import { resolveUrl } from "@jsenv/urls";
3
1
  import { Abort } from "@jsenv/abort";
4
2
  import { applyBabelPlugins } from "@jsenv/ast";
3
+ import { readFile } from "@jsenv/filesystem";
4
+ import { resolveUrl } from "@jsenv/urls";
5
5
 
6
6
  import { importWithRequire } from "../helpers/import_with_require.js";
7
7
  import { babelPluginInstrument } from "./babel_plugin_instrument.js";
@@ -1,7 +1,7 @@
1
1
  import {
2
- urlToRelativeUrl,
3
2
  fileSystemPathToUrl,
4
3
  isFileSystemPath,
4
+ urlToRelativeUrl,
5
5
  } from "@jsenv/urls";
6
6
 
7
7
  export const normalizeFileByFileCoveragePaths = (
@@ -1,14 +1,14 @@
1
- import { readFileSync } from "node:fs";
2
1
  import { Abort } from "@jsenv/abort";
2
+ import { readFileSync } from "node:fs";
3
3
 
4
+ import { normalizeFileByFileCoveragePaths } from "./file_by_file_coverage.js";
5
+ import { composeTwoFileByFileIstanbulCoverages } from "./istanbul_coverage_composition.js";
6
+ import { getMissingFileByFileCoverage } from "./missing_coverage.js";
7
+ import { composeV8AndIstanbul } from "./v8_and_istanbul.js";
4
8
  import { filterV8Coverage } from "./v8_coverage.js";
5
- import { readNodeV8CoverageDirectory } from "./v8_coverage_node_directory.js";
6
9
  import { composeTwoV8Coverages } from "./v8_coverage_composition.js";
7
- import { composeTwoFileByFileIstanbulCoverages } from "./istanbul_coverage_composition.js";
10
+ import { readNodeV8CoverageDirectory } from "./v8_coverage_node_directory.js";
8
11
  import { v8CoverageToIstanbul } from "./v8_coverage_to_istanbul.js";
9
- import { composeV8AndIstanbul } from "./v8_and_istanbul.js";
10
- import { normalizeFileByFileCoveragePaths } from "./file_by_file_coverage.js";
11
- import { getMissingFileByFileCoverage } from "./missing_coverage.js";
12
12
 
13
13
  export const generateCoverage = async (
14
14
  testPlanResult,
@@ -1,7 +1,7 @@
1
1
  import { Abort } from "@jsenv/abort";
2
2
 
3
- import { listRelativeFileUrlToCover } from "./list_files_not_covered.js";
4
3
  import { relativeUrlToEmptyCoverage } from "./empty_coverage_factory.js";
4
+ import { listRelativeFileUrlToCover } from "./list_files_not_covered.js";
5
5
 
6
6
  export const getMissingFileByFileCoverage = async ({
7
7
  signal,
@@ -1,7 +1,7 @@
1
- import { fileURLToPath } from "node:url";
2
- import { readFileSync } from "node:fs";
3
- import { urlToRelativeUrl } from "@jsenv/urls";
4
1
  import { ensureEmptyDirectorySync } from "@jsenv/filesystem";
2
+ import { urlToRelativeUrl } from "@jsenv/urls";
3
+ import { readFileSync } from "node:fs";
4
+ import { fileURLToPath } from "node:url";
5
5
 
6
6
  import { importWithRequire } from "../helpers/import_with_require.js";
7
7
  import { istanbulCoverageMapFromCoverage } from "./istanbul_coverage_map_from_coverage.js";
@@ -1,6 +1,6 @@
1
- import { urlToFileSystemPath } from "@jsenv/urls";
2
1
  import { writeFileSync } from "@jsenv/filesystem";
3
2
  import { humanizeFileSize } from "@jsenv/humanize";
3
+ import { urlToFileSystemPath } from "@jsenv/urls";
4
4
 
5
5
  export const reportCoverageAsJson = (
6
6
  testPlanResult,
@@ -1,7 +1,7 @@
1
- import { readFileSync, readdirSync } from "node:fs";
1
+ import { Abort } from "@jsenv/abort";
2
2
  import { assertAndNormalizeDirectoryUrl } from "@jsenv/filesystem";
3
3
  import { createDetailedMessage } from "@jsenv/humanize";
4
- import { Abort } from "@jsenv/abort";
4
+ import { readFileSync, readdirSync } from "node:fs";
5
5
 
6
6
  export const readNodeV8CoverageDirectory = async ({
7
7
  logger,
@@ -1,5 +1,5 @@
1
- import { urlToFileSystemPath } from "@jsenv/urls";
2
1
  import { Abort } from "@jsenv/abort";
2
+ import { urlToFileSystemPath } from "@jsenv/urls";
3
3
 
4
4
  import { importWithRequire } from "../helpers/import_with_require.js";
5
5
  import { composeTwoFileByFileIstanbulCoverages } from "./istanbul_coverage_composition.js";
@@ -19,8 +19,8 @@
19
19
 
20
20
  // https://github.com/marvinhagemeister/errorstacks/tree/main
21
21
  // https://cdn.jsdelivr.net/npm/errorstacks@latest/dist/esm/index.mjs
22
- import { parseStackTrace } from "errorstacks";
23
22
  import { URL_META } from "@jsenv/url-meta";
23
+ import { parseStackTrace } from "errorstacks";
24
24
 
25
25
  const isDev = process.execArgv.includes("--conditions=development");
26
26
  const jsenvCoreDirectoryUrl = new URL("../../../../../", import.meta.url);
@@ -14,8 +14,8 @@ import { Abort, raceProcessTeardownEvents } from "@jsenv/abort";
14
14
  import { assertAndNormalizeDirectoryUrl } from "@jsenv/filesystem";
15
15
  import { createLogger } from "@jsenv/humanize";
16
16
 
17
- import { assertAndNormalizeWebServer } from "./web_server_param.js";
18
17
  import { run } from "./run.js";
18
+ import { assertAndNormalizeWebServer } from "./web_server_param.js";
19
19
 
20
20
  export const execute = async ({
21
21
  signal = new AbortController().signal,
@@ -2,38 +2,38 @@
2
2
  *
3
3
  */
4
4
 
5
- import {
6
- release,
7
- cpus,
8
- availableParallelism,
9
- totalmem,
10
- freemem,
11
- } from "node:os";
12
- import { memoryUsage } from "node:process";
13
- import { existsSync } from "node:fs";
14
- import { takeCoverage } from "node:v8";
15
- import stripAnsi from "strip-ansi";
16
5
  import { Abort, raceProcessTeardownEvents } from "@jsenv/abort";
17
- import { URL_META } from "@jsenv/url-meta";
18
6
  import {
19
- ensureEmptyDirectory,
20
7
  assertAndNormalizeDirectoryUrl,
21
8
  collectFiles,
9
+ ensureEmptyDirectory,
22
10
  } from "@jsenv/filesystem";
23
- import { createLogger, createDetailedMessage, UNICODE } from "@jsenv/humanize";
24
11
  import {
25
- startGithubCheckRun,
26
12
  readGitHubWorkflowEnv,
13
+ startGithubCheckRun,
27
14
  } from "@jsenv/github-check-run";
15
+ import { createDetailedMessage, createLogger, UNICODE } from "@jsenv/humanize";
16
+ import { URL_META } from "@jsenv/url-meta";
17
+ import { existsSync } from "node:fs";
18
+ import {
19
+ availableParallelism,
20
+ cpus,
21
+ freemem,
22
+ release,
23
+ totalmem,
24
+ } from "node:os";
25
+ import { memoryUsage } from "node:process";
26
+ import { takeCoverage } from "node:v8";
27
+ import stripAnsi from "strip-ansi";
28
28
 
29
- import { startMeasuringTotalCpuUsage } from "../helpers/cpu_usage.js";
30
- import { createCallOrderer } from "../helpers/call_orderer.js";
31
29
  import { generateCoverage } from "../coverage/generate_coverage.js";
32
- import { assertAndNormalizeWebServer } from "./web_server_param.js";
30
+ import { createCallOrderer } from "../helpers/call_orderer.js";
31
+ import { startMeasuringTotalCpuUsage } from "../helpers/cpu_usage.js";
33
32
  import { githubAnnotationFromError } from "./github_annotation_from_error.js";
34
- import { run } from "./run.js";
35
- import { reporterList, renderOutroContent } from "./reporters/reporter_list.js";
36
33
  import { createIsInsideFragment } from "./is_inside_fragment.js";
34
+ import { renderOutroContent, reporterList } from "./reporters/reporter_list.js";
35
+ import { run } from "./run.js";
36
+ import { assertAndNormalizeWebServer } from "./web_server_param.js";
37
37
 
38
38
  /**
39
39
  * Execute a list of files and log how it goes.
@@ -1,6 +1,6 @@
1
- import { readFileSync } from "node:fs";
2
- import { generateContentFrame, ANSI } from "@jsenv/humanize";
1
+ import { ANSI, generateContentFrame } from "@jsenv/humanize";
3
2
  import { urlToFileSystemPath } from "@jsenv/urls";
3
+ import { readFileSync } from "node:fs";
4
4
 
5
5
  import { replaceUrls } from "./replace_urls.js";
6
6
 
@@ -1,14 +1,14 @@
1
- import { memoryUsage as processMemoryUsage } from "node:process";
2
- import stripAnsi from "strip-ansi";
3
1
  import { writeFileSync } from "@jsenv/filesystem";
4
2
  import {
3
+ ANSI,
5
4
  createDynamicLog,
6
5
  humanizeDuration,
7
6
  humanizeMemory,
8
- ANSI,
9
7
  UNICODE,
10
8
  } from "@jsenv/humanize";
11
9
  import { urlToFileSystemPath } from "@jsenv/urls";
10
+ import { memoryUsage as processMemoryUsage } from "node:process";
11
+ import stripAnsi from "strip-ansi";
12
12
 
13
13
  import { formatErrorForTerminal } from "../format_error_for_terminal.js";
14
14
 
@@ -10,9 +10,9 @@
10
10
  * - File execution result is returned, it contains status/errors/namespace/consoleCalls
11
11
  */
12
12
 
13
- import crypto from "node:crypto";
14
13
  import { Abort, raceCallbacks } from "@jsenv/abort";
15
14
  import { ensureParentDirectories } from "@jsenv/filesystem";
15
+ import crypto from "node:crypto";
16
16
 
17
17
  import { createException } from "./exception.js";
18
18
 
@@ -1,5 +1,5 @@
1
- import { spawn, spawnSync } from "node:child_process";
2
1
  import { Abort } from "@jsenv/abort";
2
+ import { spawn, spawnSync } from "node:child_process";
3
3
 
4
4
  import { pingServer } from "../../helpers/ping_server.js";
5
5
 
@@ -1,9 +1,9 @@
1
1
  import { assertAndNormalizeDirectoryUrl } from "@jsenv/filesystem";
2
2
 
3
- import { startServerUsingModuleUrl } from "./web_server/start_using_module_url.js";
4
- import { startServerUsingCommand } from "./web_server/start_using_command.js";
5
- import { pingServer } from "../helpers/ping_server.js";
6
3
  import { basicFetch } from "../helpers/basic_fetch.js";
4
+ import { pingServer } from "../helpers/ping_server.js";
5
+ import { startServerUsingCommand } from "./web_server/start_using_command.js";
6
+ import { startServerUsingModuleUrl } from "./web_server/start_using_module_url.js";
7
7
 
8
8
  export const assertAndNormalizeWebServer = async (
9
9
  webServer,
@@ -1,7 +1,7 @@
1
1
  import {
2
+ formatUsage,
2
3
  startMeasuringCpuUsage,
3
4
  startMeasuringTotalCpuUsage,
4
- formatUsage,
5
5
  } from "./cpu_usage.js";
6
6
 
7
7
  const cpuUsage = startMeasuringCpuUsage();
@@ -1,5 +1,5 @@
1
1
  import { ensureWindowsDriveLetter } from "@jsenv/filesystem";
2
- import { urlIsInsideOf, moveUrl } from "@jsenv/urls";
2
+ import { moveUrl, urlIsInsideOf } from "@jsenv/urls";
3
3
 
4
4
  export const WEB_URL_CONVERTER = {
5
5
  asWebUrl: (fileUrl, webServer) => {
package/src/main.js CHANGED
@@ -1,3 +1,5 @@
1
+ // tslint:disable:ordered-imports
2
+
1
3
  // test
2
4
  export { executeTestPlan } from "./execution/execute_test_plan.js";
3
5
  // runtimes (used to execute tests)
@@ -7,9 +9,9 @@ export { webkit, webkitIsolatedTab } from "./runtime_browsers/webkit.js";
7
9
  export { nodeChildProcess } from "./runtime_node/node_child_process.js";
8
10
  export { nodeWorkerThread } from "./runtime_node/node_worker_thread.js";
9
11
  // coverage
10
- export { reportCoverageInConsole } from "./coverage/report_coverage_in_console.js";
11
- export { reportCoverageAsJson } from "./coverage/report_coverage_as_json.js";
12
12
  export { reportCoverageAsHtml } from "./coverage/report_coverage_as_html.js";
13
+ export { reportCoverageAsJson } from "./coverage/report_coverage_as_json.js";
14
+ export { reportCoverageInConsole } from "./coverage/report_coverage_in_console.js";
13
15
  // reporters
14
16
  export { reporterList } from "./execution/reporters/reporter_list.js";
15
17
  // other
@@ -1,9 +1,9 @@
1
- import { URL_META } from "@jsenv/url-meta";
2
1
  import { applyBabelPlugins } from "@jsenv/ast";
3
2
  import { SOURCEMAP, generateSourcemapDataUrl } from "@jsenv/sourcemap";
3
+ import { URL_META } from "@jsenv/url-meta";
4
4
 
5
- import { WEB_URL_CONVERTER } from "../helpers/web_url_converter.js";
6
5
  import { babelPluginInstrument } from "../coverage/babel_plugin_instrument.js";
6
+ import { WEB_URL_CONVERTER } from "../helpers/web_url_converter.js";
7
7
 
8
8
  export const initIstanbulMiddleware = async (
9
9
  page,
@@ -1,9 +1,9 @@
1
- import { readFileSync } from "node:fs";
2
- import { urlToExtension } from "@jsenv/urls";
3
1
  import {
4
2
  injectSupervisorIntoHTML,
5
3
  supervisorFileUrl,
6
4
  } from "@jsenv/plugin-supervisor";
5
+ import { urlToExtension } from "@jsenv/urls";
6
+ import { readFileSync } from "node:fs";
7
7
 
8
8
  export const initJsSupervisorMiddleware = async (
9
9
  page,
@@ -1,14 +1,14 @@
1
- import { writeFileSync, readFileSync } from "node:fs";
2
- import { createDetailedMessage } from "@jsenv/humanize";
3
1
  import { Abort, raceCallbacks } from "@jsenv/abort";
2
+ import { createDetailedMessage } from "@jsenv/humanize";
4
3
  import { urlIsInsideOf } from "@jsenv/urls";
5
4
  import { memoize } from "@jsenv/utils/src/memoize/memoize.js";
5
+ import { readFileSync, writeFileSync } from "node:fs";
6
6
 
7
- import { WEB_URL_CONVERTER } from "../helpers/web_url_converter.js";
8
- import { filterV8Coverage } from "../coverage/v8_coverage.js";
9
7
  import { composeTwoFileByFileIstanbulCoverages } from "../coverage/istanbul_coverage_composition.js";
10
- import { initJsSupervisorMiddleware } from "./middleware_js_supervisor.js";
8
+ import { filterV8Coverage } from "../coverage/v8_coverage.js";
9
+ import { WEB_URL_CONVERTER } from "../helpers/web_url_converter.js";
11
10
  import { initIstanbulMiddleware } from "./middleware_istanbul.js";
11
+ import { initJsSupervisorMiddleware } from "./middleware_js_supervisor.js";
12
12
 
13
13
  const browserPromiseCache = new Map();
14
14
 
@@ -1,9 +1,9 @@
1
1
  import { writeFileSync } from "node:fs";
2
2
  import { memoryUsage } from "node:process";
3
3
 
4
- import { startJsCoverage } from "./profiler_v8_coverage.js";
5
- import { startObservingPerformances } from "./node_execution_performance.js";
6
4
  import { createException } from "../execution/exception.js";
5
+ import { startObservingPerformances } from "./node_execution_performance.js";
6
+ import { startJsCoverage } from "./profiler_v8_coverage.js";
7
7
 
8
8
  export const executeUsingDynamicImport = async ({
9
9
  rootDirectoryUrl,
@@ -1,6 +1,6 @@
1
+ import { normalizeImportMap, resolveImport } from "@jsenv/importmap";
1
2
  import { readFileSync } from "node:fs";
2
3
  import { pathToFileURL } from "node:url";
3
- import { normalizeImportMap, resolveImport } from "@jsenv/importmap";
4
4
 
5
5
  let importMap;
6
6
 
@@ -1,14 +1,14 @@
1
- import { fork } from "node:child_process";
2
- import { fileURLToPath } from "node:url";
3
1
  import { Abort, raceCallbacks } from "@jsenv/abort";
4
- import { UNICODE, ANSI, createDetailedMessage } from "@jsenv/humanize";
2
+ import { ANSI, createDetailedMessage, UNICODE } from "@jsenv/humanize";
5
3
  import { memoize } from "@jsenv/utils/src/memoize/memoize.js";
4
+ import { fork } from "node:child_process";
5
+ import { fileURLToPath } from "node:url";
6
6
 
7
7
  import { createChildExecOptions } from "./child_exec_options.js";
8
8
  import { ExecOptions } from "./exec_options.js";
9
- import { killProcessTree } from "./kill_process_tree.js";
10
9
  import { EXIT_CODES } from "./exit_codes.js";
11
10
  import { IMPORTMAP_NODE_LOADER_FILE_URL } from "./importmap_node_loader_file_url.js";
11
+ import { killProcessTree } from "./kill_process_tree.js";
12
12
  import { NO_EXPERIMENTAL_WARNING_FILE_URL } from "./no_experimental_warnings_file_url.js";
13
13
 
14
14
  const CONTROLLED_CHILD_PROCESS_URL = new URL(
@@ -1,11 +1,11 @@
1
1
  // https://github.com/avajs/ava/blob/576f534b345259055c95fa0c2b33bef10847a2af/lib/fork.js#L23
2
2
  // https://nodejs.org/api/worker_threads.html
3
3
  // https://github.com/avajs/ava/blob/576f534b345259055c95fa0c2b33bef10847a2af/lib/worker/base.js
4
- import { Worker } from "node:worker_threads";
5
- import { fileURLToPath } from "node:url";
6
4
  import { Abort, raceCallbacks } from "@jsenv/abort";
7
- import { UNICODE, ANSI } from "@jsenv/humanize";
5
+ import { ANSI, UNICODE } from "@jsenv/humanize";
8
6
  import { memoize } from "@jsenv/utils/src/memoize/memoize.js";
7
+ import { fileURLToPath } from "node:url";
8
+ import { Worker } from "node:worker_threads";
9
9
 
10
10
  import { createChildExecOptions } from "./child_exec_options.js";
11
11
  import { ExecOptions } from "./exec_options.js";
@@ -1,7 +1,7 @@
1
- import { parentPort } from "node:worker_threads";
2
1
  import { memoryUsage } from "node:process";
3
2
  import { setFlagsFromString } from "node:v8";
4
3
  import { runInNewContext } from "node:vm";
4
+ import { parentPort } from "node:worker_threads";
5
5
 
6
6
  import { createException } from "../execution/exception.js";
7
7
  import { executeUsingDynamicImport } from "./execute_using_dynamic_import.js";