Merge 123bc22dbb into 7a61aa25e6
This commit is contained in:
commit
acc4ed3433
|
|
@ -384,6 +384,10 @@ export default defineConfig({
|
||||||
});
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## property: TestConfig.recreateWorkerAfterFailure?
|
||||||
|
* since: v1.51
|
||||||
|
- type: <[boolean]>
|
||||||
|
|
||||||
## property: TestConfig.repeatEach
|
## property: TestConfig.repeatEach
|
||||||
* since: v1.10
|
* since: v1.10
|
||||||
- type: ?<[int]>
|
- type: ?<[int]>
|
||||||
|
|
|
||||||
|
|
@ -48,6 +48,7 @@ export class FullConfigInternal {
|
||||||
readonly plugins: TestRunnerPluginRegistration[];
|
readonly plugins: TestRunnerPluginRegistration[];
|
||||||
readonly projects: FullProjectInternal[] = [];
|
readonly projects: FullProjectInternal[] = [];
|
||||||
readonly singleTSConfigPath?: string;
|
readonly singleTSConfigPath?: string;
|
||||||
|
readonly recreateWorkerAfterFailure: boolean;
|
||||||
cliArgs: string[] = [];
|
cliArgs: string[] = [];
|
||||||
cliGrep: string | undefined;
|
cliGrep: string | undefined;
|
||||||
cliGrepInvert: string | undefined;
|
cliGrepInvert: string | undefined;
|
||||||
|
|
@ -85,6 +86,8 @@ export class FullConfigInternal {
|
||||||
// so that plugins such as gitCommitInfoPlugin can populate metadata once.
|
// so that plugins such as gitCommitInfoPlugin can populate metadata once.
|
||||||
userConfig.metadata = userConfig.metadata || {};
|
userConfig.metadata = userConfig.metadata || {};
|
||||||
|
|
||||||
|
this.recreateWorkerAfterFailure = userConfig.recreateWorkerAfterFailure ?? true;
|
||||||
|
|
||||||
this.config = {
|
this.config = {
|
||||||
configFile: resolvedConfigFile,
|
configFile: resolvedConfigFile,
|
||||||
rootDir: pathResolve(configDir, userConfig.testDir) || configDir,
|
rootDir: pathResolve(configDir, userConfig.testDir) || configDir,
|
||||||
|
|
|
||||||
|
|
@ -396,6 +396,9 @@ export class WorkerMain extends ProcessRunner {
|
||||||
// After hooks get an additional timeout.
|
// After hooks get an additional timeout.
|
||||||
const afterHooksTimeout = calculateMaxTimeout(this._project.project.timeout, testInfo.timeout);
|
const afterHooksTimeout = calculateMaxTimeout(this._project.project.timeout, testInfo.timeout);
|
||||||
const afterHooksSlot = { timeout: afterHooksTimeout, elapsed: 0 };
|
const afterHooksSlot = { timeout: afterHooksTimeout, elapsed: 0 };
|
||||||
|
|
||||||
|
const FAILURE_AND_RECREATE_WORKER = testInfo._isFailure() && this._config.recreateWorkerAfterFailure;
|
||||||
|
|
||||||
await testInfo._runAsStep({ title: 'After Hooks', category: 'hook' }, async () => {
|
await testInfo._runAsStep({ title: 'After Hooks', category: 'hook' }, async () => {
|
||||||
let firstAfterHooksError: Error | undefined;
|
let firstAfterHooksError: Error | undefined;
|
||||||
|
|
||||||
|
|
@ -428,7 +431,7 @@ export class WorkerMain extends ProcessRunner {
|
||||||
// In case of failure the worker will be stopped and we have to make sure that afterAll
|
// In case of failure the worker will be stopped and we have to make sure that afterAll
|
||||||
// hooks run before worker fixtures teardown.
|
// hooks run before worker fixtures teardown.
|
||||||
for (const suite of reversedSuites) {
|
for (const suite of reversedSuites) {
|
||||||
if (!nextSuites.has(suite) || testInfo._isFailure()) {
|
if (!nextSuites.has(suite) || FAILURE_AND_RECREATE_WORKER) {
|
||||||
try {
|
try {
|
||||||
await this._runAfterAllHooksForSuite(suite, testInfo);
|
await this._runAfterAllHooksForSuite(suite, testInfo);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|
@ -443,7 +446,7 @@ export class WorkerMain extends ProcessRunner {
|
||||||
|
|
||||||
checkForFloatingPromises('afterAll/afterEach hooks');
|
checkForFloatingPromises('afterAll/afterEach hooks');
|
||||||
|
|
||||||
if (testInfo._isFailure())
|
if (FAILURE_AND_RECREATE_WORKER)
|
||||||
this._isStopped = true;
|
this._isStopped = true;
|
||||||
|
|
||||||
if (this._isStopped) {
|
if (this._isStopped) {
|
||||||
|
|
|
||||||
2
packages/playwright/types/test.d.ts
vendored
2
packages/playwright/types/test.d.ts
vendored
|
|
@ -1400,6 +1400,8 @@ interface TestConfig<TestArgs = {}, WorkerArgs = {}> {
|
||||||
*/
|
*/
|
||||||
quiet?: boolean;
|
quiet?: boolean;
|
||||||
|
|
||||||
|
recreateWorkerAfterFailure?: boolean;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The number of times to repeat each test, useful for debugging flaky tests.
|
* The number of times to repeat each test, useful for debugging flaky tests.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue