@jsenv/test 3.0.3 → 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 +18 -31
- package/package.json +2 -2
- package/src/execution/execute_test_plan.js +0 -1
- 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"
|
|
@@ -6434,7 +6431,6 @@ To fix this warning:
|
|
|
6434
6431
|
promises.push(promise);
|
|
6435
6432
|
}
|
|
6436
6433
|
|
|
6437
|
-
console.log(cpuUsage.overall.active, parallel.maxCpu);
|
|
6438
6434
|
if (cpuUsage.overall.active > parallel.maxCpu) {
|
|
6439
6435
|
// retry after Xms in case cpu usage decreases
|
|
6440
6436
|
const promise = (async () => {
|
|
@@ -7042,7 +7038,7 @@ ${webServer.rootDirectoryUrl}`);
|
|
|
7042
7038
|
if (memoryUsageAPIAvailable) {
|
|
7043
7039
|
const getMemoryUsage = async () => {
|
|
7044
7040
|
const memoryUsage = await page.evaluate(
|
|
7045
|
-
/* eslint-
|
|
7041
|
+
/* eslint-env browser */
|
|
7046
7042
|
/* istanbul ignore next */
|
|
7047
7043
|
async () => {
|
|
7048
7044
|
const { performance } = window;
|
|
@@ -7057,7 +7053,7 @@ ${webServer.rootDirectoryUrl}`);
|
|
|
7057
7053
|
// https://developer.mozilla.org/en-US/docs/Web/API/Performance/measureUserAgentSpecificMemory
|
|
7058
7054
|
if (
|
|
7059
7055
|
performance.measureUserAgentSpecificMemory &&
|
|
7060
|
-
crossOriginIsolated
|
|
7056
|
+
window.crossOriginIsolated
|
|
7061
7057
|
) {
|
|
7062
7058
|
const memorySample =
|
|
7063
7059
|
await performance.measureUserAgentSpecificMemory();
|
|
@@ -7065,7 +7061,7 @@ ${webServer.rootDirectoryUrl}`);
|
|
|
7065
7061
|
}
|
|
7066
7062
|
return null;
|
|
7067
7063
|
},
|
|
7068
|
-
/* eslint-
|
|
7064
|
+
/* eslint-env node */
|
|
7069
7065
|
);
|
|
7070
7066
|
return memoryUsage;
|
|
7071
7067
|
};
|
|
@@ -7084,7 +7080,7 @@ ${webServer.rootDirectoryUrl}`);
|
|
|
7084
7080
|
if (collectPerformance) {
|
|
7085
7081
|
callbackSet.add(async () => {
|
|
7086
7082
|
const performance = await page.evaluate(
|
|
7087
|
-
/* eslint-
|
|
7083
|
+
/* eslint-env browser */
|
|
7088
7084
|
/* istanbul ignore next */
|
|
7089
7085
|
() => {
|
|
7090
7086
|
const { performance } = window;
|
|
@@ -7103,7 +7099,7 @@ ${webServer.rootDirectoryUrl}`);
|
|
|
7103
7099
|
measures,
|
|
7104
7100
|
};
|
|
7105
7101
|
},
|
|
7106
|
-
/* eslint-
|
|
7102
|
+
/* eslint-env node */
|
|
7107
7103
|
);
|
|
7108
7104
|
result.performance = performance;
|
|
7109
7105
|
});
|
|
@@ -7176,15 +7172,9 @@ ${webServer.rootDirectoryUrl}`);
|
|
|
7176
7172
|
try {
|
|
7177
7173
|
await page.goto(fileServerUrl, { timeout: 0 });
|
|
7178
7174
|
const returnValue = await page.evaluate(
|
|
7179
|
-
/* eslint-
|
|
7175
|
+
/* eslint-env browser */
|
|
7180
7176
|
/* istanbul ignore next */
|
|
7181
7177
|
async () => {
|
|
7182
|
-
let startTime;
|
|
7183
|
-
try {
|
|
7184
|
-
startTime = window.performance.timing.navigationStart;
|
|
7185
|
-
} catch (e) {
|
|
7186
|
-
startTime = Date.now();
|
|
7187
|
-
}
|
|
7188
7178
|
if (!window.__supervisor__) {
|
|
7189
7179
|
throw new Error("window.__supervisor__ is undefined");
|
|
7190
7180
|
}
|
|
@@ -7192,15 +7182,12 @@ ${webServer.rootDirectoryUrl}`);
|
|
|
7192
7182
|
await window.__supervisor__.getDocumentExecutionResult();
|
|
7193
7183
|
return {
|
|
7194
7184
|
type: "window_supervisor",
|
|
7195
|
-
timings:
|
|
7196
|
-
start: startTime,
|
|
7197
|
-
end: Date.now(),
|
|
7198
|
-
},
|
|
7185
|
+
timings: executionResultFromJsenvSupervisor.timings,
|
|
7199
7186
|
executionResults:
|
|
7200
7187
|
executionResultFromJsenvSupervisor.executionResults,
|
|
7201
7188
|
};
|
|
7202
7189
|
},
|
|
7203
|
-
/* eslint-
|
|
7190
|
+
/* eslint-env node */
|
|
7204
7191
|
);
|
|
7205
7192
|
cb(returnValue);
|
|
7206
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",
|
|
@@ -853,7 +853,6 @@ To fix this warning:
|
|
|
853
853
|
promises.push(promise);
|
|
854
854
|
}
|
|
855
855
|
|
|
856
|
-
console.log(cpuUsage.overall.active, parallel.maxCpu);
|
|
857
856
|
if (cpuUsage.overall.active > parallel.maxCpu) {
|
|
858
857
|
// retry after Xms in case cpu usage decreases
|
|
859
858
|
const promise = (async () => {
|
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;
|