@playwright/test 1.34.0-alpha-may-1-2023 → 1.34.0-alpha-may-2-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/globals.js +9 -0
- package/lib/index.js +60 -26
- package/lib/matchers/expect.js +2 -0
- package/lib/reporters/junit.js +16 -77
- package/lib/reporters/merge.js +4 -1
- package/lib/reporters/teleEmitter.js +1 -0
- package/lib/runner/dispatcher.js +4 -1
- package/lib/third_party/tsconfig-loader.js +4 -0
- package/lib/worker/testInfo.js +0 -3
- package/lib/worker/workerMain.js +16 -24
- package/package.json +2 -2
package/lib/common/globals.js
CHANGED
|
@@ -6,11 +6,13 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.currentConfig = currentConfig;
|
|
7
7
|
exports.currentExpectTimeout = currentExpectTimeout;
|
|
8
8
|
exports.currentTestInfo = currentTestInfo;
|
|
9
|
+
exports.currentTestInstrumentation = currentTestInstrumentation;
|
|
9
10
|
exports.currentlyLoadingFileSuite = currentlyLoadingFileSuite;
|
|
10
11
|
exports.isWorkerProcess = isWorkerProcess;
|
|
11
12
|
exports.setCurrentConfig = setCurrentConfig;
|
|
12
13
|
exports.setCurrentExpectConfigureTimeout = setCurrentExpectConfigureTimeout;
|
|
13
14
|
exports.setCurrentTestInfo = setCurrentTestInfo;
|
|
15
|
+
exports.setCurrentTestInstrumentation = setCurrentTestInstrumentation;
|
|
14
16
|
exports.setCurrentlyLoadingFileSuite = setCurrentlyLoadingFileSuite;
|
|
15
17
|
exports.setIsWorkerProcess = setIsWorkerProcess;
|
|
16
18
|
/**
|
|
@@ -69,4 +71,11 @@ function setCurrentConfig(config) {
|
|
|
69
71
|
}
|
|
70
72
|
function currentConfig() {
|
|
71
73
|
return currentConfigValue;
|
|
74
|
+
}
|
|
75
|
+
let testInstrumentation;
|
|
76
|
+
function setCurrentTestInstrumentation(instrumentation) {
|
|
77
|
+
testInstrumentation = instrumentation;
|
|
78
|
+
}
|
|
79
|
+
function currentTestInstrumentation() {
|
|
80
|
+
return testInstrumentation;
|
|
72
81
|
}
|
package/lib/index.js
CHANGED
|
@@ -24,6 +24,7 @@ var playwrightLibrary = _interopRequireWildcard(require("playwright-core"));
|
|
|
24
24
|
var _utils = require("playwright-core/lib/utils");
|
|
25
25
|
var _testType = require("./common/testType");
|
|
26
26
|
var _folders = require("./isomorphic/folders");
|
|
27
|
+
var _globals = require("./common/globals");
|
|
27
28
|
var _expect = require("./matchers/expect");
|
|
28
29
|
var _store = require("./store");
|
|
29
30
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
@@ -427,15 +428,15 @@ const playwrightFixtures = {
|
|
|
427
428
|
_artifactsDir,
|
|
428
429
|
trace,
|
|
429
430
|
screenshot
|
|
430
|
-
}, use
|
|
431
|
-
|
|
432
|
-
const testInfoImpl = testInfo;
|
|
431
|
+
}, use) => {
|
|
432
|
+
let artifactsRecorder;
|
|
433
433
|
const csiListener = {
|
|
434
434
|
onApiCallBegin: (apiCall, stackTrace, wallTime, userData) => {
|
|
435
|
-
|
|
435
|
+
const testInfo = (0, _globals.currentTestInfo)();
|
|
436
|
+
if (!testInfo || apiCall.startsWith('expect.') || apiCall.includes('setTestIdAttribute')) return {
|
|
436
437
|
userObject: null
|
|
437
438
|
};
|
|
438
|
-
const step =
|
|
439
|
+
const step = testInfo._addStep({
|
|
439
440
|
location: stackTrace === null || stackTrace === void 0 ? void 0 : stackTrace.frames[0],
|
|
440
441
|
category: 'pw:api',
|
|
441
442
|
title: apiCall,
|
|
@@ -450,35 +451,71 @@ const playwrightFixtures = {
|
|
|
450
451
|
});
|
|
451
452
|
},
|
|
452
453
|
onWillPause: () => {
|
|
453
|
-
|
|
454
|
+
var _currentTestInfo;
|
|
455
|
+
(_currentTestInfo = (0, _globals.currentTestInfo)()) === null || _currentTestInfo === void 0 ? void 0 : _currentTestInfo.setTimeout(0);
|
|
454
456
|
},
|
|
455
457
|
onDidCreateBrowserContext: async context => {
|
|
456
|
-
|
|
457
|
-
|
|
458
|
+
var _artifactsRecorder;
|
|
459
|
+
await ((_artifactsRecorder = artifactsRecorder) === null || _artifactsRecorder === void 0 ? void 0 : _artifactsRecorder.didCreateBrowserContext(context));
|
|
460
|
+
const testInfo = (0, _globals.currentTestInfo)();
|
|
461
|
+
if (testInfo) attachConnectedHeaderIfNeeded(testInfo, context.browser());
|
|
458
462
|
},
|
|
459
463
|
onDidCreateRequestContext: async context => {
|
|
460
|
-
|
|
464
|
+
var _artifactsRecorder2;
|
|
465
|
+
await ((_artifactsRecorder2 = artifactsRecorder) === null || _artifactsRecorder2 === void 0 ? void 0 : _artifactsRecorder2.didCreateRequestContext(context));
|
|
461
466
|
},
|
|
462
467
|
onWillCloseBrowserContext: async context => {
|
|
463
|
-
|
|
468
|
+
var _artifactsRecorder3;
|
|
469
|
+
await ((_artifactsRecorder3 = artifactsRecorder) === null || _artifactsRecorder3 === void 0 ? void 0 : _artifactsRecorder3.willCloseBrowserContext(context));
|
|
464
470
|
},
|
|
465
471
|
onWillCloseRequestContext: async context => {
|
|
466
|
-
|
|
472
|
+
var _artifactsRecorder4;
|
|
473
|
+
await ((_artifactsRecorder4 = artifactsRecorder) === null || _artifactsRecorder4 === void 0 ? void 0 : _artifactsRecorder4.willCloseRequestContext(context));
|
|
467
474
|
}
|
|
468
475
|
};
|
|
476
|
+
const willStartTest = async testInfo => {
|
|
477
|
+
artifactsRecorder = new ArtifactsRecorder(playwright, _artifactsDir(), trace, screenshot);
|
|
478
|
+
await artifactsRecorder.willStartTest(testInfo);
|
|
479
|
+
};
|
|
480
|
+
const didFinishTestFunction = async testInfo => {
|
|
481
|
+
var _artifactsRecorder5;
|
|
482
|
+
await ((_artifactsRecorder5 = artifactsRecorder) === null || _artifactsRecorder5 === void 0 ? void 0 : _artifactsRecorder5.didFinishTestFunction());
|
|
483
|
+
};
|
|
484
|
+
const didFinishTest = async testInfo => {
|
|
485
|
+
var _artifactsRecorder6;
|
|
486
|
+
await ((_artifactsRecorder6 = artifactsRecorder) === null || _artifactsRecorder6 === void 0 ? void 0 : _artifactsRecorder6.didFinishTest());
|
|
487
|
+
artifactsRecorder = undefined;
|
|
488
|
+
};
|
|
489
|
+
|
|
490
|
+
// 1. Setup instrumentation.
|
|
491
|
+
const clientInstrumentation = playwright._instrumentation;
|
|
492
|
+
clientInstrumentation.addListener(csiListener);
|
|
493
|
+
(0, _globals.setCurrentTestInstrumentation)({
|
|
494
|
+
willStartTest,
|
|
495
|
+
didFinishTestFunction,
|
|
496
|
+
didFinishTest
|
|
497
|
+
});
|
|
469
498
|
|
|
470
|
-
//
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
499
|
+
// 2. Setup for the first test in the worker.
|
|
500
|
+
{
|
|
501
|
+
const firstTestInfo = (0, _globals.currentTestInfo)();
|
|
502
|
+
if (firstTestInfo) await willStartTest(firstTestInfo);
|
|
503
|
+
}
|
|
474
504
|
|
|
475
505
|
// 2. Run the test.
|
|
476
506
|
await use();
|
|
477
507
|
|
|
478
|
-
// 3.
|
|
479
|
-
|
|
480
|
-
|
|
508
|
+
// 3. Teardown for the last test in the worker.
|
|
509
|
+
{
|
|
510
|
+
const lastTestInfo = (0, _globals.currentTestInfo)();
|
|
511
|
+
if (lastTestInfo) await didFinishTest(lastTestInfo);
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
// 4. Cleanup instrumentation.
|
|
515
|
+
(0, _globals.setCurrentTestInstrumentation)(undefined);
|
|
516
|
+
clientInstrumentation.removeListener(csiListener);
|
|
481
517
|
}, {
|
|
518
|
+
scope: 'worker',
|
|
482
519
|
auto: 'all-hooks-included',
|
|
483
520
|
_title: 'trace recording'
|
|
484
521
|
}],
|
|
@@ -681,7 +718,6 @@ class ArtifactsRecorder {
|
|
|
681
718
|
this._traceOrdinal = 0;
|
|
682
719
|
this._screenshottedSymbol = void 0;
|
|
683
720
|
this._startedCollectingArtifacts = void 0;
|
|
684
|
-
this._screenshotOnTestFailureBound = void 0;
|
|
685
721
|
this._playwright = playwright;
|
|
686
722
|
this._artifactsDir = artifactsDir;
|
|
687
723
|
this._screenshotMode = normalizeScreenshotMode(screenshot);
|
|
@@ -699,9 +735,8 @@ class ArtifactsRecorder {
|
|
|
699
735
|
};
|
|
700
736
|
this._screenshottedSymbol = Symbol('screenshotted');
|
|
701
737
|
this._startedCollectingArtifacts = Symbol('startedCollectingArtifacts');
|
|
702
|
-
this._screenshotOnTestFailureBound = this._screenshotOnTestFailure.bind(this);
|
|
703
738
|
}
|
|
704
|
-
async
|
|
739
|
+
async willStartTest(testInfo) {
|
|
705
740
|
this._testInfo = testInfo;
|
|
706
741
|
this._captureTrace = shouldCaptureTrace(this._traceMode, testInfo) && !process.env.PW_TEST_DISABLE_TRACING;
|
|
707
742
|
|
|
@@ -718,9 +753,6 @@ class ArtifactsRecorder {
|
|
|
718
753
|
const existingApiRequests = Array.from(this._playwright.request._contexts);
|
|
719
754
|
await Promise.all(existingApiRequests.map(c => this.didCreateRequestContext(c)));
|
|
720
755
|
}
|
|
721
|
-
|
|
722
|
-
// Setup "screenshot on failure" callback.
|
|
723
|
-
if (this._screenshotMode === 'on' || this._screenshotMode === 'only-on-failure') testInfo._onTestFailureImmediateCallbacks.set(this._screenshotOnTestFailureBound, 'Screenshot on failure');
|
|
724
756
|
}
|
|
725
757
|
async didCreateBrowserContext(context) {
|
|
726
758
|
await this._startTraceChunkOnContextCreation(context.tracing);
|
|
@@ -744,12 +776,14 @@ class ArtifactsRecorder {
|
|
|
744
776
|
const tracing = context._tracing;
|
|
745
777
|
await this._stopTracing(tracing, context[kStartedContextTearDown]);
|
|
746
778
|
}
|
|
747
|
-
async
|
|
779
|
+
async didFinishTestFunction() {
|
|
780
|
+
if (this._testInfo._isFailure() && (this._screenshotMode === 'on' || this._screenshotMode === 'only-on-failure')) await this._screenshotOnTestFailure();
|
|
781
|
+
}
|
|
782
|
+
async didFinishTest() {
|
|
748
783
|
const captureScreenshots = this._screenshotMode === 'on' || this._screenshotMode === 'only-on-failure' && this._testInfo.status !== this._testInfo.expectedStatus;
|
|
749
784
|
const leftoverContexts = [];
|
|
750
785
|
for (const browserType of [this._playwright.chromium, this._playwright.firefox, this._playwright.webkit]) leftoverContexts.push(...browserType._contexts);
|
|
751
786
|
const leftoverApiRequests = Array.from(this._playwright.request._contexts);
|
|
752
|
-
this._testInfo._onTestFailureImmediateCallbacks.delete(this._screenshotOnTestFailureBound);
|
|
753
787
|
|
|
754
788
|
// Collect traces/screenshots for remaining contexts.
|
|
755
789
|
await Promise.all(leftoverContexts.map(async context => {
|
package/lib/matchers/expect.js
CHANGED
|
@@ -26,6 +26,8 @@ var _expectBundle = require("../common/expectBundle");
|
|
|
26
26
|
* limitations under the License.
|
|
27
27
|
*/
|
|
28
28
|
|
|
29
|
+
// from expect/build/types
|
|
30
|
+
|
|
29
31
|
// #region
|
|
30
32
|
// Mirrored from https://github.com/facebook/jest/blob/f13abff8df9a0e1148baf3584bcde6d1b479edc7/packages/expect/src/print.ts
|
|
31
33
|
/**
|
package/lib/reporters/junit.js
CHANGED
|
@@ -36,14 +36,8 @@ class JUnitReporter {
|
|
|
36
36
|
this.totalSkipped = 0;
|
|
37
37
|
this.outputFile = void 0;
|
|
38
38
|
this.stripANSIControlSequences = false;
|
|
39
|
-
this.embedAnnotationsAsProperties = false;
|
|
40
|
-
this.textContentAnnotations = void 0;
|
|
41
|
-
this.embedAttachmentsAsProperty = void 0;
|
|
42
39
|
this.outputFile = options.outputFile || reportOutputNameFromEnv();
|
|
43
40
|
this.stripANSIControlSequences = options.stripANSIControlSequences || false;
|
|
44
|
-
this.embedAnnotationsAsProperties = options.embedAnnotationsAsProperties || false;
|
|
45
|
-
this.textContentAnnotations = options.textContentAnnotations || [];
|
|
46
|
-
this.embedAttachmentsAsProperty = options.embedAttachmentsAsProperty;
|
|
47
41
|
}
|
|
48
42
|
printsToStdio() {
|
|
49
43
|
return !this.outputFile;
|
|
@@ -121,7 +115,7 @@ class JUnitReporter {
|
|
|
121
115
|
return entry;
|
|
122
116
|
}
|
|
123
117
|
_addTestCase(suiteName, test, entries) {
|
|
124
|
-
var _properties$
|
|
118
|
+
var _properties$children2;
|
|
125
119
|
const entry = {
|
|
126
120
|
name: 'testcase',
|
|
127
121
|
attributes: {
|
|
@@ -142,72 +136,18 @@ class JUnitReporter {
|
|
|
142
136
|
name: 'properties',
|
|
143
137
|
children: []
|
|
144
138
|
};
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
if ((_this$textContentAnno = this.textContentAnnotations) !== null && _this$textContentAnno !== void 0 && _this$textContentAnno.includes(annotation.type)) {
|
|
149
|
-
var _properties$children;
|
|
150
|
-
const property = {
|
|
151
|
-
name: 'property',
|
|
152
|
-
attributes: {
|
|
153
|
-
name: annotation.type
|
|
154
|
-
},
|
|
155
|
-
text: annotation.description
|
|
156
|
-
};
|
|
157
|
-
(_properties$children = properties.children) === null || _properties$children === void 0 ? void 0 : _properties$children.push(property);
|
|
158
|
-
} else {
|
|
159
|
-
var _properties$children2;
|
|
160
|
-
const property = {
|
|
161
|
-
name: 'property',
|
|
162
|
-
attributes: {
|
|
163
|
-
name: annotation.type,
|
|
164
|
-
value: annotation !== null && annotation !== void 0 && annotation.description ? annotation.description : ''
|
|
165
|
-
}
|
|
166
|
-
};
|
|
167
|
-
(_properties$children2 = properties.children) === null || _properties$children2 === void 0 ? void 0 : _properties$children2.push(property);
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
const systemErr = [];
|
|
172
|
-
// attachments are optionally embed as base64 encoded content on inner <item> elements
|
|
173
|
-
if (this.embedAttachmentsAsProperty) {
|
|
174
|
-
var _properties$children3;
|
|
175
|
-
const evidence = {
|
|
139
|
+
for (const annotation of test.annotations) {
|
|
140
|
+
var _properties$children;
|
|
141
|
+
const property = {
|
|
176
142
|
name: 'property',
|
|
177
143
|
attributes: {
|
|
178
|
-
name:
|
|
179
|
-
|
|
180
|
-
children: []
|
|
181
|
-
};
|
|
182
|
-
for (const result of test.results) {
|
|
183
|
-
for (const attachment of result.attachments) {
|
|
184
|
-
let contents;
|
|
185
|
-
if (attachment.body) {
|
|
186
|
-
contents = attachment.body.toString('base64');
|
|
187
|
-
} else {
|
|
188
|
-
if (!attachment.path) continue;
|
|
189
|
-
try {
|
|
190
|
-
if (_fs.default.existsSync(attachment.path)) contents = _fs.default.readFileSync(attachment.path, {
|
|
191
|
-
encoding: 'base64'
|
|
192
|
-
});else systemErr.push(`\nWarning: attachment ${attachment.path} is missing`);
|
|
193
|
-
} catch (e) {}
|
|
194
|
-
}
|
|
195
|
-
if (contents) {
|
|
196
|
-
var _evidence$children;
|
|
197
|
-
const item = {
|
|
198
|
-
name: 'item',
|
|
199
|
-
attributes: {
|
|
200
|
-
name: attachment.name
|
|
201
|
-
},
|
|
202
|
-
text: contents
|
|
203
|
-
};
|
|
204
|
-
(_evidence$children = evidence.children) === null || _evidence$children === void 0 ? void 0 : _evidence$children.push(item);
|
|
205
|
-
}
|
|
144
|
+
name: annotation.type,
|
|
145
|
+
value: annotation !== null && annotation !== void 0 && annotation.description ? annotation.description : ''
|
|
206
146
|
}
|
|
207
|
-
}
|
|
208
|
-
(_properties$
|
|
147
|
+
};
|
|
148
|
+
(_properties$children = properties.children) === null || _properties$children === void 0 ? void 0 : _properties$children.push(property);
|
|
209
149
|
}
|
|
210
|
-
if ((_properties$
|
|
150
|
+
if ((_properties$children2 = properties.children) !== null && _properties$children2 !== void 0 && _properties$children2.length) entry.children.push(properties);
|
|
211
151
|
if (test.outcome() === 'skipped') {
|
|
212
152
|
entry.children.push({
|
|
213
153
|
name: 'skipped'
|
|
@@ -225,17 +165,16 @@ class JUnitReporter {
|
|
|
225
165
|
});
|
|
226
166
|
}
|
|
227
167
|
const systemOut = [];
|
|
168
|
+
const systemErr = [];
|
|
228
169
|
for (const result of test.results) {
|
|
229
170
|
systemOut.push(...result.stdout.map(item => item.toString()));
|
|
230
171
|
systemErr.push(...result.stderr.map(item => item.toString()));
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
} catch (e) {}
|
|
238
|
-
}
|
|
172
|
+
for (const attachment of result.attachments) {
|
|
173
|
+
if (!attachment.path) continue;
|
|
174
|
+
try {
|
|
175
|
+
const attachmentPath = _path.default.relative(this.config.rootDir, attachment.path);
|
|
176
|
+
if (_fs.default.existsSync(attachment.path)) systemOut.push(`\n[[ATTACHMENT|${attachmentPath}]]\n`);else systemErr.push(`\nWarning: attachment ${attachmentPath} is missing`);
|
|
177
|
+
} catch (e) {}
|
|
239
178
|
}
|
|
240
179
|
}
|
|
241
180
|
// Note: it is important to only produce a single system-out/system-err entry
|
package/lib/reporters/merge.js
CHANGED
|
@@ -89,7 +89,10 @@ function mergeEvents(shardReports) {
|
|
|
89
89
|
if (event.method === 'onBegin') beginEvents.push(event);else if (event.method === 'onEnd') endEvents.push(event);else events.push(event);
|
|
90
90
|
}
|
|
91
91
|
}
|
|
92
|
-
return [mergeBeginEvents(beginEvents), ...events, mergeEndEvents(endEvents)
|
|
92
|
+
return [mergeBeginEvents(beginEvents), ...events, mergeEndEvents(endEvents), {
|
|
93
|
+
method: 'onExit',
|
|
94
|
+
params: undefined
|
|
95
|
+
}];
|
|
93
96
|
}
|
|
94
97
|
function mergeBeginEvents(beginEvents) {
|
|
95
98
|
if (!beginEvents.length) throw new Error('No begin events found');
|
package/lib/runner/dispatcher.js
CHANGED
|
@@ -186,7 +186,9 @@ class Dispatcher {
|
|
|
186
186
|
};
|
|
187
187
|
const remainingByTestId = new Map(testGroup.tests.map(e => [e.id, e]));
|
|
188
188
|
const failedTestIds = new Set();
|
|
189
|
+
let runningTest = false;
|
|
189
190
|
const onTestBegin = params => {
|
|
191
|
+
runningTest = true;
|
|
190
192
|
const data = this._testById.get(params.testId);
|
|
191
193
|
const result = data.test._appendTestResult();
|
|
192
194
|
data.resultByWorkerIndex.set(worker.workerIndex, {
|
|
@@ -201,6 +203,7 @@ class Dispatcher {
|
|
|
201
203
|
};
|
|
202
204
|
worker.addListener('testBegin', onTestBegin);
|
|
203
205
|
const onTestEnd = params => {
|
|
206
|
+
runningTest = false;
|
|
204
207
|
remainingByTestId.delete(params.testId);
|
|
205
208
|
if (this._hasReachedMaxFailures()) {
|
|
206
209
|
// Do not show more than one error to avoid confusion, but report
|
|
@@ -313,7 +316,7 @@ class Dispatcher {
|
|
|
313
316
|
if (runData) {
|
|
314
317
|
result = runData.result;
|
|
315
318
|
} else {
|
|
316
|
-
if (onlyStartedTests) return true;
|
|
319
|
+
if (onlyStartedTests && runningTest) return true;
|
|
317
320
|
result = data.test._appendTestResult();
|
|
318
321
|
this._reporter.onTestBegin(test, result);
|
|
319
322
|
}
|
package/lib/worker/testInfo.js
CHANGED
|
@@ -27,8 +27,6 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
27
27
|
*/
|
|
28
28
|
|
|
29
29
|
class TestInfoImpl {
|
|
30
|
-
// fn -> title
|
|
31
|
-
|
|
32
30
|
// ------------ TestInfo fields ------------
|
|
33
31
|
|
|
34
32
|
get error() {
|
|
@@ -53,7 +51,6 @@ class TestInfoImpl {
|
|
|
53
51
|
this._startWallTime = void 0;
|
|
54
52
|
this._hasHardError = false;
|
|
55
53
|
this._traceEvents = [];
|
|
56
|
-
this._onTestFailureImmediateCallbacks = new Map();
|
|
57
54
|
this._didTimeout = false;
|
|
58
55
|
this._wasInterrupted = false;
|
|
59
56
|
this._lastStepId = 0;
|
package/lib/worker/workerMain.js
CHANGED
|
@@ -41,18 +41,12 @@ class WorkerMain extends _process.ProcessRunner {
|
|
|
41
41
|
|
|
42
42
|
// Whether we should skip running remaining tests in this suite because
|
|
43
43
|
// of a setup error, usually beforeAll hook.
|
|
44
|
-
|
|
45
44
|
// The stage of the full cleanup. Once "finished", we can safely stop running anything.
|
|
46
|
-
|
|
47
45
|
// Whether the worker was requested to stop.
|
|
48
|
-
|
|
49
46
|
// This promise resolves once the single "run test group" call finishes.
|
|
50
|
-
|
|
51
47
|
// Dynamic annotations originated by modifiers with a callback, e.g. `test.skip(() => true)`.
|
|
52
|
-
|
|
53
48
|
// Suites that had their beforeAll hooks, but not afterAll hooks executed.
|
|
54
49
|
// These suites still need afterAll hooks to be executed for the proper cleanup.
|
|
55
|
-
|
|
56
50
|
constructor(params) {
|
|
57
51
|
super();
|
|
58
52
|
this._params = void 0;
|
|
@@ -300,6 +294,9 @@ class WorkerMain extends _process.ProcessRunner {
|
|
|
300
294
|
// Note: wrap all preparation steps together, because failure/skip in any of them
|
|
301
295
|
// prevents further setup and/or test from running.
|
|
302
296
|
const beforeHooksError = await testInfo._runAndFailOnError(async () => {
|
|
297
|
+
var _currentTestInstrumen;
|
|
298
|
+
await ((_currentTestInstrumen = (0, _globals.currentTestInstrumentation)()) === null || _currentTestInstrumen === void 0 ? void 0 : _currentTestInstrumen.willStartTest(testInfo));
|
|
299
|
+
|
|
303
300
|
// Run "beforeAll" modifiers on parent suites, unless already run during previous tests.
|
|
304
301
|
for (const suite of suites) {
|
|
305
302
|
if (this._extraSuiteAnnotations.has(suite)) continue;
|
|
@@ -379,24 +376,14 @@ class WorkerMain extends _process.ProcessRunner {
|
|
|
379
376
|
// Note: do not wrap all teardown steps together, because failure in any of them
|
|
380
377
|
// does not prevent further teardown steps from running.
|
|
381
378
|
|
|
382
|
-
// Run "immediately upon test
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
(0, _util2.debugTest)(`on-failure callback started`);
|
|
391
|
-
await testInfo._runAsStep({
|
|
392
|
-
category: 'hook',
|
|
393
|
-
title
|
|
394
|
-
}, fn);
|
|
395
|
-
(0, _util2.debugTest)(`on-failure callback finished`);
|
|
396
|
-
}
|
|
397
|
-
});
|
|
398
|
-
firstAfterHooksError = firstAfterHooksError || onFailureError;
|
|
399
|
-
}
|
|
379
|
+
// Run "immediately upon test function finish" callback.
|
|
380
|
+
(0, _util2.debugTest)(`on-test-function-finish callback started`);
|
|
381
|
+
const didFinishTestFunctionError = await testInfo._runAndFailOnError(async () => {
|
|
382
|
+
var _currentTestInstrumen2;
|
|
383
|
+
return await ((_currentTestInstrumen2 = (0, _globals.currentTestInstrumentation)()) === null || _currentTestInstrumen2 === void 0 ? void 0 : _currentTestInstrumen2.didFinishTestFunction(testInfo));
|
|
384
|
+
});
|
|
385
|
+
firstAfterHooksError = firstAfterHooksError || didFinishTestFunctionError;
|
|
386
|
+
(0, _util2.debugTest)(`on-test-function-finish callback finished`);
|
|
400
387
|
|
|
401
388
|
// Run "afterEach" hooks, unless we failed at beforeAll stage.
|
|
402
389
|
if (shouldRunAfterEachHooks) {
|
|
@@ -462,6 +449,11 @@ class WorkerMain extends _process.ProcessRunner {
|
|
|
462
449
|
firstAfterHooksError = firstAfterHooksError || workerScopeError;
|
|
463
450
|
});
|
|
464
451
|
}
|
|
452
|
+
const didRunTestError = await testInfo._runAndFailOnError(async () => {
|
|
453
|
+
var _currentTestInstrumen3;
|
|
454
|
+
return await ((_currentTestInstrumen3 = (0, _globals.currentTestInstrumentation)()) === null || _currentTestInstrumen3 === void 0 ? void 0 : _currentTestInstrumen3.didFinishTest(testInfo));
|
|
455
|
+
});
|
|
456
|
+
firstAfterHooksError = firstAfterHooksError || didRunTestError;
|
|
465
457
|
if (firstAfterHooksError) step.complete({
|
|
466
458
|
error: firstAfterHooksError
|
|
467
459
|
});
|
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-2-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-2-2023"
|
|
40
40
|
},
|
|
41
41
|
"optionalDependencies": {
|
|
42
42
|
"fsevents": "2.3.2"
|