@jsenv/test 3.3.34 → 3.4.1

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.
@@ -301,7 +301,7 @@ const resolveAssociations = (associations, baseUrl) => {
301
301
  let patternResolved;
302
302
  try {
303
303
  patternResolved = String(new URL(pattern, baseUrl));
304
- } catch (e) {
304
+ } catch {
305
305
  // it's not really an url, no need to perform url resolution nor encoding
306
306
  patternResolved = pattern;
307
307
  }
@@ -1887,7 +1887,7 @@ const validateDirectoryUrl = (value) => {
1887
1887
  } else {
1888
1888
  try {
1889
1889
  urlString = String(new URL(value));
1890
- } catch (e) {
1890
+ } catch {
1891
1891
  return {
1892
1892
  valid: false,
1893
1893
  value,
@@ -1895,6 +1895,12 @@ const validateDirectoryUrl = (value) => {
1895
1895
  };
1896
1896
  }
1897
1897
  }
1898
+ } else if (
1899
+ value &&
1900
+ typeof value === "object" &&
1901
+ typeof value.href === "string"
1902
+ ) {
1903
+ value = value.href;
1898
1904
  } else {
1899
1905
  return {
1900
1906
  valid: false,
@@ -1937,7 +1943,7 @@ const validateFileUrl = (value, baseUrl) => {
1937
1943
  } else {
1938
1944
  try {
1939
1945
  urlString = String(new URL(value, baseUrl));
1940
- } catch (e) {
1946
+ } catch {
1941
1947
  return {
1942
1948
  valid: false,
1943
1949
  value,
@@ -2048,7 +2054,7 @@ const baseUrlFallback = fileSystemPathToUrl(process.cwd());
2048
2054
  const ensureWindowsDriveLetter = (url, baseUrl) => {
2049
2055
  try {
2050
2056
  url = String(new URL(url));
2051
- } catch (e) {
2057
+ } catch {
2052
2058
  throw new Error(`absolute url expect but got ${url}`);
2053
2059
  }
2054
2060
 
@@ -2058,7 +2064,7 @@ const ensureWindowsDriveLetter = (url, baseUrl) => {
2058
2064
 
2059
2065
  try {
2060
2066
  baseUrl = String(new URL(baseUrl));
2061
- } catch (e) {
2067
+ } catch {
2062
2068
  throw new Error(
2063
2069
  `absolute baseUrl expect but got ${baseUrl} to ensure windows drive letter on ${url}`,
2064
2070
  );
@@ -3314,8 +3320,6 @@ const composeTwoV8Coverages = (firstV8Coverage, secondV8Coverage) => {
3314
3320
  if (secondV8Coverage.result.length === 0) {
3315
3321
  return firstV8Coverage;
3316
3322
  }
3317
-
3318
- // eslint-disable-next-line import/no-unresolved
3319
3323
  const { mergeProcessCovs } = importWithRequire("@c88/v8-coverage");
3320
3324
  // "mergeProcessCovs" do not preserves source-map-cache during the merge
3321
3325
  // so we store sourcemap cache now
@@ -4531,11 +4535,11 @@ const renderIntro = (testPlanResult, logOptions) => {
4531
4535
  // TODO: an option to log how many cpu, memory etc we'll use?
4532
4536
  }
4533
4537
  {
4534
- const process = logOptions.mockFluctuatingValues
4538
+ const runtime = logOptions.mockFluctuatingValues
4535
4539
  ? `node@mock`
4536
- : `${testPlanResult.process.name}@${testPlanResult.process.version}`;
4537
- let processLine = `process: ${process}`;
4538
- lines.push(processLine);
4540
+ : `${testPlanResult.runtime.name}@${testPlanResult.runtime.version}`;
4541
+ let runtimeLine = `runtime: ${runtime}`;
4542
+ lines.push(runtimeLine);
4539
4543
  }
4540
4544
  }
4541
4545
  return `${renderBigSection({
@@ -5550,7 +5554,6 @@ const startServerUsingCommand = async (
5550
5554
 
5551
5555
  const startedPromise = (async () => {
5552
5556
  const logScale = [100, 250, 500];
5553
- // eslint-disable-next-line no-constant-condition
5554
5557
  while (true) {
5555
5558
  if (errorReceived) {
5556
5559
  break;
@@ -5856,7 +5859,7 @@ const executeTestPlan = async ({
5856
5859
  availableCpu: countAvailableCpus(),
5857
5860
  availableMemory: totalmem(),
5858
5861
  },
5859
- process: {
5862
+ runtime: {
5860
5863
  name: "node",
5861
5864
  version: process.version.slice(1),
5862
5865
  },
@@ -7332,7 +7335,7 @@ ${webServer.rootDirectoryUrl}`);
7332
7335
  if (memoryUsageAPIAvailable) {
7333
7336
  const getMemoryUsage = async () => {
7334
7337
  const memoryUsage = await page.evaluate(
7335
- /* eslint-env browser */
7338
+ /* eslint-disable no-undef */
7336
7339
  /* istanbul ignore next */
7337
7340
  async () => {
7338
7341
  const { performance } = window;
@@ -7355,7 +7358,7 @@ ${webServer.rootDirectoryUrl}`);
7355
7358
  }
7356
7359
  return null;
7357
7360
  },
7358
- /* eslint-env node */
7361
+ /* eslint-enable no-undef */
7359
7362
  );
7360
7363
  return memoryUsage;
7361
7364
  };
@@ -7374,7 +7377,7 @@ ${webServer.rootDirectoryUrl}`);
7374
7377
  if (collectPerformance) {
7375
7378
  callbackSet.add(async () => {
7376
7379
  const performance = await page.evaluate(
7377
- /* eslint-env browser */
7380
+ /* eslint-disable no-undef */
7378
7381
  /* istanbul ignore next */
7379
7382
  () => {
7380
7383
  const { performance } = window;
@@ -7393,7 +7396,7 @@ ${webServer.rootDirectoryUrl}`);
7393
7396
  measures,
7394
7397
  };
7395
7398
  },
7396
- /* eslint-env node */
7399
+ /* eslint-enable no-undef */
7397
7400
  );
7398
7401
  result.performance = performance;
7399
7402
  });
@@ -7466,7 +7469,7 @@ ${webServer.rootDirectoryUrl}`);
7466
7469
  try {
7467
7470
  await page.goto(fileServerUrl, { timeout: 0 });
7468
7471
  const returnValue = await page.evaluate(
7469
- /* eslint-env browser */
7472
+ /* eslint-disable no-undef */
7470
7473
  /* istanbul ignore next */
7471
7474
  async () => {
7472
7475
  if (!window.__supervisor__) {
@@ -7481,7 +7484,7 @@ ${webServer.rootDirectoryUrl}`);
7481
7484
  executionResultFromJsenvSupervisor.executionResults,
7482
7485
  };
7483
7486
  },
7484
- /* eslint-env node */
7487
+ /* eslint-enable no-undef */
7485
7488
  );
7486
7489
  cb(returnValue);
7487
7490
  } catch (e) {
@@ -7652,7 +7655,6 @@ const extractTextFromConsoleMessage = (consoleMessage) => {
7652
7655
  // ensure we use a string so that istanbul won't try
7653
7656
  // to put any coverage statement inside it
7654
7657
  // ideally we should use uneval no ?
7655
- // eslint-disable-next-line no-new-func
7656
7658
  // const functionEvaluatedBrowserSide = new Function(
7657
7659
  // "value",
7658
7660
  // `if (value instanceof Error) {
@@ -8037,7 +8039,7 @@ const killProcessTree = async (
8037
8039
  descendantProcessIds.forEach((descendantProcessId) => {
8038
8040
  try {
8039
8041
  process.kill(descendantProcessId, signal);
8040
- } catch (error) {
8042
+ } catch {
8041
8043
  // ignore
8042
8044
  }
8043
8045
  });
@@ -8057,7 +8059,7 @@ const killProcessTree = async (
8057
8059
  try {
8058
8060
  process.kill(remainingId, 0);
8059
8061
  return true;
8060
- } catch (e) {
8062
+ } catch {
8061
8063
  return false;
8062
8064
  }
8063
8065
  });
@@ -9336,7 +9338,7 @@ const reportAsJson = (
9336
9338
  testPlanResultCopy.os.version = "<mock>";
9337
9339
  testPlanResultCopy.os.availableCpu = "<mock>";
9338
9340
  testPlanResultCopy.os.availableMemory = "<mock>";
9339
- testPlanResultCopy.process.version = "<mock>";
9341
+ testPlanResultCopy.runtime.version = "<mock>";
9340
9342
  testPlanResultCopy.memoryUsage = "<mock>";
9341
9343
  testPlanResultCopy.cpuUsage = "<mock>";
9342
9344
  testPlanResultCopy.rootDirectoryUrl = "/mock/";
@@ -29,7 +29,7 @@ const ACTIONS_AVAILABLE = {
29
29
  const filePath = fileURLToPath(fileUrl);
30
30
  const require = createRequire(fileUrl);
31
31
  result.timings.start = Date.now();
32
- // eslint-disable-next-line import/no-dynamic-require
32
+ // eslint-disable-next-line import-x/no-dynamic-require
33
33
  const namespace = require(filePath);
34
34
  const namespaceResolved = {};
35
35
  await Promise.all(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jsenv/test",
3
- "version": "3.3.34",
3
+ "version": "3.4.1",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",
@@ -39,9 +39,9 @@
39
39
  "@c88/v8-coverage": "0.1.1",
40
40
  "@jsenv/abort": "4.3.0",
41
41
  "@jsenv/ast": "6.2.16",
42
- "@jsenv/exception": "1.1.1",
43
- "@jsenv/filesystem": "4.10.1",
44
- "@jsenv/github-check-run": "0.1.31",
42
+ "@jsenv/exception": "1.1.2",
43
+ "@jsenv/filesystem": "4.10.2",
44
+ "@jsenv/github-check-run": "0.1.32",
45
45
  "@jsenv/humanize": "1.2.8",
46
46
  "@jsenv/plugin-supervisor": "1.5.18",
47
47
  "@jsenv/sourcemap": "1.2.23",
@@ -4,8 +4,6 @@ export const composeTwoV8Coverages = (firstV8Coverage, secondV8Coverage) => {
4
4
  if (secondV8Coverage.result.length === 0) {
5
5
  return firstV8Coverage;
6
6
  }
7
-
8
- // eslint-disable-next-line import/no-unresolved
9
7
  const { mergeProcessCovs } = importWithRequire("@c88/v8-coverage");
10
8
  // "mergeProcessCovs" do not preserves source-map-cache during the merge
11
9
  // so we store sourcemap cache now
@@ -193,7 +193,7 @@ export const executeTestPlan = async ({
193
193
  availableCpu: countAvailableCpus(),
194
194
  availableMemory: totalmem(),
195
195
  },
196
- process: {
196
+ runtime: {
197
197
  name: "node",
198
198
  version: process.version.slice(1),
199
199
  },
@@ -19,7 +19,7 @@ export const reportAsJson = (
19
19
  testPlanResultCopy.os.version = "<mock>";
20
20
  testPlanResultCopy.os.availableCpu = "<mock>";
21
21
  testPlanResultCopy.os.availableMemory = "<mock>";
22
- testPlanResultCopy.process.version = "<mock>";
22
+ testPlanResultCopy.runtime.version = "<mock>";
23
23
  testPlanResultCopy.memoryUsage = "<mock>";
24
24
  testPlanResultCopy.cpuUsage = "<mock>";
25
25
  testPlanResultCopy.rootDirectoryUrl = "/mock/";
@@ -292,12 +292,12 @@ const renderIntro = (testPlanResult, logOptions) => {
292
292
  lines.push(osLine);
293
293
  // TODO: an option to log how many cpu, memory etc we'll use?
294
294
  }
295
- process_line: {
296
- const process = logOptions.mockFluctuatingValues
295
+ runtime_line: {
296
+ const runtime = logOptions.mockFluctuatingValues
297
297
  ? `node@mock`
298
- : `${testPlanResult.process.name}@${testPlanResult.process.version}`;
299
- let processLine = `process: ${process}`;
300
- lines.push(processLine);
298
+ : `${testPlanResult.runtime.name}@${testPlanResult.runtime.version}`;
299
+ let runtimeLine = `runtime: ${runtime}`;
300
+ lines.push(runtimeLine);
301
301
  }
302
302
  }
303
303
  return `${renderBigSection({
@@ -1,6 +1,5 @@
1
1
  import { Abort } from "@jsenv/abort";
2
2
  import { spawn, spawnSync } from "node:child_process";
3
-
4
3
  import { pingServer } from "../../helpers/ping_server.js";
5
4
 
6
5
  export const startServerUsingCommand = async (
@@ -96,7 +95,6 @@ export const startServerUsingCommand = async (
96
95
 
97
96
  const startedPromise = (async () => {
98
97
  const logScale = [100, 250, 500];
99
- // eslint-disable-next-line no-constant-condition
100
98
  while (true) {
101
99
  if (errorReceived) {
102
100
  break;
@@ -3,7 +3,6 @@ import { createDetailedMessage } from "@jsenv/humanize";
3
3
  import { urlIsInsideOf } from "@jsenv/urls";
4
4
  import { memoize } from "@jsenv/utils/src/memoize/memoize.js";
5
5
  import { readFileSync, writeFileSync } from "node:fs";
6
-
7
6
  import { composeTwoFileByFileIstanbulCoverages } from "../coverage/istanbul_coverage_composition.js";
8
7
  import { filterV8Coverage } from "../coverage/v8_coverage.js";
9
8
  import { WEB_URL_CONVERTER } from "../helpers/web_url_converter.js";
@@ -275,7 +274,7 @@ ${webServer.rootDirectoryUrl}`);
275
274
  if (memoryUsageAPIAvailable) {
276
275
  const getMemoryUsage = async () => {
277
276
  const memoryUsage = await page.evaluate(
278
- /* eslint-env browser */
277
+ /* eslint-disable no-undef */
279
278
  /* istanbul ignore next */
280
279
  async () => {
281
280
  const { performance } = window;
@@ -298,7 +297,7 @@ ${webServer.rootDirectoryUrl}`);
298
297
  }
299
298
  return null;
300
299
  },
301
- /* eslint-env node */
300
+ /* eslint-enable no-undef */
302
301
  );
303
302
  return memoryUsage;
304
303
  };
@@ -317,7 +316,7 @@ ${webServer.rootDirectoryUrl}`);
317
316
  if (collectPerformance) {
318
317
  callbackSet.add(async () => {
319
318
  const performance = await page.evaluate(
320
- /* eslint-env browser */
319
+ /* eslint-disable no-undef */
321
320
  /* istanbul ignore next */
322
321
  () => {
323
322
  const { performance } = window;
@@ -336,7 +335,7 @@ ${webServer.rootDirectoryUrl}`);
336
335
  measures,
337
336
  };
338
337
  },
339
- /* eslint-env node */
338
+ /* eslint-enable no-undef */
340
339
  );
341
340
  result.performance = performance;
342
341
  });
@@ -409,7 +408,7 @@ ${webServer.rootDirectoryUrl}`);
409
408
  try {
410
409
  await page.goto(fileServerUrl, { timeout: 0 });
411
410
  const returnValue = await page.evaluate(
412
- /* eslint-env browser */
411
+ /* eslint-disable no-undef */
413
412
  /* istanbul ignore next */
414
413
  async () => {
415
414
  if (!window.__supervisor__) {
@@ -424,7 +423,7 @@ ${webServer.rootDirectoryUrl}`);
424
423
  executionResultFromJsenvSupervisor.executionResults,
425
424
  };
426
425
  },
427
- /* eslint-env node */
426
+ /* eslint-enable no-undef */
428
427
  );
429
428
  cb(returnValue);
430
429
  } catch (e) {
@@ -595,7 +594,6 @@ const extractTextFromConsoleMessage = (consoleMessage) => {
595
594
  // ensure we use a string so that istanbul won't try
596
595
  // to put any coverage statement inside it
597
596
  // ideally we should use uneval no ?
598
- // eslint-disable-next-line no-new-func
599
597
  // const functionEvaluatedBrowserSide = new Function(
600
598
  // "value",
601
599
  // `if (value instanceof Error) {
@@ -1,4 +1,5 @@
1
1
  import { importWithRequire } from "../helpers/import_with_require.js";
2
+
2
3
  // see also https://github.com/sindresorhus/execa/issues/96
3
4
  export const killProcessTree = async (
4
5
  processId,
@@ -19,7 +20,7 @@ export const killProcessTree = async (
19
20
  descendantProcessIds.forEach((descendantProcessId) => {
20
21
  try {
21
22
  process.kill(descendantProcessId, signal);
22
- } catch (error) {
23
+ } catch {
23
24
  // ignore
24
25
  }
25
26
  });
@@ -39,7 +40,7 @@ export const killProcessTree = async (
39
40
  try {
40
41
  process.kill(remainingId, 0);
41
42
  return true;
42
- } catch (e) {
43
+ } catch {
43
44
  return false;
44
45
  }
45
46
  });
@@ -26,7 +26,7 @@ const ACTIONS_AVAILABLE = {
26
26
  const filePath = fileURLToPath(fileUrl);
27
27
  const require = createRequire(fileUrl);
28
28
  result.timings.start = Date.now();
29
- // eslint-disable-next-line import/no-dynamic-require
29
+ // eslint-disable-next-line import-x/no-dynamic-require
30
30
  const namespace = require(filePath);
31
31
  const namespaceResolved = {};
32
32
  await Promise.all(