-
Notifications
You must be signed in to change notification settings - Fork 3.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(playwright): test unexpected result if failed and skipped #30276
Changes from 3 commits
49b2930
3436a86
7eccbf7
c19ebab
ad586d2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -290,10 +290,14 @@ export class TestCase extends Base implements reporterTypes.TestCase { | |
return 'skipped'; | ||
|
||
const failures = results.filter(result => result.status !== 'skipped' && result.status !== 'interrupted' && result.status !== this.expectedStatus); | ||
const skipped = results.filter(result => result.status === 'skipped' && result.status !== this.expectedStatus); | ||
const passed = results.filter(result => result.status === 'passed'); | ||
if (!failures.length) // all passed | ||
return 'expected'; | ||
if (failures.length === results.length) // all failed | ||
return 'unexpected'; | ||
if (failures.length && skipped.length && !passed.length) // some failed, none succeeded and the rest were skipped | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I believe what we need here is instead of lines 297-300 something like: if (failures.length && !passed.length)
return 'unexpected'; as we don't care if there were any "skips". There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed 👍 |
||
return 'unexpected'; | ||
return 'flaky'; // mixed bag | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -140,6 +140,40 @@ test('test.describe.serial should work with retry', async ({ runInlineTest }) => | |
]); | ||
}); | ||
|
||
test('test.describe.serial should work with retry when it fails in different places', async ({ runInlineTest }) => { | ||
const result = await runInlineTest({ | ||
'a.test.ts': ` | ||
import { test, expect } from '@playwright/test'; | ||
test.describe.serial('serial suite', () => { | ||
test('test1', async ({}, testInfo) => { | ||
console.log('\\n%%test1'); | ||
expect(testInfo.retry).toEqual(0) | ||
}); | ||
test('test2', async ({}, testInfo) => { | ||
console.log('\\n%%test2'); | ||
expect(testInfo.retry).toEqual(1) | ||
}); | ||
test('test3', async ({}) => { | ||
console.log('\\n%%test3'); | ||
}); | ||
test('test4', async ({}) => { | ||
console.log('\\n%%test4'); | ||
}); | ||
}); | ||
`, | ||
}, { retries: 1 }); | ||
expect(result.exitCode).toBe(1); | ||
expect(result.passed).toBe(0); | ||
expect(result.flaky).toBe(1); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I believe in this scenario at least two tests There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. My apologies, read the bug again, this is an intentional change. I'll discuss in the team meeting if this is change that we want. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Discussed this in the meeting, we'll consider all the implications and other possibilities and @dgozman will come back to you. |
||
expect(result.failed).toBe(1); | ||
expect(result.skipped).toBe(2); | ||
expect(result.outputLines).toEqual([ | ||
'test1', | ||
'test2', | ||
'test1', | ||
]); | ||
}); | ||
|
||
test('test.describe.serial should work with retry and beforeAll failure', async ({ runInlineTest }) => { | ||
const result = await runInlineTest({ | ||
'a.test.ts': ` | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We probably need a test for this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure I understood, do you mean another test where the expected result is failure?