parent
78309b9900
commit
700b310150
|
|
@ -342,8 +342,8 @@ scheme.PlaywrightNewRequestParams = tObject({
|
|||
})),
|
||||
timeout: tOptional(tNumber),
|
||||
storageState: tOptional(tObject({
|
||||
cookies: tArray(tType('NetworkCookie')),
|
||||
origins: tArray(tType('OriginStorage')),
|
||||
cookies: tOptional(tArray(tType('NetworkCookie'))),
|
||||
origins: tOptional(tArray(tType('OriginStorage'))),
|
||||
})),
|
||||
tracesDir: tOptional(tString),
|
||||
});
|
||||
|
|
|
|||
|
|
@ -523,7 +523,7 @@ export class GlobalAPIRequestContext extends APIRequestContext {
|
|||
}
|
||||
if (options.storageState) {
|
||||
this._origins = options.storageState.origins;
|
||||
this._cookieStore.addCookies(options.storageState.cookies);
|
||||
this._cookieStore.addCookies(options.storageState.cookies || []);
|
||||
}
|
||||
this._options = {
|
||||
baseURL: options.baseURL,
|
||||
|
|
|
|||
|
|
@ -587,8 +587,8 @@ export type PlaywrightNewRequestParams = {
|
|||
},
|
||||
timeout?: number,
|
||||
storageState?: {
|
||||
cookies: NetworkCookie[],
|
||||
origins: OriginStorage[],
|
||||
cookies?: NetworkCookie[],
|
||||
origins?: OriginStorage[],
|
||||
},
|
||||
tracesDir?: string,
|
||||
};
|
||||
|
|
@ -610,8 +610,8 @@ export type PlaywrightNewRequestOptions = {
|
|||
},
|
||||
timeout?: number,
|
||||
storageState?: {
|
||||
cookies: NetworkCookie[],
|
||||
origins: OriginStorage[],
|
||||
cookies?: NetworkCookie[],
|
||||
origins?: OriginStorage[],
|
||||
},
|
||||
tracesDir?: string,
|
||||
};
|
||||
|
|
|
|||
|
|
@ -683,10 +683,10 @@ Playwright:
|
|||
type: object?
|
||||
properties:
|
||||
cookies:
|
||||
type: array
|
||||
type: array?
|
||||
items: NetworkCookie
|
||||
origins:
|
||||
type: array
|
||||
type: array?
|
||||
items: OriginStorage
|
||||
tracesDir: string?
|
||||
|
||||
|
|
|
|||
|
|
@ -436,3 +436,14 @@ it('storage state should round-trip through file', async ({ playwright, server }
|
|||
const state2 = await request2.storageState();
|
||||
expect(state2).toEqual(storageState);
|
||||
});
|
||||
|
||||
it('should work with empty storage state', async ({ playwright, server }, testInfo) => {
|
||||
const storageState = testInfo.outputPath('storage-state.json');
|
||||
await fs.promises.writeFile(storageState, '{}');
|
||||
const request1 = await playwright.request.newContext({ storageState });
|
||||
|
||||
const state1 = await request1.storageState();
|
||||
expect(state1).toEqual({ cookies: [], origins: [] });
|
||||
await expect(await request1.get(server.EMPTY_PAGE)).toBeOK();
|
||||
await request1.dispose();
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue