feat(fetch): accept numeric and bool params (#9345)
This commit is contained in:
parent
52f19a222e
commit
6c18f1a6f0
|
|
@ -303,7 +303,7 @@ Emulates consistent window screen size available inside web page via `window.scr
|
|||
Target URL.
|
||||
|
||||
## fetch-option-params
|
||||
- `params` <[Object]<[string], [string]>>
|
||||
- `params` <[Object]<[string], [string]|[float]|[boolean]>>
|
||||
|
||||
Query parameters to be send with the URL.
|
||||
|
||||
|
|
|
|||
|
|
@ -903,3 +903,29 @@ it('context request should export same storage state as context', async ({ conte
|
|||
const pageState = await page.request.storageState();
|
||||
expect(pageState).toEqual(contextState);
|
||||
});
|
||||
|
||||
it('should accept bool and numeric params', async ({ context, page, server }) => {
|
||||
let request;
|
||||
const url = new URL(server.EMPTY_PAGE);
|
||||
url.searchParams.set('str', 's');
|
||||
url.searchParams.set('num', '10');
|
||||
url.searchParams.set('bool', 'true');
|
||||
url.searchParams.set('bool2', 'false');
|
||||
server.setRoute(url.pathname + url.search, (req, res) => {
|
||||
request = req;
|
||||
server.serveFile(req, res);
|
||||
});
|
||||
await page.request.get(server.EMPTY_PAGE, {
|
||||
params: {
|
||||
'str': 's',
|
||||
'num': 10,
|
||||
'bool': true,
|
||||
'bool2': false,
|
||||
}
|
||||
});
|
||||
const params = new URLSearchParams(request.url.substr(request.url.indexOf('?')));
|
||||
expect(params.get('str')).toEqual('s');
|
||||
expect(params.get('num')).toEqual('10');
|
||||
expect(params.get('bool')).toEqual('true');
|
||||
expect(params.get('bool2')).toEqual('false');
|
||||
});
|
||||
|
|
|
|||
14
types/types.d.ts
vendored
14
types/types.d.ts
vendored
|
|
@ -11747,7 +11747,7 @@ export interface ApiRequestContext {
|
|||
/**
|
||||
* Query parameters to be send with the URL.
|
||||
*/
|
||||
params?: { [key: string]: string; };
|
||||
params?: { [key: string]: string|number|boolean; };
|
||||
|
||||
/**
|
||||
* Request timeout in milliseconds. Defaults to `30000` (30 seconds). Pass `0` to disable timeout.
|
||||
|
|
@ -11835,7 +11835,7 @@ export interface ApiRequestContext {
|
|||
/**
|
||||
* Query parameters to be send with the URL.
|
||||
*/
|
||||
params?: { [key: string]: string; };
|
||||
params?: { [key: string]: string|number|boolean; };
|
||||
|
||||
/**
|
||||
* Request timeout in milliseconds. Defaults to `30000` (30 seconds). Pass `0` to disable timeout.
|
||||
|
|
@ -11869,7 +11869,7 @@ export interface ApiRequestContext {
|
|||
/**
|
||||
* Query parameters to be send with the URL.
|
||||
*/
|
||||
params?: { [key: string]: string; };
|
||||
params?: { [key: string]: string|number|boolean; };
|
||||
|
||||
/**
|
||||
* Request timeout in milliseconds. Defaults to `30000` (30 seconds). Pass `0` to disable timeout.
|
||||
|
|
@ -11903,7 +11903,7 @@ export interface ApiRequestContext {
|
|||
/**
|
||||
* Query parameters to be send with the URL.
|
||||
*/
|
||||
params?: { [key: string]: string; };
|
||||
params?: { [key: string]: string|number|boolean; };
|
||||
|
||||
/**
|
||||
* Request timeout in milliseconds. Defaults to `30000` (30 seconds). Pass `0` to disable timeout.
|
||||
|
|
@ -11974,7 +11974,7 @@ export interface ApiRequestContext {
|
|||
/**
|
||||
* Query parameters to be send with the URL.
|
||||
*/
|
||||
params?: { [key: string]: string; };
|
||||
params?: { [key: string]: string|number|boolean; };
|
||||
|
||||
/**
|
||||
* Request timeout in milliseconds. Defaults to `30000` (30 seconds). Pass `0` to disable timeout.
|
||||
|
|
@ -12045,7 +12045,7 @@ export interface ApiRequestContext {
|
|||
/**
|
||||
* Query parameters to be send with the URL.
|
||||
*/
|
||||
params?: { [key: string]: string; };
|
||||
params?: { [key: string]: string|number|boolean; };
|
||||
|
||||
/**
|
||||
* Request timeout in milliseconds. Defaults to `30000` (30 seconds). Pass `0` to disable timeout.
|
||||
|
|
@ -12116,7 +12116,7 @@ export interface ApiRequestContext {
|
|||
/**
|
||||
* Query parameters to be send with the URL.
|
||||
*/
|
||||
params?: { [key: string]: string; };
|
||||
params?: { [key: string]: string|number|boolean; };
|
||||
|
||||
/**
|
||||
* Request timeout in milliseconds. Defaults to `30000` (30 seconds). Pass `0` to disable timeout.
|
||||
|
|
|
|||
Loading…
Reference in a new issue