@jsenv/test 3.0.2 → 3.0.4
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/js/execute_using_dynamic_import.js +3 -2
- package/dist/jsenv_test.js +28 -30
- package/package.json +2 -2
- package/src/execution/execute_test_plan.js +10 -0
- package/src/execution/run.js +10 -13
- package/src/runtime_browsers/using_playwright.js +8 -17
- package/src/runtime_node/execute_using_dynamic_import.js +3 -2
|
@@ -138,6 +138,7 @@ const executeUsingDynamicImport = async ({
|
|
|
138
138
|
}) => {
|
|
139
139
|
const result = {
|
|
140
140
|
timings: {
|
|
141
|
+
origin: Date.now(),
|
|
141
142
|
start: null,
|
|
142
143
|
end: null,
|
|
143
144
|
},
|
|
@@ -187,7 +188,7 @@ const executeUsingDynamicImport = async ({
|
|
|
187
188
|
};
|
|
188
189
|
}
|
|
189
190
|
|
|
190
|
-
result.timings.start = Date.now();
|
|
191
|
+
result.timings.start = Date.now() - result.timings.origin;
|
|
191
192
|
try {
|
|
192
193
|
const namespace = await import(fileUrl);
|
|
193
194
|
const namespaceResolved = {};
|
|
@@ -203,7 +204,7 @@ const executeUsingDynamicImport = async ({
|
|
|
203
204
|
result.status = "failed";
|
|
204
205
|
result.errors.push(createException(e, { rootDirectoryUrl }));
|
|
205
206
|
} finally {
|
|
206
|
-
result.timings.end = Date.now();
|
|
207
|
+
result.timings.end = Date.now() - result.timings.origin;
|
|
207
208
|
if (finalizeCoverage) {
|
|
208
209
|
await finalizeCoverage();
|
|
209
210
|
finalizeCoverage = null;
|
package/dist/jsenv_test.js
CHANGED
|
@@ -4552,14 +4552,17 @@ const run = async ({
|
|
|
4552
4552
|
allocatedMs = 0;
|
|
4553
4553
|
}
|
|
4554
4554
|
|
|
4555
|
-
const
|
|
4555
|
+
const timingsOrigin = Date.now();
|
|
4556
|
+
const takeTiming = (ms = Date.now()) => {
|
|
4557
|
+
return ms - timingsOrigin;
|
|
4558
|
+
};
|
|
4556
4559
|
const result = {
|
|
4557
4560
|
status: "pending",
|
|
4558
4561
|
errors: [],
|
|
4559
4562
|
namespace: null,
|
|
4560
4563
|
consoleCalls: null,
|
|
4561
4564
|
timings: {
|
|
4562
|
-
origin:
|
|
4565
|
+
origin: timingsOrigin,
|
|
4563
4566
|
start: 0,
|
|
4564
4567
|
runtimeStart: null,
|
|
4565
4568
|
executionStart: null,
|
|
@@ -4571,9 +4574,6 @@ const run = async ({
|
|
|
4571
4574
|
performance: null,
|
|
4572
4575
|
coverageFileUrl: null,
|
|
4573
4576
|
};
|
|
4574
|
-
const takeTiming = (ms = Date.now()) => {
|
|
4575
|
-
return ms - timingOrigin;
|
|
4576
|
-
};
|
|
4577
4577
|
const onConsoleRef = { current: () => {} };
|
|
4578
4578
|
const stopSignal = { notify: () => {} };
|
|
4579
4579
|
const runtimeLabel = `${runtime.name}/${runtime.version}`;
|
|
@@ -4646,7 +4646,7 @@ const run = async ({
|
|
|
4646
4646
|
onConsole: (log) => onConsoleRef.current(log),
|
|
4647
4647
|
onRuntimeStarted: () => {
|
|
4648
4648
|
runtimeStatus = "started";
|
|
4649
|
-
result.timings.runtimeStart = takeTiming();
|
|
4649
|
+
result.timings.runtimeStart = Math.max(takeTiming(), 0);
|
|
4650
4650
|
},
|
|
4651
4651
|
onRuntimeStopped: () => {
|
|
4652
4652
|
if (runtimeStatus === "stopped") return; // ignore double calls
|
|
@@ -4684,13 +4684,10 @@ const run = async ({
|
|
|
4684
4684
|
result.errors.push(errorProxy);
|
|
4685
4685
|
}
|
|
4686
4686
|
result.namespace = namespace;
|
|
4687
|
-
if (timings) {
|
|
4688
|
-
|
|
4689
|
-
|
|
4690
|
-
|
|
4691
|
-
if (timings.end) {
|
|
4692
|
-
result.timings.executionEnd = Math.max(takeTiming(timings.end), 0);
|
|
4693
|
-
}
|
|
4687
|
+
if (timings && typeof timings.start === "number") {
|
|
4688
|
+
const diff = timings.origin - result.timings.origin;
|
|
4689
|
+
result.timings.executionStart = timings.start + diff;
|
|
4690
|
+
result.timings.executionEnd = timings.end + diff;
|
|
4694
4691
|
}
|
|
4695
4692
|
result.memoryUsage =
|
|
4696
4693
|
typeof memoryUsage === "number"
|
|
@@ -5889,6 +5886,16 @@ const executeTestPlan = async ({
|
|
|
5889
5886
|
`parallel.maxMemory must be a number or a percentage, got ${maxMemory}`,
|
|
5890
5887
|
);
|
|
5891
5888
|
}
|
|
5889
|
+
|
|
5890
|
+
const maxCpu = parallel.maxCpu;
|
|
5891
|
+
if (typeof maxCpu === "string") {
|
|
5892
|
+
const maxCpuAsRatio = assertPercentageAndConvertToRatio(maxCpu);
|
|
5893
|
+
parallel.maxCpu = maxCpuAsRatio;
|
|
5894
|
+
} else if (typeof maxCpu !== "number") {
|
|
5895
|
+
throw new TypeError(
|
|
5896
|
+
`parallel.maxCpu must be a number or a percentage, got ${maxCpu}`,
|
|
5897
|
+
);
|
|
5898
|
+
}
|
|
5892
5899
|
}
|
|
5893
5900
|
// testPlan
|
|
5894
5901
|
{
|
|
@@ -7031,7 +7038,7 @@ ${webServer.rootDirectoryUrl}`);
|
|
|
7031
7038
|
if (memoryUsageAPIAvailable) {
|
|
7032
7039
|
const getMemoryUsage = async () => {
|
|
7033
7040
|
const memoryUsage = await page.evaluate(
|
|
7034
|
-
/* eslint-
|
|
7041
|
+
/* eslint-env browser */
|
|
7035
7042
|
/* istanbul ignore next */
|
|
7036
7043
|
async () => {
|
|
7037
7044
|
const { performance } = window;
|
|
@@ -7046,7 +7053,7 @@ ${webServer.rootDirectoryUrl}`);
|
|
|
7046
7053
|
// https://developer.mozilla.org/en-US/docs/Web/API/Performance/measureUserAgentSpecificMemory
|
|
7047
7054
|
if (
|
|
7048
7055
|
performance.measureUserAgentSpecificMemory &&
|
|
7049
|
-
crossOriginIsolated
|
|
7056
|
+
window.crossOriginIsolated
|
|
7050
7057
|
) {
|
|
7051
7058
|
const memorySample =
|
|
7052
7059
|
await performance.measureUserAgentSpecificMemory();
|
|
@@ -7054,7 +7061,7 @@ ${webServer.rootDirectoryUrl}`);
|
|
|
7054
7061
|
}
|
|
7055
7062
|
return null;
|
|
7056
7063
|
},
|
|
7057
|
-
/* eslint-
|
|
7064
|
+
/* eslint-env node */
|
|
7058
7065
|
);
|
|
7059
7066
|
return memoryUsage;
|
|
7060
7067
|
};
|
|
@@ -7073,7 +7080,7 @@ ${webServer.rootDirectoryUrl}`);
|
|
|
7073
7080
|
if (collectPerformance) {
|
|
7074
7081
|
callbackSet.add(async () => {
|
|
7075
7082
|
const performance = await page.evaluate(
|
|
7076
|
-
/* eslint-
|
|
7083
|
+
/* eslint-env browser */
|
|
7077
7084
|
/* istanbul ignore next */
|
|
7078
7085
|
() => {
|
|
7079
7086
|
const { performance } = window;
|
|
@@ -7092,7 +7099,7 @@ ${webServer.rootDirectoryUrl}`);
|
|
|
7092
7099
|
measures,
|
|
7093
7100
|
};
|
|
7094
7101
|
},
|
|
7095
|
-
/* eslint-
|
|
7102
|
+
/* eslint-env node */
|
|
7096
7103
|
);
|
|
7097
7104
|
result.performance = performance;
|
|
7098
7105
|
});
|
|
@@ -7165,15 +7172,9 @@ ${webServer.rootDirectoryUrl}`);
|
|
|
7165
7172
|
try {
|
|
7166
7173
|
await page.goto(fileServerUrl, { timeout: 0 });
|
|
7167
7174
|
const returnValue = await page.evaluate(
|
|
7168
|
-
/* eslint-
|
|
7175
|
+
/* eslint-env browser */
|
|
7169
7176
|
/* istanbul ignore next */
|
|
7170
7177
|
async () => {
|
|
7171
|
-
let startTime;
|
|
7172
|
-
try {
|
|
7173
|
-
startTime = window.performance.timing.navigationStart;
|
|
7174
|
-
} catch (e) {
|
|
7175
|
-
startTime = Date.now();
|
|
7176
|
-
}
|
|
7177
7178
|
if (!window.__supervisor__) {
|
|
7178
7179
|
throw new Error("window.__supervisor__ is undefined");
|
|
7179
7180
|
}
|
|
@@ -7181,15 +7182,12 @@ ${webServer.rootDirectoryUrl}`);
|
|
|
7181
7182
|
await window.__supervisor__.getDocumentExecutionResult();
|
|
7182
7183
|
return {
|
|
7183
7184
|
type: "window_supervisor",
|
|
7184
|
-
timings:
|
|
7185
|
-
start: startTime,
|
|
7186
|
-
end: Date.now(),
|
|
7187
|
-
},
|
|
7185
|
+
timings: executionResultFromJsenvSupervisor.timings,
|
|
7188
7186
|
executionResults:
|
|
7189
7187
|
executionResultFromJsenvSupervisor.executionResults,
|
|
7190
7188
|
};
|
|
7191
7189
|
},
|
|
7192
|
-
/* eslint-
|
|
7190
|
+
/* eslint-env node */
|
|
7193
7191
|
);
|
|
7194
7192
|
cb(returnValue);
|
|
7195
7193
|
} catch (e) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jsenv/test",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.4",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"@jsenv/github-check-run": "0.1.8",
|
|
44
44
|
"@jsenv/inspect": "2.0.0",
|
|
45
45
|
"@jsenv/log": "3.5.2",
|
|
46
|
-
"@jsenv/plugin-supervisor": "1.4.
|
|
46
|
+
"@jsenv/plugin-supervisor": "1.4.2",
|
|
47
47
|
"@jsenv/url-meta": "8.4.0",
|
|
48
48
|
"@jsenv/urls": "2.2.2",
|
|
49
49
|
"@jsenv/utils": "2.1.1",
|
|
@@ -308,6 +308,16 @@ export const executeTestPlan = async ({
|
|
|
308
308
|
`parallel.maxMemory must be a number or a percentage, got ${maxMemory}`,
|
|
309
309
|
);
|
|
310
310
|
}
|
|
311
|
+
|
|
312
|
+
const maxCpu = parallel.maxCpu;
|
|
313
|
+
if (typeof maxCpu === "string") {
|
|
314
|
+
const maxCpuAsRatio = assertPercentageAndConvertToRatio(maxCpu);
|
|
315
|
+
parallel.maxCpu = maxCpuAsRatio;
|
|
316
|
+
} else if (typeof maxCpu !== "number") {
|
|
317
|
+
throw new TypeError(
|
|
318
|
+
`parallel.maxCpu must be a number or a percentage, got ${maxCpu}`,
|
|
319
|
+
);
|
|
320
|
+
}
|
|
311
321
|
}
|
|
312
322
|
// testPlan
|
|
313
323
|
{
|
package/src/execution/run.js
CHANGED
|
@@ -38,14 +38,17 @@ export const run = async ({
|
|
|
38
38
|
allocatedMs = 0;
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
-
const
|
|
41
|
+
const timingsOrigin = Date.now();
|
|
42
|
+
const takeTiming = (ms = Date.now()) => {
|
|
43
|
+
return ms - timingsOrigin;
|
|
44
|
+
};
|
|
42
45
|
const result = {
|
|
43
46
|
status: "pending",
|
|
44
47
|
errors: [],
|
|
45
48
|
namespace: null,
|
|
46
49
|
consoleCalls: null,
|
|
47
50
|
timings: {
|
|
48
|
-
origin:
|
|
51
|
+
origin: timingsOrigin,
|
|
49
52
|
start: 0,
|
|
50
53
|
runtimeStart: null,
|
|
51
54
|
executionStart: null,
|
|
@@ -57,9 +60,6 @@ export const run = async ({
|
|
|
57
60
|
performance: null,
|
|
58
61
|
coverageFileUrl: null,
|
|
59
62
|
};
|
|
60
|
-
const takeTiming = (ms = Date.now()) => {
|
|
61
|
-
return ms - timingOrigin;
|
|
62
|
-
};
|
|
63
63
|
const onConsoleRef = { current: () => {} };
|
|
64
64
|
const stopSignal = { notify: () => {} };
|
|
65
65
|
const runtimeLabel = `${runtime.name}/${runtime.version}`;
|
|
@@ -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 = takeTiming();
|
|
135
|
+
result.timings.runtimeStart = Math.max(takeTiming(), 0);
|
|
136
136
|
},
|
|
137
137
|
onRuntimeStopped: () => {
|
|
138
138
|
if (runtimeStatus === "stopped") return; // ignore double calls
|
|
@@ -170,13 +170,10 @@ export const run = async ({
|
|
|
170
170
|
result.errors.push(errorProxy);
|
|
171
171
|
}
|
|
172
172
|
result.namespace = namespace;
|
|
173
|
-
if (timings) {
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
if (timings.end) {
|
|
178
|
-
result.timings.executionEnd = Math.max(takeTiming(timings.end), 0);
|
|
179
|
-
}
|
|
173
|
+
if (timings && typeof timings.start === "number") {
|
|
174
|
+
const diff = timings.origin - result.timings.origin;
|
|
175
|
+
result.timings.executionStart = timings.start + diff;
|
|
176
|
+
result.timings.executionEnd = timings.end + diff;
|
|
180
177
|
}
|
|
181
178
|
result.memoryUsage =
|
|
182
179
|
typeof memoryUsage === "number"
|
|
@@ -275,7 +275,7 @@ ${webServer.rootDirectoryUrl}`);
|
|
|
275
275
|
if (memoryUsageAPIAvailable) {
|
|
276
276
|
const getMemoryUsage = async () => {
|
|
277
277
|
const memoryUsage = await page.evaluate(
|
|
278
|
-
/* eslint-
|
|
278
|
+
/* eslint-env browser */
|
|
279
279
|
/* istanbul ignore next */
|
|
280
280
|
async () => {
|
|
281
281
|
const { performance } = window;
|
|
@@ -290,7 +290,7 @@ ${webServer.rootDirectoryUrl}`);
|
|
|
290
290
|
// https://developer.mozilla.org/en-US/docs/Web/API/Performance/measureUserAgentSpecificMemory
|
|
291
291
|
if (
|
|
292
292
|
performance.measureUserAgentSpecificMemory &&
|
|
293
|
-
crossOriginIsolated
|
|
293
|
+
window.crossOriginIsolated
|
|
294
294
|
) {
|
|
295
295
|
const memorySample =
|
|
296
296
|
await performance.measureUserAgentSpecificMemory();
|
|
@@ -298,7 +298,7 @@ ${webServer.rootDirectoryUrl}`);
|
|
|
298
298
|
}
|
|
299
299
|
return null;
|
|
300
300
|
},
|
|
301
|
-
/* eslint-
|
|
301
|
+
/* eslint-env node */
|
|
302
302
|
);
|
|
303
303
|
return memoryUsage;
|
|
304
304
|
};
|
|
@@ -317,7 +317,7 @@ ${webServer.rootDirectoryUrl}`);
|
|
|
317
317
|
if (collectPerformance) {
|
|
318
318
|
callbackSet.add(async () => {
|
|
319
319
|
const performance = await page.evaluate(
|
|
320
|
-
/* eslint-
|
|
320
|
+
/* eslint-env browser */
|
|
321
321
|
/* istanbul ignore next */
|
|
322
322
|
() => {
|
|
323
323
|
const { performance } = window;
|
|
@@ -336,7 +336,7 @@ ${webServer.rootDirectoryUrl}`);
|
|
|
336
336
|
measures,
|
|
337
337
|
};
|
|
338
338
|
},
|
|
339
|
-
/* eslint-
|
|
339
|
+
/* eslint-env node */
|
|
340
340
|
);
|
|
341
341
|
result.performance = performance;
|
|
342
342
|
});
|
|
@@ -409,15 +409,9 @@ ${webServer.rootDirectoryUrl}`);
|
|
|
409
409
|
try {
|
|
410
410
|
await page.goto(fileServerUrl, { timeout: 0 });
|
|
411
411
|
const returnValue = await page.evaluate(
|
|
412
|
-
/* eslint-
|
|
412
|
+
/* eslint-env browser */
|
|
413
413
|
/* istanbul ignore next */
|
|
414
414
|
async () => {
|
|
415
|
-
let startTime;
|
|
416
|
-
try {
|
|
417
|
-
startTime = window.performance.timing.navigationStart;
|
|
418
|
-
} catch (e) {
|
|
419
|
-
startTime = Date.now();
|
|
420
|
-
}
|
|
421
415
|
if (!window.__supervisor__) {
|
|
422
416
|
throw new Error("window.__supervisor__ is undefined");
|
|
423
417
|
}
|
|
@@ -425,15 +419,12 @@ ${webServer.rootDirectoryUrl}`);
|
|
|
425
419
|
await window.__supervisor__.getDocumentExecutionResult();
|
|
426
420
|
return {
|
|
427
421
|
type: "window_supervisor",
|
|
428
|
-
timings:
|
|
429
|
-
start: startTime,
|
|
430
|
-
end: Date.now(),
|
|
431
|
-
},
|
|
422
|
+
timings: executionResultFromJsenvSupervisor.timings,
|
|
432
423
|
executionResults:
|
|
433
424
|
executionResultFromJsenvSupervisor.executionResults,
|
|
434
425
|
};
|
|
435
426
|
},
|
|
436
|
-
/* eslint-
|
|
427
|
+
/* eslint-env node */
|
|
437
428
|
);
|
|
438
429
|
cb(returnValue);
|
|
439
430
|
} catch (e) {
|
|
@@ -17,6 +17,7 @@ export const executeUsingDynamicImport = async ({
|
|
|
17
17
|
}) => {
|
|
18
18
|
const result = {
|
|
19
19
|
timings: {
|
|
20
|
+
origin: Date.now(),
|
|
20
21
|
start: null,
|
|
21
22
|
end: null,
|
|
22
23
|
},
|
|
@@ -66,7 +67,7 @@ export const executeUsingDynamicImport = async ({
|
|
|
66
67
|
};
|
|
67
68
|
}
|
|
68
69
|
|
|
69
|
-
result.timings.start = Date.now();
|
|
70
|
+
result.timings.start = Date.now() - result.timings.origin;
|
|
70
71
|
try {
|
|
71
72
|
const namespace = await import(fileUrl);
|
|
72
73
|
const namespaceResolved = {};
|
|
@@ -82,7 +83,7 @@ export const executeUsingDynamicImport = async ({
|
|
|
82
83
|
result.status = "failed";
|
|
83
84
|
result.errors.push(createException(e, { rootDirectoryUrl }));
|
|
84
85
|
} finally {
|
|
85
|
-
result.timings.end = Date.now();
|
|
86
|
+
result.timings.end = Date.now() - result.timings.origin;
|
|
86
87
|
if (finalizeCoverage) {
|
|
87
88
|
await finalizeCoverage();
|
|
88
89
|
finalizeCoverage = null;
|