Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/core/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down
18 changes: 18 additions & 0 deletions test/commands/fetch.js
Original file line number Diff line number Diff line change
Expand Up @@ -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("<div _='on click fetch /test then put \"ok\" into me'></div>");
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("<div _='on click fetch /test then put \"ok\" into me'></div>");
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' });
Expand Down