Skip to content

Commit

Permalink
chore: upgrade to vitest 3 (#13330)
Browse files Browse the repository at this point in the history
* chore: upgrade to vitest 3

* increase timeout

* more timeout

* more

* more

* more
  • Loading branch information
benmccann authored Jan 20, 2025
1 parent 537cd1b commit 702575e
Show file tree
Hide file tree
Showing 16 changed files with 489 additions and 467 deletions.
2 changes: 1 addition & 1 deletion packages/adapter-auto/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion packages/adapter-netlify/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion packages/adapter-node/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,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",
Expand Down
2 changes: 1 addition & 1 deletion packages/adapter-vercel/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,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"
Expand Down
2 changes: 1 addition & 1 deletion packages/enhanced-img/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion packages/kit/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,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",
Expand Down
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
Expand Up @@ -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.
Expand Down
24 changes: 13 additions & 11 deletions packages/kit/test/build-errors/env.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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', {
Expand All @@ -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
);
Expand Down
2 changes: 1 addition & 1 deletion packages/kit/test/build-errors/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Up @@ -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`
);
Expand Down
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
Expand Up @@ -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(
Expand All @@ -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(
Expand All @@ -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(
Expand All @@ -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(
Expand Down
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
Expand Up @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion packages/kit/test/prerendering/basics/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Up @@ -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
Expand Up @@ -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"
}
Loading

0 comments on commit 702575e

Please sign in to comment.