@playwright/test 1.34.0-alpha-may-2-2023 → 1.34.0-alpha-may-4-2023
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/lib/common/transform.js +6 -5
- package/lib/index.js +2 -1
- package/lib/reporters/merge.js +0 -2
- package/lib/worker/testInfo.js +26 -9
- package/lib/worker/workerMain.js +34 -17
- package/package.json +2 -2
package/lib/common/transform.js
CHANGED
|
@@ -37,16 +37,17 @@ function validateTsConfig(tsconfig) {
|
|
|
37
37
|
if (!tsconfig.tsConfigPath || !tsconfig.baseUrl) return;
|
|
38
38
|
// Make 'baseUrl' absolute, because it is relative to the tsconfig.json, not to cwd.
|
|
39
39
|
const absoluteBaseUrl = _path.default.resolve(_path.default.dirname(tsconfig.tsConfigPath), tsconfig.baseUrl);
|
|
40
|
-
const
|
|
41
|
-
|
|
42
|
-
|
|
40
|
+
const pathsFallback = [{
|
|
41
|
+
key: '*',
|
|
42
|
+
values: ['*']
|
|
43
|
+
}];
|
|
43
44
|
return {
|
|
44
45
|
allowJs: tsconfig.allowJs,
|
|
45
46
|
absoluteBaseUrl,
|
|
46
|
-
paths: Object.entries(paths).map(([key, values]) => ({
|
|
47
|
+
paths: Object.entries(tsconfig.paths || {}).map(([key, values]) => ({
|
|
47
48
|
key,
|
|
48
49
|
values
|
|
49
|
-
}))
|
|
50
|
+
})).concat(pathsFallback)
|
|
50
51
|
};
|
|
51
52
|
}
|
|
52
53
|
function loadAndValidateTsconfigForFile(file) {
|
package/lib/index.js
CHANGED
|
@@ -440,7 +440,8 @@ const playwrightFixtures = {
|
|
|
440
440
|
location: stackTrace === null || stackTrace === void 0 ? void 0 : stackTrace.frames[0],
|
|
441
441
|
category: 'pw:api',
|
|
442
442
|
title: apiCall,
|
|
443
|
-
wallTime
|
|
443
|
+
wallTime,
|
|
444
|
+
laxParent: true
|
|
444
445
|
});
|
|
445
446
|
userData.userObject = step;
|
|
446
447
|
},
|
package/lib/reporters/merge.js
CHANGED
|
@@ -84,8 +84,6 @@ function mergeEvents(shardReports) {
|
|
|
84
84
|
for (const reportJsonl of shardReports) {
|
|
85
85
|
const parsedEvents = parseEvents(reportJsonl);
|
|
86
86
|
for (const event of parsedEvents) {
|
|
87
|
-
// TODO: show remaining events?
|
|
88
|
-
if (event.method === 'onError') throw new Error('Error in shard');
|
|
89
87
|
if (event.method === 'onBegin') beginEvents.push(event);else if (event.method === 'onEnd') endEvents.push(event);else events.push(event);
|
|
90
88
|
}
|
|
91
89
|
}
|
package/lib/worker/testInfo.js
CHANGED
|
@@ -56,6 +56,7 @@ class TestInfoImpl {
|
|
|
56
56
|
this._lastStepId = 0;
|
|
57
57
|
this._projectInternal = void 0;
|
|
58
58
|
this._configInternal = void 0;
|
|
59
|
+
this._steps = [];
|
|
59
60
|
this.testId = void 0;
|
|
60
61
|
this.repeatEachIndex = void 0;
|
|
61
62
|
this.retry = void 0;
|
|
@@ -163,15 +164,28 @@ class TestInfoImpl {
|
|
|
163
164
|
}
|
|
164
165
|
_addStep(data) {
|
|
165
166
|
const stepId = `${data.category}@${data.title}@${++this._lastStepId}`;
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
167
|
+
let parentStep = _utils.zones.zoneData('stepZone', (0, _utils.captureRawStack)());
|
|
168
|
+
|
|
169
|
+
// For out-of-stack calls, locate the enclosing step.
|
|
170
|
+
let isLaxParent = false;
|
|
171
|
+
if (!parentStep && data.laxParent) {
|
|
172
|
+
const visit = step => {
|
|
173
|
+
// Never nest into under another lax element, it could be a series
|
|
174
|
+
// of no-reply actions, ala page.continue().
|
|
175
|
+
if (!step.endWallTime && step.category === data.category && !step.laxParent) parentStep = step;
|
|
176
|
+
step.steps.forEach(visit);
|
|
177
|
+
};
|
|
178
|
+
this._steps.forEach(visit);
|
|
179
|
+
isLaxParent = !!parentStep;
|
|
180
|
+
}
|
|
169
181
|
const step = {
|
|
170
182
|
stepId,
|
|
171
183
|
...data,
|
|
184
|
+
laxParent: isLaxParent,
|
|
185
|
+
steps: [],
|
|
172
186
|
complete: result => {
|
|
173
|
-
if (
|
|
174
|
-
|
|
187
|
+
if (step.endWallTime) return;
|
|
188
|
+
step.endWallTime = Date.now();
|
|
175
189
|
let error;
|
|
176
190
|
if (result.error instanceof Error) {
|
|
177
191
|
// Step function threw an error.
|
|
@@ -180,19 +194,22 @@ class TestInfoImpl {
|
|
|
180
194
|
// Internal API step reported an error.
|
|
181
195
|
error = result.error;
|
|
182
196
|
} else {
|
|
183
|
-
//
|
|
184
|
-
// Report step as failed to make it easier to spot.
|
|
185
|
-
error =
|
|
197
|
+
// One of the child steps failed (probably soft expect).
|
|
198
|
+
// Report this step as failed to make it easier to spot.
|
|
199
|
+
error = step.steps.map(s => s.error).find(e => !!e);
|
|
186
200
|
}
|
|
201
|
+
step.error = error;
|
|
187
202
|
const payload = {
|
|
188
203
|
testId: this._test.id,
|
|
189
204
|
stepId,
|
|
190
|
-
wallTime:
|
|
205
|
+
wallTime: step.endWallTime,
|
|
191
206
|
error
|
|
192
207
|
};
|
|
193
208
|
this._onStepEnd(payload);
|
|
194
209
|
}
|
|
195
210
|
};
|
|
211
|
+
const parentStepList = parentStep ? parentStep.steps : this._steps;
|
|
212
|
+
parentStepList.push(step);
|
|
196
213
|
const hasLocation = data.location && !data.location.file.includes('@playwright');
|
|
197
214
|
// Sanitize location that comes from user land, it might have extra properties.
|
|
198
215
|
const location = data.location && hasLocation ? {
|
package/lib/worker/workerMain.js
CHANGED
|
@@ -391,18 +391,8 @@ class WorkerMain extends _process.ProcessRunner {
|
|
|
391
391
|
firstAfterHooksError = firstAfterHooksError || afterEachError;
|
|
392
392
|
}
|
|
393
393
|
|
|
394
|
-
// Run "afterAll" hooks for suites that are not shared with the next test.
|
|
395
|
-
// In case of failure the worker will be stopped and we have to make sure that afterAll
|
|
396
|
-
// hooks run before test fixtures teardown.
|
|
397
|
-
for (const suite of reversedSuites) {
|
|
398
|
-
if (!nextSuites.has(suite) || testInfo._isFailure()) {
|
|
399
|
-
const afterAllError = await this._runAfterAllHooksForSuite(suite, testInfo);
|
|
400
|
-
firstAfterHooksError = firstAfterHooksError || afterAllError;
|
|
401
|
-
}
|
|
402
|
-
}
|
|
403
|
-
|
|
404
394
|
// Teardown test-scoped fixtures. Attribute to 'test' so that users understand
|
|
405
|
-
// they should probably
|
|
395
|
+
// they should probably increase the test timeout to fix this issue.
|
|
406
396
|
testInfo._timeoutManager.setCurrentRunnable({
|
|
407
397
|
type: 'test',
|
|
408
398
|
slot: afterHooksSlot
|
|
@@ -411,6 +401,16 @@ class WorkerMain extends _process.ProcessRunner {
|
|
|
411
401
|
const testScopeError = await testInfo._runAndFailOnError(() => this._fixtureRunner.teardownScope('test', testInfo._timeoutManager));
|
|
412
402
|
(0, _util2.debugTest)(`tearing down test scope finished`);
|
|
413
403
|
firstAfterHooksError = firstAfterHooksError || testScopeError;
|
|
404
|
+
|
|
405
|
+
// Run "afterAll" hooks for suites that are not shared with the next test.
|
|
406
|
+
// In case of failure the worker will be stopped and we have to make sure that afterAll
|
|
407
|
+
// hooks run before worker fixtures teardown.
|
|
408
|
+
for (const suite of reversedSuites) {
|
|
409
|
+
if (!nextSuites.has(suite) || testInfo._isFailure()) {
|
|
410
|
+
const afterAllError = await this._runAfterAllHooksForSuite(suite, testInfo);
|
|
411
|
+
firstAfterHooksError = firstAfterHooksError || afterAllError;
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
414
|
});
|
|
415
415
|
if (testInfo._isFailure()) this._isStopped = true;
|
|
416
416
|
if (this._isStopped) {
|
|
@@ -421,10 +421,6 @@ class WorkerMain extends _process.ProcessRunner {
|
|
|
421
421
|
// Give it more time for the full cleanup.
|
|
422
422
|
await testInfo._runWithTimeout(async () => {
|
|
423
423
|
(0, _util2.debugTest)(`running full cleanup after the failure`);
|
|
424
|
-
for (const suite of reversedSuites) {
|
|
425
|
-
const afterAllError = await this._runAfterAllHooksForSuite(suite, testInfo);
|
|
426
|
-
firstAfterHooksError = firstAfterHooksError || afterAllError;
|
|
427
|
-
}
|
|
428
424
|
const teardownSlot = {
|
|
429
425
|
timeout: this._project.project.timeout,
|
|
430
426
|
elapsed: 0
|
|
@@ -438,6 +434,11 @@ class WorkerMain extends _process.ProcessRunner {
|
|
|
438
434
|
const testScopeError = await testInfo._runAndFailOnError(() => this._fixtureRunner.teardownScope('test', testInfo._timeoutManager));
|
|
439
435
|
(0, _util2.debugTest)(`tearing down test scope finished`);
|
|
440
436
|
firstAfterHooksError = firstAfterHooksError || testScopeError;
|
|
437
|
+
for (const suite of reversedSuites) {
|
|
438
|
+
const afterAllError = await this._runAfterAllHooksForSuite(suite, testInfo);
|
|
439
|
+
firstAfterHooksError = firstAfterHooksError || afterAllError;
|
|
440
|
+
}
|
|
441
|
+
|
|
441
442
|
// Attribute to 'teardown' because worker fixtures are not perceived as a part of a test.
|
|
442
443
|
testInfo._timeoutManager.setCurrentRunnable({
|
|
443
444
|
type: 'teardown',
|
|
@@ -509,7 +510,15 @@ class WorkerMain extends _process.ProcessRunner {
|
|
|
509
510
|
category: 'hook',
|
|
510
511
|
title: `${hook.type} hook`,
|
|
511
512
|
location: hook.location
|
|
512
|
-
}, () =>
|
|
513
|
+
}, async () => {
|
|
514
|
+
try {
|
|
515
|
+
await this._fixtureRunner.resolveParametersAndRunFunction(hook.fn, testInfo, 'all-hooks-only');
|
|
516
|
+
} finally {
|
|
517
|
+
// Each beforeAll hook has its own scope for test fixtures. Attribute to the same runnable and timeSlot.
|
|
518
|
+
// Note: we must teardown even after beforeAll fails, because we'll run more beforeAlls.
|
|
519
|
+
await this._fixtureRunner.teardownScope('test', testInfo._timeoutManager);
|
|
520
|
+
}
|
|
521
|
+
});
|
|
513
522
|
} catch (e) {
|
|
514
523
|
// Always run all the hooks, and capture the first error.
|
|
515
524
|
beforeAllError = beforeAllError || e;
|
|
@@ -540,7 +549,15 @@ class WorkerMain extends _process.ProcessRunner {
|
|
|
540
549
|
category: 'hook',
|
|
541
550
|
title: `${hook.type} hook`,
|
|
542
551
|
location: hook.location
|
|
543
|
-
}, () =>
|
|
552
|
+
}, async () => {
|
|
553
|
+
try {
|
|
554
|
+
await this._fixtureRunner.resolveParametersAndRunFunction(hook.fn, testInfo, 'all-hooks-only');
|
|
555
|
+
} finally {
|
|
556
|
+
// Each afterAll hook has its own scope for test fixtures. Attribute to the same runnable and timeSlot.
|
|
557
|
+
// Note: we must teardown even after afterAll fails, because we'll run more afterAlls.
|
|
558
|
+
await this._fixtureRunner.teardownScope('test', testInfo._timeoutManager);
|
|
559
|
+
}
|
|
560
|
+
});
|
|
544
561
|
});
|
|
545
562
|
firstError = firstError || afterAllError;
|
|
546
563
|
(0, _util2.debugTest)(`${hook.type} hook at "${(0, _util2.formatLocation)(hook.location)}" finished`);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@playwright/test",
|
|
3
|
-
"version": "1.34.0-alpha-may-
|
|
3
|
+
"version": "1.34.0-alpha-may-4-2023",
|
|
4
4
|
"description": "A high-level API to automate web browsers",
|
|
5
5
|
"repository": "github:Microsoft/playwright",
|
|
6
6
|
"homepage": "https://playwright.dev",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"license": "Apache-2.0",
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"@types/node": "*",
|
|
39
|
-
"playwright-core": "1.34.0-alpha-may-
|
|
39
|
+
"playwright-core": "1.34.0-alpha-may-4-2023"
|
|
40
40
|
},
|
|
41
41
|
"optionalDependencies": {
|
|
42
42
|
"fsevents": "2.3.2"
|