test: rewrite 'should fulfill json' test (#23735)
This commit is contained in:
parent
8602981d87
commit
421872f130
|
|
@ -379,7 +379,8 @@ it('should fulfill preload link requests', async ({ page, server, browserName })
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should fulfill json', async ({ page, server }) => {
|
it('should fulfill json', async ({ page, server }) => {
|
||||||
await page.route('**/*', route => {
|
await page.goto(server.EMPTY_PAGE);
|
||||||
|
await page.route('**/data.json', route => {
|
||||||
void route.fulfill({
|
void route.fulfill({
|
||||||
status: 201,
|
status: 201,
|
||||||
headers: {
|
headers: {
|
||||||
|
|
@ -388,8 +389,11 @@ it('should fulfill json', async ({ page, server }) => {
|
||||||
json: { bar: 'baz' },
|
json: { bar: 'baz' },
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
const response = await page.goto(server.EMPTY_PAGE);
|
const [response, body] = await Promise.all([
|
||||||
|
page.waitForResponse('**/*'),
|
||||||
|
page.evaluate(() => fetch('./data.json').then(r => r.text()))
|
||||||
|
]);
|
||||||
expect(response.status()).toBe(201);
|
expect(response.status()).toBe(201);
|
||||||
expect(response.headers()['content-type']).toBe('application/json');
|
expect(response.headers()['content-type']).toBe('application/json');
|
||||||
expect(await page.evaluate(() => document.body.textContent)).toBe(JSON.stringify({ bar: 'baz' }));
|
expect(body).toBe(JSON.stringify({ bar: 'baz' }));
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue