Do not use pw:api in runner code
This commit is contained in:
parent
d112ae6c4f
commit
0d54e8e0de
|
|
@ -261,6 +261,7 @@ const playwrightFixtures: Fixtures<TestFixtures, WorkerFixtures> = ({
|
|||
title: renderApiCall(apiName, params),
|
||||
apiName,
|
||||
params,
|
||||
canNestByTime: true,
|
||||
});
|
||||
userData.userObject = step;
|
||||
out.stepId = step.stepId;
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ export interface TestStepInternal {
|
|||
complete(result: { error?: Error, attachments?: Attachment[] }): void;
|
||||
stepId: string;
|
||||
title: string;
|
||||
category: 'hook' | 'fixture' | 'test.step' | 'expect' | 'pw:api' | string;
|
||||
category: 'hook' | 'fixture' | 'test.step' | 'expect' | 'attach' | string;
|
||||
location?: Location;
|
||||
boxedStack?: StackFrame[];
|
||||
steps: TestStepInternal[];
|
||||
|
|
@ -44,6 +44,9 @@ export interface TestStepInternal {
|
|||
infectParentStepsWithError?: boolean;
|
||||
box?: boolean;
|
||||
isStage?: boolean;
|
||||
// TODO: this сould be decided based on the category, but pw:api
|
||||
// is from a different abstraction layer.
|
||||
canNestByTime?: boolean;
|
||||
}
|
||||
|
||||
export type TestStage = {
|
||||
|
|
@ -252,7 +255,7 @@ export class TestInfoImpl implements TestInfo {
|
|||
parentStep = this._findLastStageStep();
|
||||
} else {
|
||||
parentStep = zones.zoneData<TestStepInternal>('stepZone');
|
||||
if (!parentStep && data.category === 'pw:api') {
|
||||
if (!parentStep && data.canNestByTime) {
|
||||
// API steps (but not test.step calls) can be nested by time, instead of by stack.
|
||||
// However, do not nest chains of route.continue by checking the title.
|
||||
parentStep = this._findLastNonFinishedStep(step => step.title !== data.title);
|
||||
|
|
|
|||
|
|
@ -1179,24 +1179,6 @@ test('should record trace for manually created context in a failed test', async
|
|||
expect(trace.events).toContainEqual(expect.objectContaining({ type: 'console', text: 'from the page' }));
|
||||
});
|
||||
|
||||
test('expect during fetch', async ({ page, server }) => {
|
||||
server.setRoute('/index', (req, res) => {
|
||||
console.log('index');
|
||||
res.writeHead(200, { 'Content-Type': 'text/html' });
|
||||
res.end(`<script>fetch('/api')</script><div>Hello!</div>`);
|
||||
});
|
||||
server.setRoute('/hang', async (req, res) => {
|
||||
console.log('Hanging request');
|
||||
});
|
||||
await page.route('**/api', async route => {
|
||||
const response = await route.fetch({ url: server.PREFIX + '/hang' });
|
||||
await route.fulfill({ response });
|
||||
});
|
||||
await page.goto(server.PREFIX + '/index');
|
||||
await expect(page.getByText('Hello!')).toBeVisible();
|
||||
await page.unrouteAll({ behavior: 'ignoreErrors' });
|
||||
});
|
||||
|
||||
test('should not nest top level expect into unfinished api calls ', {
|
||||
annotation: { type: 'issue', description: 'https://github.com/microsoft/playwright/issues/31959' }
|
||||
}, async ({ runInlineTest, server }) => {
|
||||
|
|
|
|||
Loading…
Reference in a new issue