Skip to content

chore: upgrade to vitest 3 #13330

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jan 20, 2025
Merged
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 packages/adapter-auto/package.json
Original file line number Diff line number Diff line change
@@ -44,7 +44,7 @@
"@sveltejs/vite-plugin-svelte": "^5.0.1",
"@types/node": "^18.19.48",
"typescript": "^5.3.3",
"vitest": "^2.1.6"
"vitest": "^3.0.1"
},
"dependencies": {
"import-meta-resolve": "^4.1.0"
2 changes: 1 addition & 1 deletion packages/adapter-netlify/package.json
Original file line number Diff line number Diff line change
@@ -56,7 +56,7 @@
"@types/set-cookie-parser": "^2.4.7",
"rollup": "^4.14.2",
"typescript": "^5.3.3",
"vitest": "^2.1.6"
"vitest": "^3.0.1"
},
"peerDependencies": {
"@sveltejs/kit": "^2.4.0"
2 changes: 1 addition & 1 deletion packages/adapter-node/package.json
Original file line number Diff line number Diff line change
@@ -48,7 +48,7 @@
"polka": "^1.0.0-next.28",
"sirv": "^3.0.0",
"typescript": "^5.3.3",
"vitest": "^2.1.6"
"vitest": "^3.0.1"
},
"dependencies": {
"@rollup/plugin-commonjs": "^28.0.1",
2 changes: 1 addition & 1 deletion packages/adapter-vercel/package.json
Original file line number Diff line number Diff line change
@@ -47,7 +47,7 @@
"@sveltejs/vite-plugin-svelte": "^5.0.1",
"@types/node": "^18.19.48",
"typescript": "^5.3.3",
"vitest": "^2.1.6"
"vitest": "^3.0.1"
},
"peerDependencies": {
"@sveltejs/kit": "^2.4.0"
2 changes: 1 addition & 1 deletion packages/enhanced-img/package.json
Original file line number Diff line number Diff line change
@@ -49,7 +49,7 @@
"svelte": "^5.2.9",
"typescript": "^5.6.3",
"vite": "^6.0.1",
"vitest": "^2.1.6"
"vitest": "^3.0.1"
},
"peerDependencies": {
"svelte": "^5.0.0",
2 changes: 1 addition & 1 deletion packages/kit/package.json
Original file line number Diff line number Diff line change
@@ -43,7 +43,7 @@
"svelte-preprocess": "^6.0.0",
"typescript": "^5.3.3",
"vite": "^6.0.1",
"vitest": "^2.1.6"
"vitest": "^3.0.1"
},
"peerDependencies": {
"@sveltejs/vite-plugin-svelte": "^3.0.0 || ^4.0.0-next.1 || ^5.0.0",
2 changes: 1 addition & 1 deletion packages/kit/src/core/sync/write_types/index.spec.js
Original file line number Diff line number Diff line change
@@ -29,7 +29,7 @@ function run_test(dir) {
write_all_types(initial, manifest);
}

test('Creates correct $types', () => {
test('Creates correct $types', { timeout: 6000 }, () => {
// To save us from creating a real SvelteKit project for each of the tests,
// we first run the type generation directly for each test case, and then
// call `tsc` to check that the generated types are valid.
24 changes: 13 additions & 11 deletions packages/kit/test/build-errors/env.spec.js
Original file line number Diff line number Diff line change
@@ -3,55 +3,57 @@ import { execSync } from 'node:child_process';
import path from 'node:path';
import process from 'node:process';

test('$env/dynamic/private is not statically importable from the client', () => {
const timeout = 60_000;

test('$env/dynamic/private is not statically importable from the client', { timeout }, () => {
assert.throws(
() =>
execSync('pnpm build', {
cwd: path.join(process.cwd(), 'apps/private-dynamic-env'),
stdio: 'pipe',
timeout: 60000
timeout
}),
/.*Cannot import \$env\/dynamic\/private into client-side code:.*/gs
);
});

test('$env/dynamic/private is not dynamically importable from the client', () => {
test('$env/dynamic/private is not dynamically importable from the client', { timeout }, () => {
assert.throws(
() =>
execSync('pnpm build', {
cwd: path.join(process.cwd(), 'apps/private-dynamic-env-dynamic-import'),
stdio: 'pipe',
timeout: 60000
timeout
}),
/.*Cannot import \$env\/dynamic\/private into client-side code:.*/gs
);
});

test('$env/static/private is not statically importable from the client', () => {
test('$env/static/private is not statically importable from the client', { timeout }, () => {
assert.throws(
() =>
execSync('pnpm build', {
cwd: path.join(process.cwd(), 'apps/private-static-env'),
stdio: 'pipe',
timeout: 60000
timeout
}),
/.*Cannot import \$env\/static\/private into client-side code:.*/gs
);
});

test('$env/static/private is not dynamically importable from the client', () => {
test('$env/static/private is not dynamically importable from the client', { timeout }, () => {
assert.throws(
() =>
execSync('pnpm build', {
cwd: path.join(process.cwd(), 'apps/private-static-env-dynamic-import'),
stdio: 'pipe',
timeout: 60000
timeout
}),
/.*Cannot import \$env\/static\/private into client-side code:.*/gs
);
});

test('$env/dynamic/private is not importable from the service worker', () => {
test('$env/dynamic/private is not importable from the service worker', { timeout }, () => {
assert.throws(
() =>
execSync('pnpm build', {
@@ -63,13 +65,13 @@ test('$env/dynamic/private is not importable from the service worker', () => {
);
});

test('$env/dynamic/public is not importable from the service worker', () => {
test('$env/dynamic/public is not importable from the service worker', { timeout }, () => {
assert.throws(
() =>
execSync('pnpm build', {
cwd: path.join(process.cwd(), 'apps/service-worker-dynamic-public-env'),
stdio: 'pipe',
timeout: 60000
timeout
}),
/.*Cannot import \$env\/dynamic\/public into service-worker code.*/gs
);
2 changes: 1 addition & 1 deletion packages/kit/test/build-errors/package.json
Original file line number Diff line number Diff line change
@@ -8,6 +8,6 @@
},
"type": "module",
"devDependencies": {
"vitest": "^2.1.6"
"vitest": "^3.0.1"
}
}
10 changes: 6 additions & 4 deletions packages/kit/test/build-errors/prerender.spec.js
Original file line number Diff line number Diff line change
@@ -4,25 +4,27 @@ import path from 'node:path';
import { EOL } from 'node:os';
import process from 'node:process';

test('prerenderable routes must be prerendered', () => {
const timeout = 60_000;

test('prerenderable routes must be prerendered', { timeout }, () => {
assert.throws(
() =>
execSync('pnpm build', {
cwd: path.join(process.cwd(), 'apps/prerenderable-not-prerendered'),
stdio: 'pipe',
timeout: 60000
timeout
}),
/The following routes were marked as prerenderable, but were not prerendered because they were not found while crawling your app:\r?\n {2}- \/\[x\]/gs
);
});

test('entry generators should match their own route', () => {
test('entry generators should match their own route', { timeout }, () => {
assert.throws(
() =>
execSync('pnpm build', {
cwd: path.join(process.cwd(), 'apps/prerender-entry-generator-mismatch'),
stdio: 'pipe',
timeout: 60000
timeout
}),
`Error: The entries export from /[slug]/[notSpecific] generated entry /whatever/specific, which was matched by /[slug]/specific - see the \`handleEntryGeneratorMismatch\` option in https://svelte.dev/docs/kit/configuration#prerender for more info.${EOL}To suppress or handle this error, implement \`handleEntryGeneratorMismatch\` in https://svelte.dev/docs/kit/configuration#prerender`
);
18 changes: 10 additions & 8 deletions packages/kit/test/build-errors/server-only.spec.js
Original file line number Diff line number Diff line change
@@ -3,12 +3,14 @@ import { execSync } from 'node:child_process';
import path from 'node:path';
import process from 'node:process';

test('$lib/*.server.* is not statically importable from the client', () => {
const timeout = 60_000;

test('$lib/*.server.* is not statically importable from the client', { timeout }, () => {
try {
execSync('pnpm build', {
cwd: path.join(process.cwd(), 'apps/server-only-module'),
stdio: 'pipe',
timeout: 60000
timeout
});
} catch (err) {
assert.ok(
@@ -20,12 +22,12 @@ test('$lib/*.server.* is not statically importable from the client', () => {
throw new Error();
});

test('$lib/*.server.* is not dynamically importable from the client', () => {
test('$lib/*.server.* is not dynamically importable from the client', { timeout }, () => {
try {
execSync('pnpm build', {
cwd: path.join(process.cwd(), 'apps/server-only-module-dynamic-import'),
stdio: 'pipe',
timeout: 60000
timeout
});
} catch (err) {
assert.ok(
@@ -37,12 +39,12 @@ test('$lib/*.server.* is not dynamically importable from the client', () => {
throw new Error();
});

test('$lib/server/* is not statically importable from the client', () => {
test('$lib/server/* is not statically importable from the client', { timeout }, () => {
try {
execSync('pnpm build', {
cwd: path.join(process.cwd(), 'apps/server-only-folder'),
stdio: 'pipe',
timeout: 60000
timeout
});
} catch (err) {
assert.ok(
@@ -54,12 +56,12 @@ test('$lib/server/* is not statically importable from the client', () => {
throw new Error();
});

test('$lib/server/* is not dynamically importable from the client', () => {
test('$lib/server/* is not dynamically importable from the client', { timeout }, () => {
try {
execSync('pnpm build', {
cwd: path.join(process.cwd(), 'apps/server-only-folder-dynamic-import'),
stdio: 'pipe',
timeout: 60000
timeout
});
} catch (err) {
assert.ok(
6 changes: 4 additions & 2 deletions packages/kit/test/build-errors/syntax-error.spec.js
Original file line number Diff line number Diff line change
@@ -3,12 +3,14 @@ import { execSync } from 'node:child_process';
import path from 'node:path';
import process from 'node:process';

test('$lib/*.server.* is not statically importable from the client', () => {
const timeout = 60_000;

test('$lib/*.server.* is not statically importable from the client', { timeout }, () => {
try {
execSync('pnpm build', {
cwd: path.join(process.cwd(), 'apps/syntax-error'),
stdio: 'pipe',
timeout: 60000
timeout
});
} catch (err) {
assert.ok(
2 changes: 1 addition & 1 deletion packages/kit/test/prerendering/basics/package.json
Original file line number Diff line number Diff line change
@@ -17,7 +17,7 @@
"svelte-check": "^4.1.1",
"typescript": "^5.5.4",
"vite": "^6.0.1",
"vitest": "^2.1.6"
"vitest": "^3.0.1"
},
"type": "module"
}
2 changes: 1 addition & 1 deletion packages/kit/test/prerendering/options/package.json
Original file line number Diff line number Diff line change
@@ -16,7 +16,7 @@
"svelte-check": "^4.1.1",
"typescript": "^5.5.4",
"vite": "^6.0.1",
"vitest": "^2.1.6"
"vitest": "^3.0.1"
},
"type": "module"
}
2 changes: 1 addition & 1 deletion packages/kit/test/prerendering/paths-base/package.json
Original file line number Diff line number Diff line change
@@ -16,7 +16,7 @@
"svelte-check": "^4.1.1",
"typescript": "^5.5.4",
"vite": "^6.0.1",
"vitest": "^2.1.6"
"vitest": "^3.0.1"
},
"type": "module"
}
876 changes: 445 additions & 431 deletions pnpm-lock.yaml

Large diffs are not rendered by default.


Unchanged files with check annotations Beta

test.describe.configure({ mode: 'parallel' });
test.describe('a11y', () => {
test('resets focus', async ({ page, clicknav, browserName }) => {

Check warning on line 12 in packages/kit/test/apps/basics/test/cross-platform/client.test.js

GitHub Actions / test-kit-cross-browser (18, windows-2019, chromium, dev)

flaky test: resets focus

retries: 2
const tab = browserName === 'webkit' ? 'Alt+Tab' : 'Tab';
await page.goto('/accessibility/a');
expect(await page.evaluate(() => document.documentElement.getAttribute('tabindex'))).toBe(null);
});
test('applies autofocus after a navigation', async ({ page, clicknav }) => {

Check warning on line 36 in packages/kit/test/apps/basics/test/cross-platform/client.test.js

GitHub Actions / test-kit-cross-browser (18, windows-2019, chromium, dev)

flaky test: applies autofocus after a navigation

retries: 2
await page.goto('/accessibility/autofocus/a');
await clicknav('[href="/accessibility/autofocus/b"]');
const selector = '[data-testid="count"]';
expect(await page.textContent(selector)).toBe('count: 1');

Check warning on line 872 in packages/kit/test/apps/basics/test/cross-platform/client.test.js

GitHub Actions / test-kit-cross-browser (18, ubuntu-latest, firefox, build)

flaky test: responds to <form target="_blank"> submission with new tab

retries: 2
await page.locator(selector).click();
expect(await page.textContent(selector)).toBe('count: 1');
});
expect(
await page.evaluate(() => {
const links = Array.from(document.head.querySelectorAll('link[rel=stylesheet]'));

Check warning on line 1185 in packages/kit/test/apps/basics/test/client.test.js

GitHub Actions / test-kit (22, ubuntu-latest, chromium)

flaky test: Catches fetch errors from server load functions (direct hit)

retries: 2
for (let i = 0; i < links.length; ) {
const link = links.shift();
const asset_name = link.href.split('/').at(-1);
test.describe('Filesystem updates', () => {
if (process.env.DEV) {
test('New route is immediately available in dev', async ({ page }) => {

Check warning on line 14 in packages/kit/test/apps/writes/test/test.js

GitHub Actions / test-kit (22, ubuntu-latest, chromium)

flaky test: New route is immediately available in dev

retries: 2
await page.goto('/new-route');
// hash the filename so that it won't conflict with