Skip to content

Commit

Permalink
[chore] upgrade to playwright 1.28.1 (#7696)
Browse files Browse the repository at this point in the history
* [chore] upgrade to Playwright 1.28.1

* wait for console event

* better still

* need to use a predicate since there are multiple console logs

* stacktrace is unreliable

* Revert "stacktrace is unreliable"

This reverts commit 6c5e4d0.

* solve stacktrace issue in another way

* format

* fix some turbo config

Co-authored-by: Rich Harris <hello@rich-harris.dev>
  • Loading branch information
benmccann and Rich-Harris committed Nov 28, 2022
1 parent 0984794 commit 191583c
Show file tree
Hide file tree
Showing 8 changed files with 45 additions and 28 deletions.
5 changes: 5 additions & 0 deletions .changeset/nine-rivers-argue.md
@@ -0,0 +1,5 @@
---
'create-svelte': patch
---

Upgrade to Playwright 1.28.1
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -27,7 +27,7 @@
"@rollup/plugin-json": "^5.0.1",
"@rollup/plugin-node-resolve": "^15.0.1",
"@svitejs/changesets-changelog-github-compact": "^0.1.1",
"playwright": "1.25.0",
"playwright": "^1.28.1",
"prettier": "^2.7.1",
"rollup": "^2.79.1",
"svelte": "^3.52.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/create-svelte/package.json
Expand Up @@ -15,7 +15,7 @@
"prompts": "^2.4.2"
},
"devDependencies": {
"@playwright/test": "1.25.0",
"@playwright/test": "^1.28.1",
"@sveltejs/kit": "workspace:*",
"@types/gitignore-parser": "^0.0.0",
"@types/prettier": "^2.7.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/kit/package.json
Expand Up @@ -24,7 +24,7 @@
"undici": "5.13.0"
},
"devDependencies": {
"@playwright/test": "1.25.0",
"@playwright/test": "^1.28.1",
"@types/connect": "^3.4.35",
"@types/marked": "^4.0.7",
"@types/mime": "^3.0.1",
Expand Down
7 changes: 6 additions & 1 deletion packages/kit/src/runtime/client/fetcher.js
Expand Up @@ -26,7 +26,12 @@ if (import.meta.env.DEV) {
const url = input instanceof Request ? input.url : input.toString();
const stack = /** @type {string} */ (new Error().stack);

const heuristic = can_inspect_stack_trace ? stack.includes('load_node') : loading;
// check if fetch was called via load_node. the lock method only checks if it was called at the
// same time, but not necessarily if it was called from `load`
// we use just the filename as the method name sometimes does not appear on the CI
const heuristic = can_inspect_stack_trace
? stack.includes('src/runtime/client/client.js')
: loading;
if (heuristic) {
console.warn(
`Loading ${url} 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
24 changes: 14 additions & 10 deletions packages/kit/test/apps/basics/test/client.test.js
Expand Up @@ -608,24 +608,28 @@ test.describe('Load', () => {

if (process.env.DEV) {
test('using window.fetch causes a warning', async ({ page, baseURL }) => {
await Promise.all([
page.goto('/load/window-fetch/incorrect'),
page.waitForEvent('console', {
predicate: (message) => {
return (
message.text() ===
`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`
);
},
timeout: 3_000
})
]);
expect(await page.textContent('h1')).toBe('42');

/** @type {string[]} */
const warnings = [];

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

await page.goto('/load/window-fetch/incorrect');
expect(await page.textContent('h1')).toBe('42');

expect(warnings).toContain(
`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 page.goto('/load/window-fetch/correct');
expect(await page.textContent('h1')).toBe('42');

Expand Down
28 changes: 14 additions & 14 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions turbo.json
Expand Up @@ -30,6 +30,9 @@
"check": {
"dependsOn": ["prepare"],
"inputs": [
"index.js",
"index.d.ts",
"ambient.d.ts",
"src/**",
"types/**",
".svelte-kit/types/**",
Expand Down

0 comments on commit 191583c

Please sign in to comment.