Repository: sveltejs/kit
Pull request #7647 (2022-11-14 19:40:44)

[fix] remove global variable from test to fix flakiness
one down. several to go...

changeset-bot[bot]: ###  ⚠️  No Changeset found

Latest commit: 3a42096b14a333841ae33bb7a8f5867cd34bde87

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. **If these changes should result in a version bump, you need to add a changeset.**

<details><summary>This PR includes no changesets</summary>

  When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

</details>

[Click here to learn what changesets are, and how to add one](https://github.com/changesets/changesets/blob/master/docs/adding-a-changeset.md).

[Click here if you're a maintainer who wants to add a changeset to this PR](https://github.com/sveltejs/kit/new/no-global-var?filename=.changeset/empty-rabbits-wonder.md&value=---%0A%22%40sveltejs%2Fkit%22%3A%20patch%0A%22test-basics%22%3A%20patch%0A---%0A%0A%5Bfix%5D%20remove%20global%20variable%20from%20test%20to%20fix%20flakiness%0A)


dominikg: > How does this reduce flakyness due to race conditions. What's different to a global variable and a cookie? Is it that we assume the browser instances are isolated so that their cookie values don't conflate?

playwright isolates page in different tests https://playwright.dev/docs/browser-contexts 
Conduitry: Yeah, what Dominik said. Each test gets its own browser context (and thus its own cookies). By avoiding this global state on the server, we should be able to have these tests run in parallel against a single instance of the app being tested.

Patch:
diff --git a/.changeset/kind-beans-talk.md b/.changeset/kind-beans-talk.md
new file mode 100644
index 000000000..5c3b93881
--- /dev/null
+++ b/.changeset/kind-beans-talk.md
@@ -0,0 +1,5 @@
+---
+"@sveltejs/kit": patch
+---
+
+fix outdated config error
diff --git a/.changeset/warm-deers-sneeze.md b/.changeset/warm-deers-sneeze.md
new file mode 100644
index 000000000..9361acd98
--- /dev/null
+++ b/.changeset/warm-deers-sneeze.md
@@ -0,0 +1,5 @@
+---
+"@sveltejs/kit": patch
+---
+
+fix `beforeNavigate` description — `routeId` -> `route.id`
diff --git a/packages/kit/src/core/config/options.js b/packages/kit/src/core/config/options.js
index 32d8ca1cd..8e1228e07 100644
--- a/packages/kit/src/core/config/options.js
+++ b/packages/kit/src/core/config/options.js
@@ -111,11 +111,11 @@ const options = object(
 			browser: object({
 				hydrate: error(
 					(keypath) =>
-						`${keypath} has been removed. You can set it inside the top level +layout.js instead. See the PR for more information: https://github.com/sveltejs/kit/pull/6197`
+						`${keypath} has been removed. You can set \`export const csr = false\` inside the top level +layout.js instead. See the PR for more information: https://github.com/sveltejs/kit/pull/6197`
 				),
 				router: error(
 					(keypath) =>
-						`${keypath} has been removed. You can set it inside the top level +layout.js instead. See the PR for more information: https://github.com/sveltejs/kit/pull/6197`
+						`${keypath} has been removed. You can set \`export const csr = false\` inside the top level +layout.js instead. See the PR for more information: https://github.com/sveltejs/kit/pull/6197`
 				)
 			}),
 
@@ -318,7 +318,10 @@ const options = object(
 			),
 
 			// TODO remove for 1.0
-			router: error((keypath) => `${keypath} has been moved to config.kit.browser.router`),
+			router: error(
+				(keypath) =>
+					`${keypath} has been removed. You can set \`export const csr = false\` inside the top level +layout.js instead. See the PR for more information: https://github.com/sveltejs/kit/pull/6197`
+			),
 
 			// TODO remove for 1.0
 			routes: error(
diff --git a/packages/kit/types/ambient.d.ts b/packages/kit/types/ambient.d.ts
index b3232b32e..c5a14c3a0 100644
--- a/packages/kit/types/ambient.d.ts
+++ b/packages/kit/types/ambient.d.ts
@@ -260,7 +260,7 @@ declare module '$app/navigation' {
 	 * A navigation interceptor that triggers before we navigate to a new URL, whether by clicking a link, calling `goto(...)`, or using the browser back/forward controls.
 	 * Calling `cancel()` will prevent the navigation from completing.
 	 *
-	 * When a navigation isn't client side, `navigation.to.routeId` will be `null`.
+	 * When a navigation isn't client side, `navigation.to.route.id` will be `null`.
 	 *
 	 * `beforeNavigate` must be called during a component initialization. It remains active as long as the component is mounted.
 	 */


Test patch:
diff --git a/packages/kit/test/apps/basics/src/routes/+layout.server.js b/packages/kit/test/apps/basics/src/routes/+layout.server.js
index e1959399b..d30920705 100644
--- a/packages/kit/test/apps/basics/src/routes/+layout.server.js
+++ b/packages/kit/test/apps/basics/src/routes/+layout.server.js
@@ -1,24 +1,15 @@
 import { error, redirect } from '@sveltejs/kit';
 
-let should_fail = '';
-/**
- * @param {string} value
- */
-export function set_should_fail(value) {
-	should_fail = value;
-}
-
 /** @type {import('./$types').LayoutServerLoad} */
-export async function load() {
+export async function load({ cookies }) {
+	const should_fail = cookies.get('fail-type');
 	if (should_fail) {
+		cookies.delete('fail-type', { path: '/' });
 		if (should_fail === 'expected') {
-			set_should_fail('');
 			throw error(401, 'Not allowed');
 		} else if (should_fail === 'unexpected') {
-			set_should_fail('');
 			throw new Error('Failed to load');
 		} else {
-			set_should_fail('');
 			throw redirect(307, '/load');
 		}
 	}
diff --git a/packages/kit/test/apps/basics/src/routes/errors/error-html/make-root-fail/+server.js b/packages/kit/test/apps/basics/src/routes/errors/error-html/make-root-fail/+server.js
index c3030a9c9..63f0488cd 100644
--- a/packages/kit/test/apps/basics/src/routes/errors/error-html/make-root-fail/+server.js
+++ b/packages/kit/test/apps/basics/src/routes/errors/error-html/make-root-fail/+server.js
@@ -1,9 +1,7 @@
-import { set_should_fail } from '../../../+layout.server';
-
 /**
  * @type {import('./$types').RequestHandler} param0
  */
-export function GET({ url }) {
-	set_should_fail(url.searchParams.get('type'));
+export function GET({ cookies, url }) {
+	cookies.set('fail-type', url.searchParams.get('type'), { path: '/' });
 	return new Response();
 }
diff --git a/packages/kit/test/apps/basics/test/client.test.js b/packages/kit/test/apps/basics/test/client.test.js
index f0c84475d..9c11830d0 100644
--- a/packages/kit/test/apps/basics/test/client.test.js
+++ b/packages/kit/test/apps/basics/test/client.test.js
@@ -774,6 +774,7 @@ test.describe('Routing', () => {
 	});
 
 	test('does not normalize external path', async ({ page }) => {
+		/** @type {Array<string|undefined>} */
 		const urls = [];
 
 		const { port, close } = await start_server((req, res) => {
@@ -1030,6 +1031,7 @@ test.describe.serial('Invalidation', () => {
 
 test.describe('data-sveltekit attributes', () => {
 	test('data-sveltekit-prefetch', async ({ baseURL, page }) => {
+		/** @type {string[]} */
 		const requests = [];
 		page.on('request', (r) => requests.push(r.url()));
 
@@ -1065,6 +1067,7 @@ test.describe('data-sveltekit attributes', () => {
 	});
 
 	test('data-sveltekit-reload', async ({ baseURL, page, clicknav }) => {
+		/** @type {string[]} */
 		const requests = [];
 		page.on('request', (r) => requests.push(r.url()));