@jsenv/test 3.4.3 → 3.5.0

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.
@@ -365,13 +365,19 @@ const applyAssociations = ({ url, associations }) => {
365
365
  };
366
366
 
367
367
  const deepAssign = (firstValue, secondValue) => {
368
- if (!isPlainObject(firstValue) || !isPlainObject(secondValue)) {
368
+ if (!isPlainObject(firstValue)) {
369
+ if (isPlainObject(secondValue)) {
370
+ return deepAssign({}, secondValue);
371
+ }
372
+ return secondValue;
373
+ }
374
+ if (!isPlainObject(secondValue)) {
369
375
  return secondValue;
370
376
  }
371
377
  for (const key of Object.keys(secondValue)) {
372
- const leftValue = firstValue[key];
373
- const rightValue = secondValue[key];
374
- firstValue[key] = deepAssign(leftValue, rightValue);
378
+ const leftPopertyValue = firstValue[key];
379
+ const rightPropertyValue = secondValue[key];
380
+ firstValue[key] = deepAssign(leftPopertyValue, rightPropertyValue);
375
381
  }
376
382
  return firstValue;
377
383
  };
@@ -8,6 +8,7 @@ import { readdir, chmod, stat, lstat, chmodSync, statSync, lstatSync, promises,
8
8
  import { dirname } from "node:path";
9
9
  import crypto from "node:crypto";
10
10
  import { readGitHubWorkflowEnv, startGithubCheckRun } from "@jsenv/github-check-run";
11
+ import { applyNodeEsmResolution } from "@jsenv/node-esm-resolution";
11
12
  import { takeCoverage } from "node:v8";
12
13
  import stripAnsi from "strip-ansi";
13
14
  import { createRequire } from "node:module";
@@ -1583,15 +1584,13 @@ const createDynamicLog = ({
1583
1584
  // is that node.js will later throw error if stream gets closed
1584
1585
  // while something listening data on it
1585
1586
  const spyStreamOutput = (stream, callback) => {
1586
- const originalWrite = stream.write;
1587
-
1588
1587
  let output = "";
1589
1588
  let installed = true;
1590
-
1589
+ const originalWrite = stream.write;
1591
1590
  stream.write = function (...args /* chunk, encoding, callback */) {
1592
1591
  output += args;
1593
1592
  callback(output);
1594
- return originalWrite.call(stream, ...args);
1593
+ return originalWrite.call(this, ...args);
1595
1594
  };
1596
1595
 
1597
1596
  const uninstall = () => {
@@ -4504,8 +4503,8 @@ const renderIntro = (testPlanResult, logOptions) => {
4504
4503
  if (!single) {
4505
4504
  testPlanLog += ",";
4506
4505
  }
4506
+ testPlanLog += "\n";
4507
4507
  }
4508
- testPlanLog += "\n";
4509
4508
  testPlanLog += "}";
4510
4509
  lines.push(`testPlan: ${testPlanLog}`);
4511
4510
  }
@@ -6330,10 +6329,30 @@ To fix this warning:
6330
6329
  // --- 100 execution found ---
6331
6330
  // Executing only from 33 to 66 according to fragment: "2/3"
6332
6331
 
6332
+ let onlyWithinUrl;
6333
+ if (process.argv.length > 2) {
6334
+ const onlyWithin = process.argv[2];
6335
+ if (onlyWithin[0] === "@") {
6336
+ const resolutionResult = applyNodeEsmResolution({
6337
+ specifier: onlyWithin,
6338
+ parentUrl: rootDirectoryUrl,
6339
+ });
6340
+ onlyWithinUrl = resolutionResult.packageDirectoryUrl;
6341
+ } else {
6342
+ onlyWithinUrl = new URL(onlyWithin, rootDirectoryUrl);
6343
+ }
6344
+ }
6345
+
6333
6346
  let index = 0;
6334
6347
  let lastExecution;
6335
6348
  const fileExecutionCountMap = new Map();
6336
6349
  for (const { relativeUrl, meta } of fileResultArray) {
6350
+ if (onlyWithinUrl) {
6351
+ const fileUrl = new URL(relativeUrl, rootDirectoryUrl).href;
6352
+ if (!urlIsInsideOf(fileUrl, onlyWithinUrl)) {
6353
+ continue;
6354
+ }
6355
+ }
6337
6356
  const filePlan = meta.testPlan;
6338
6357
  for (const groupName of Object.keys(filePlan)) {
6339
6358
  const stepConfig = filePlan[groupName];
@@ -6416,7 +6435,15 @@ To fix this warning:
6416
6435
  result: {},
6417
6436
  };
6418
6437
  if (typeof params.allocatedMs === "function") {
6419
- params.allocatedMs = params.allocatedMs(execution);
6438
+ const allocatedMsResult = params.allocatedMs(execution);
6439
+ params.allocatedMs =
6440
+ allocatedMsResult === undefined
6441
+ ? defaultMsAllocatedPerExecution
6442
+ : allocatedMsResult;
6443
+ }
6444
+ if (typeof params.uses === "function") {
6445
+ const usesResult = params.uses(execution);
6446
+ params.uses = usesResult;
6420
6447
  }
6421
6448
 
6422
6449
  lastExecution = execution;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jsenv/test",
3
- "version": "3.4.3",
3
+ "version": "3.5.0",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",
@@ -28,7 +28,6 @@
28
28
  "/src/"
29
29
  ],
30
30
  "scripts": {
31
- "test": "node --conditions=development ./scripts/test.mjs",
32
31
  "build": "node --conditions=development ./scripts/build.mjs",
33
32
  "prepublishOnly": "npm run build"
34
33
  },
@@ -38,14 +37,14 @@
38
37
  "dependencies": {
39
38
  "@c88/v8-coverage": "0.1.1",
40
39
  "@jsenv/abort": "4.3.0",
41
- "@jsenv/ast": "6.2.16",
42
- "@jsenv/exception": "1.1.2",
43
- "@jsenv/filesystem": "4.10.2",
44
- "@jsenv/github-check-run": "0.2.0",
40
+ "@jsenv/ast": "6.2.17",
41
+ "@jsenv/exception": "1.1.3",
42
+ "@jsenv/filesystem": "4.10.3",
43
+ "@jsenv/github-check-run": "0.2.1",
45
44
  "@jsenv/humanize": "1.2.8",
46
- "@jsenv/plugin-supervisor": "1.5.18",
45
+ "@jsenv/plugin-supervisor": "1.5.19",
47
46
  "@jsenv/sourcemap": "1.2.23",
48
- "@jsenv/url-meta": "8.5.1",
47
+ "@jsenv/url-meta": "8.5.2",
49
48
  "@jsenv/urls": "2.5.2",
50
49
  "@jsenv/utils": "2.1.2",
51
50
  "he": "1.2.0",
@@ -57,8 +56,5 @@
57
56
  "strip-ansi": "7.1.0",
58
57
  "supports-color": "9.4.0",
59
58
  "v8-to-istanbul": "9.3.0"
60
- },
61
- "devDependencies": {
62
- "@jsenv/terminal-recorder": "../independent/terminal-recorder/"
63
59
  }
64
60
  }
@@ -13,7 +13,9 @@ import {
13
13
  startGithubCheckRun,
14
14
  } from "@jsenv/github-check-run";
15
15
  import { createDetailedMessage, createLogger, UNICODE } from "@jsenv/humanize";
16
+ import { applyNodeEsmResolution } from "@jsenv/node-esm-resolution";
16
17
  import { URL_META } from "@jsenv/url-meta";
18
+ import { urlIsInsideOf } from "@jsenv/urls";
17
19
  import { existsSync } from "node:fs";
18
20
  import {
19
21
  availableParallelism,
@@ -661,10 +663,30 @@ To fix this warning:
661
663
  // --- 100 execution found ---
662
664
  // Executing only from 33 to 66 according to fragment: "2/3"
663
665
 
666
+ let onlyWithinUrl;
667
+ if (process.argv.length > 2) {
668
+ const onlyWithin = process.argv[2];
669
+ if (onlyWithin[0] === "@") {
670
+ const resolutionResult = applyNodeEsmResolution({
671
+ specifier: onlyWithin,
672
+ parentUrl: rootDirectoryUrl,
673
+ });
674
+ onlyWithinUrl = resolutionResult.packageDirectoryUrl;
675
+ } else {
676
+ onlyWithinUrl = new URL(onlyWithin, rootDirectoryUrl);
677
+ }
678
+ }
679
+
664
680
  let index = 0;
665
681
  let lastExecution;
666
682
  const fileExecutionCountMap = new Map();
667
683
  for (const { relativeUrl, meta } of fileResultArray) {
684
+ if (onlyWithinUrl) {
685
+ const fileUrl = new URL(relativeUrl, rootDirectoryUrl).href;
686
+ if (!urlIsInsideOf(fileUrl, onlyWithinUrl)) {
687
+ continue;
688
+ }
689
+ }
668
690
  const filePlan = meta.testPlan;
669
691
  for (const groupName of Object.keys(filePlan)) {
670
692
  const stepConfig = filePlan[groupName];
@@ -747,7 +769,15 @@ To fix this warning:
747
769
  result: {},
748
770
  };
749
771
  if (typeof params.allocatedMs === "function") {
750
- params.allocatedMs = params.allocatedMs(execution);
772
+ const allocatedMsResult = params.allocatedMs(execution);
773
+ params.allocatedMs =
774
+ allocatedMsResult === undefined
775
+ ? defaultMsAllocatedPerExecution
776
+ : allocatedMsResult;
777
+ }
778
+ if (typeof params.uses === "function") {
779
+ const usesResult = params.uses(execution);
780
+ params.uses = usesResult;
751
781
  }
752
782
 
753
783
  lastExecution = execution;
@@ -260,8 +260,8 @@ const renderIntro = (testPlanResult, logOptions) => {
260
260
  if (!single) {
261
261
  testPlanLog += ",";
262
262
  }
263
+ testPlanLog += "\n";
263
264
  }
264
- testPlanLog += "\n";
265
265
  testPlanLog += "}";
266
266
  lines.push(`testPlan: ${testPlanLog}`);
267
267
  }