parent
78309b9900
commit
700b310150
|
|
@ -342,8 +342,8 @@ scheme.PlaywrightNewRequestParams = tObject({
|
||||||
})),
|
})),
|
||||||
timeout: tOptional(tNumber),
|
timeout: tOptional(tNumber),
|
||||||
storageState: tOptional(tObject({
|
storageState: tOptional(tObject({
|
||||||
cookies: tArray(tType('NetworkCookie')),
|
cookies: tOptional(tArray(tType('NetworkCookie'))),
|
||||||
origins: tArray(tType('OriginStorage')),
|
origins: tOptional(tArray(tType('OriginStorage'))),
|
||||||
})),
|
})),
|
||||||
tracesDir: tOptional(tString),
|
tracesDir: tOptional(tString),
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -523,7 +523,7 @@ export class GlobalAPIRequestContext extends APIRequestContext {
|
||||||
}
|
}
|
||||||
if (options.storageState) {
|
if (options.storageState) {
|
||||||
this._origins = options.storageState.origins;
|
this._origins = options.storageState.origins;
|
||||||
this._cookieStore.addCookies(options.storageState.cookies);
|
this._cookieStore.addCookies(options.storageState.cookies || []);
|
||||||
}
|
}
|
||||||
this._options = {
|
this._options = {
|
||||||
baseURL: options.baseURL,
|
baseURL: options.baseURL,
|
||||||
|
|
|
||||||
|
|
@ -587,8 +587,8 @@ export type PlaywrightNewRequestParams = {
|
||||||
},
|
},
|
||||||
timeout?: number,
|
timeout?: number,
|
||||||
storageState?: {
|
storageState?: {
|
||||||
cookies: NetworkCookie[],
|
cookies?: NetworkCookie[],
|
||||||
origins: OriginStorage[],
|
origins?: OriginStorage[],
|
||||||
},
|
},
|
||||||
tracesDir?: string,
|
tracesDir?: string,
|
||||||
};
|
};
|
||||||
|
|
@ -610,8 +610,8 @@ export type PlaywrightNewRequestOptions = {
|
||||||
},
|
},
|
||||||
timeout?: number,
|
timeout?: number,
|
||||||
storageState?: {
|
storageState?: {
|
||||||
cookies: NetworkCookie[],
|
cookies?: NetworkCookie[],
|
||||||
origins: OriginStorage[],
|
origins?: OriginStorage[],
|
||||||
},
|
},
|
||||||
tracesDir?: string,
|
tracesDir?: string,
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -683,10 +683,10 @@ Playwright:
|
||||||
type: object?
|
type: object?
|
||||||
properties:
|
properties:
|
||||||
cookies:
|
cookies:
|
||||||
type: array
|
type: array?
|
||||||
items: NetworkCookie
|
items: NetworkCookie
|
||||||
origins:
|
origins:
|
||||||
type: array
|
type: array?
|
||||||
items: OriginStorage
|
items: OriginStorage
|
||||||
tracesDir: string?
|
tracesDir: string?
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -436,3 +436,14 @@ it('storage state should round-trip through file', async ({ playwright, server }
|
||||||
const state2 = await request2.storageState();
|
const state2 = await request2.storageState();
|
||||||
expect(state2).toEqual(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