fix(pwt): max-failures should work with retries (#7127)

fixes #7112
This commit is contained in:
Joel Einbinder 2021-06-14 22:16:16 -07:00 committed by GitHub
parent 2041aab010
commit aa72b2b9bb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 1 deletions

View File

@ -186,7 +186,7 @@ export class Dispatcher {
// Only retry expected failures, not passes and only if the test failed.
for (const testId of failedTestIds) {
const pair = this._testById.get(testId)!;
if (pair.test.expectedStatus === 'passed' && pair.test.results.length < pair.test.retries + 1) {
if (!this._isStopped && pair.test.expectedStatus === 'passed' && pair.test.results.length < pair.test.retries + 1) {
pair.result = pair.test._appendTestResult();
remaining.unshift({
retry: pair.result.retry,

View File

@ -63,3 +63,19 @@ test('-x should work', async ({ runInlineTest }) => {
expect(result.failed).toBe(1);
expect(result.output.split('\n').filter(l => l.includes('expect(')).length).toBe(2);
});
test('max-failures should work with retries', async ({ runInlineTest }) => {
const result = await runInlineTest({
'a.spec.js': `
const { test } = pwt;
for (let i = 0; i < 10; ++i) {
test('fail_' + i, () => {
expect(true).toBe(false);
});
}
`,
}, { 'max-failures': 2, 'retries': 4 });
expect(result.exitCode).toBe(1);
expect(result.failed).toBe(1);
expect(result.output.split('\n').filter(l => l.includes('Received:')).length).toBe(2);
});