Skip to content

Commit

Permalink
better still
Browse files Browse the repository at this point in the history
  • Loading branch information
benmccann committed Nov 27, 2022
1 parent 81726e0 commit 510ba27
Showing 1 changed file with 10 additions and 17 deletions.
27 changes: 10 additions & 17 deletions packages/kit/test/apps/basics/test/client.test.js
Expand Up @@ -608,28 +608,21 @@ test.describe('Load', () => {

if (process.env.DEV) {
test('using window.fetch causes a warning', async ({ page, baseURL }) => {
/** @type {string[]} */
const warnings = [];

page.on('console', (msg) => {
if (msg.type() === 'warning') {
warnings.push(msg.text());
}
});

await Promise.all([page.goto('/load/window-fetch/incorrect'), page.waitForEvent('console')]);

const [msg0] = await Promise.all([
page.waitForEvent('console'),
page.goto('/load/window-fetch/incorrect')
]);
expect(await page.textContent('h1')).toBe('42');
expect(warnings).toContain(
expect(msg0.text()).toBe(
`Loading ${baseURL}/load/window-fetch/data.json using \`window.fetch\`. For best results, use the \`fetch\` that is passed to your \`load\` function: https://kit.svelte.dev/docs/load#making-fetch-requests`
);

warnings.length = 0;

await Promise.all([page.goto('/load/window-fetch/correct'), page.waitForEvent('console')]);

const [msg1] = await Promise.all([
page.waitForEvent('console'),
page.goto('/load/window-fetch/correct')
]);
expect(await page.textContent('h1')).toBe('42');
expect(warnings).not.toContain(
expect(msg1.text()).toBe(
`Loading ${baseURL}/load/window-fetch/data.json using \`window.fetch\`. For best results, use the \`fetch\` that is passed to your \`load\` function: https://kit.svelte.dev/docs/load#making-fetch-requests`
);
});
Expand Down

0 comments on commit 510ba27

Please sign in to comment.