diff --git a/src/core/config.js b/src/core/config.js index 7c3c11299..ab596a47b 100644 --- a/src/core/config.js +++ b/src/core/config.js @@ -4,7 +4,7 @@ export const config = { attributes: "_, script, data-script", defaultTransition: "all 500ms ease-in", disableSelector: "[disable-scripting], [data-disable-scripting]", - fetchThrowsOn: [/4.*/, /5.*/], + fetchThrowsOn: [/^4/, /^5/], hideShowStrategies: {}, logAll: false, mutatingMethods: { diff --git a/test/commands/fetch.js b/test/commands/fetch.js index 965ada56d..c1a5d47d2 100644 --- a/test/commands/fetch.js +++ b/test/commands/fetch.js @@ -196,6 +196,24 @@ test.describe("the fetch command", () => { await expect(find('div')).toHaveText("the body"); }); + test("does not throw on 204 No Content", async ({html, find, page}) => { + await page.route('**/test', async (route) => { + await route.fulfill({ status: 204, body: '' }); + }); + await html("
"); + await find('div').dispatchEvent('click'); + await expect(find('div')).toHaveText("ok"); + }); + + test("does not throw on 304 Not Modified", async ({html, find, page}) => { + await page.route('**/test', async (route) => { + await route.fulfill({ status: 304, body: '' }); + }); + await html(""); + await find('div').dispatchEvent('click'); + await expect(find('div')).toHaveText("ok"); + }); + test("as response does not throw on 404", async ({html, find, page}) => { await page.route('**/test', async (route) => { await route.fulfill({ status: 404, body: 'not found' });