Skip to content

Commit 2f3a007

Browse files
dominikgteemingcbenmccann
authored
chore: test matrix dimension for vite (#15208)
this allows us to test with different vite majors --- ### Please don't delete this checklist! Before submitting the PR, please make sure you do the following: - [ ] It's really useful if your PR references an issue where it is discussed ahead of time. In many cases, features are absent for a reason. For large changes, please create an RFC: https://github.com/sveltejs/rfcs - [x] This message body should clearly illustrate what problems it solves. - [ ] Ideally, include a test that fails without this PR but passes with it. ### Tests - [x] Run the tests with `pnpm test` and lint the project with `pnpm lint` and `pnpm check` ### Changesets - [ ] If your PR makes a change that should be noted in one or more packages' changelogs, generate a changeset by running `pnpm changeset` and following the prompts. Changesets that add features should be `minor` and those that fix bugs should be `patch`. Please prefix changeset messages with `feat:`, `fix:`, or `chore:`. ### Edits - [x] Please ensure that 'Allow edits from maintainers' is checked. PRs without this option may be closed. --------- Co-authored-by: Tee Ming <[email protected]> Co-authored-by: Ben McCann <[email protected]>
1 parent 159aece commit 2f3a007

File tree

40 files changed

+254
-131
lines changed

40 files changed

+254
-131
lines changed

.github/workflows/ci.yml

Lines changed: 30 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -54,17 +54,26 @@ jobs:
5454
- node-version: 18
5555
os: ubuntu-latest
5656
e2e-browser: 'chromium'
57+
vite: 'baseline'
5758
- node-version: 20
5859
os: ubuntu-latest
5960
e2e-browser: 'chromium'
61+
vite: 'current'
6062
- node-version: 22
6163
os: ubuntu-latest
6264
e2e-browser: 'chromium'
65+
vite: 'current'
6366
- node-version: 24
6467
os: ubuntu-latest
6568
e2e-browser: 'chromium'
69+
vite: 'current'
70+
- node-version: 24
71+
os: ubuntu-latest
72+
e2e-browser: 'chromium'
73+
vite: 'beta'
6674
env:
6775
KIT_E2E_BROWSER: ${{matrix.e2e-browser}}
76+
MATRIX_VITE: ${{matrix.vite}}
6877
steps:
6978
- run: git config --global core.autocrlf false
7079
- uses: actions/checkout@v6
@@ -74,6 +83,13 @@ jobs:
7483
node-version: ${{ matrix.node-version }}
7584
cache: pnpm
7685
- run: pnpm install --frozen-lockfile
86+
- name: setup overrides for matrix.vite
87+
if: matrix.vite != 'current'
88+
run: | # copies catalogs.vite-xxx to overrides in pnpm-workspace.yaml so the subsequent `pnpm install` enforces them
89+
yq -i '.overrides =.catalogs."vite-${{matrix.vite}}"' pnpm-workspace.yaml
90+
pnpm install --no-frozen-lockfile
91+
git checkout pnpm-lock.yaml pnpm-workspace.yaml # revert changes to pnpm files to avoid cache key changes
92+
pnpm --dir packages/kit ls vite
7793
- run: pnpm playwright install ${{ matrix.e2e-browser }}
7894
- run: pnpm run sync-all
7995
- run: pnpm test:kit
@@ -90,7 +106,7 @@ jobs:
90106
uses: actions/upload-artifact@v6
91107
with:
92108
retention-days: 3
93-
name: test-failure-${{ github.run_id }}-${{ matrix.os }}-${{ matrix.node-version }}-${{ matrix.e2e-browser }}
109+
name: test-failure-${{ github.run_id }}-${{ matrix.os }}-${{ matrix.node-version }}-${{ matrix.e2e-browser }}-vite-${{matrix.vite}}
94110
path: test-results.tar.gz
95111
test-kit-cross-browser:
96112
runs-on: ${{ matrix.os }}
@@ -99,27 +115,27 @@ jobs:
99115
fail-fast: false
100116
matrix:
101117
include:
102-
- node-version: 18
118+
- node-version: 24
103119
os: windows-latest
104120
e2e-browser: 'chromium'
105121
mode: 'dev'
106-
- node-version: 18
122+
- node-version: 24
107123
os: ubuntu-latest
108124
e2e-browser: 'firefox'
109125
mode: 'dev'
110-
- node-version: 18
126+
- node-version: 24
111127
os: macOS-latest
112128
e2e-browser: 'webkit'
113129
mode: 'dev'
114-
- node-version: 18
130+
- node-version: 24
115131
os: windows-latest
116132
e2e-browser: 'chromium'
117133
mode: 'build'
118-
- node-version: 18
134+
- node-version: 24
119135
os: ubuntu-latest
120136
e2e-browser: 'firefox'
121137
mode: 'build'
122-
- node-version: 18
138+
- node-version: 24
123139
os: macOS-latest
124140
e2e-browser: 'webkit'
125141
mode: 'build'
@@ -235,6 +251,13 @@ jobs:
235251
with:
236252
deno-version: ^2.2.4
237253
- run: pnpm install --frozen-lockfile
254+
- name: setup overrides for matrix.node
255+
if: matrix.node-version == 18
256+
run: | # copies catalogs.node-xx to overrides in pnpm-workspace.yaml so the subsequent `pnpm install` enforces them
257+
yq -i '.overrides =.catalogs."node-18"' pnpm-workspace.yaml
258+
pnpm install --no-frozen-lockfile
259+
git checkout pnpm-lock.yaml pnpm-workspace.yaml # revert changes to pnpm files to avoid cache key changes
260+
pnpm --dir packages/kit ls vite @sveltejs/vite-plugin-svelte
238261
- run: pnpm playwright install chromium
239262
- run: cd packages/kit && pnpm prepublishOnly
240263
- run: pnpm run test:others

packages/adapter-cloudflare/test/utils.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { devices } from '@playwright/test';
22
import process from 'node:process';
3+
import { number_from_env } from '../../../test-utils/index.js';
34

45
/** @type {import('@playwright/test').PlaywrightTestConfig} */
56
export const config = {
@@ -10,7 +11,7 @@ export const config = {
1011
command: process.env.DEV ? 'pnpm dev' : 'pnpm build && pnpm preview',
1112
port: process.env.DEV ? 5173 : 8787
1213
},
13-
retries: process.env.CI ? 2 : 0,
14+
retries: process.env.CI ? 2 : number_from_env('KIT_E2E_RETRIES', 0),
1415
projects: [
1516
{
1617
name: 'chromium'
@@ -21,7 +22,7 @@ export const config = {
2122
screenshot: 'only-on-failure',
2223
trace: 'retain-on-failure'
2324
},
24-
workers: process.env.CI ? 2 : undefined,
25+
workers: process.env.CI ? 2 : number_from_env('KIT_E2E_WORKERS', undefined),
2526
reporter: 'list',
2627
testDir: 'test',
2728
testMatch: /(.+\.)?(test|spec)\.[jt]s/

packages/adapter-netlify/test/utils.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { devices } from '@playwright/test';
22
import process from 'node:process';
3+
import { number_from_env } from '../../../test-utils/index.js';
34

45
/** @type {import('@playwright/test').PlaywrightTestConfig} */
56
export const config = {
@@ -10,7 +11,7 @@ export const config = {
1011
command: 'pnpm build && pnpm preview',
1112
port: 8888
1213
},
13-
retries: process.env.CI ? 2 : 0,
14+
retries: process.env.CI ? 2 : number_from_env('KIT_E2E_RETRIES', 0),
1415
projects: [
1516
{
1617
name: 'chromium'
@@ -21,7 +22,7 @@ export const config = {
2122
screenshot: 'only-on-failure',
2223
trace: 'retain-on-failure'
2324
},
24-
workers: process.env.CI ? 2 : undefined,
25+
workers: process.env.CI ? 2 : number_from_env('KIT_E2E_WORKERS', undefined),
2526
reporter: 'list',
2627
testDir: 'test',
2728
testMatch: /(.+\.)?(test|spec)\.[jt]s/

packages/adapter-static/test/utils.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { devices } from '@playwright/test';
22
import process from 'node:process';
3+
import { number_from_env } from '../../../test-utils/index.js';
34

45
/** @type {import('@playwright/test').PlaywrightTestConfig} */
56
export const config = {
@@ -10,7 +11,7 @@ export const config = {
1011
command: 'pnpm build && pnpm preview',
1112
port: 5173
1213
},
13-
retries: process.env.CI ? 2 : 0,
14+
retries: process.env.CI ? 2 : number_from_env('KIT_E2E_RETRIES', 0),
1415
projects: [
1516
{
1617
name: 'chromium'
@@ -21,7 +22,7 @@ export const config = {
2122
screenshot: 'only-on-failure',
2223
trace: 'retain-on-failure'
2324
},
24-
workers: process.env.CI ? 2 : undefined,
25+
workers: process.env.CI ? 2 : number_from_env('KIT_E2E_WORKERS', undefined),
2526
reporter: 'list',
2627
testDir: 'test',
2728
testMatch: /(.+\.)?(test|spec)\.[jt]s/

packages/enhanced-img/test/apps/basics/test/test.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
import { expect, test } from '@playwright/test';
2-
2+
import process from 'node:process';
3+
const is_node18 = process.versions.node.startsWith('18.');
4+
// TODO: remove with SvelteKit 3
5+
test.skip(is_node18, 'enhanced-img requires vite-plugin-svelte@6 which requires node20');
36
test('images are properly rendered', async ({ page }) => {
47
await page.goto('/');
58

packages/enhanced-img/test/utils.js

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,22 @@
11
import { devices } from '@playwright/test';
22
import process from 'node:process';
3+
import { number_from_env } from '../../../test-utils/index.js';
34

5+
// TODO: remove with SvelteKit 3
6+
const is_node18 = process.versions.node.startsWith('18.');
47
/** @type {import('@playwright/test').PlaywrightTestConfig} */
58
export const config = {
69
forbidOnly: !!process.env.CI,
710
// generous timeouts on CI
811
timeout: process.env.CI ? 45000 : 15000,
9-
webServer: {
10-
command: 'pnpm build && pnpm preview',
11-
port: 4173
12-
},
13-
retries: process.env.CI ? 2 : 0,
12+
webServer: is_node18
13+
? undefined
14+
: {
15+
// do not try to build on node18
16+
command: 'pnpm build && pnpm preview',
17+
port: 4173
18+
},
19+
retries: process.env.CI ? 2 : number_from_env('KIT_E2E_RETRIES', 0),
1420
projects: [
1521
{
1622
name: 'chromium'
@@ -21,7 +27,7 @@ export const config = {
2127
screenshot: 'only-on-failure',
2228
trace: 'retain-on-failure'
2329
},
24-
workers: process.env.CI ? 2 : undefined,
30+
workers: process.env.CI ? 2 : number_from_env('KIT_E2E_WORKERS', undefined),
2531
reporter: 'list',
2632
testDir: 'test',
2733
testMatch: /(.+\.)?(test|spec)\.[jt]s/

packages/kit/src/core/sync/write_types/index.spec.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { execSync } from 'node:child_process';
22
import fs from 'node:fs';
33
import path from 'node:path';
4+
import process from 'node:process';
45
import { fileURLToPath } from 'node:url';
56
import { assert, expect, test } from 'vitest';
67
import { rimraf } from '../../../utils/filesystem.js';
@@ -43,7 +44,11 @@ test('Creates correct $types', { timeout: 60000 }, () => {
4344
for (const dir of directories) {
4445
run_test(dir);
4546
try {
46-
execSync('pnpm testtypes', { cwd: path.join(cwd, dir) });
47+
// we skip lib check if MATRIX_VITE is set and not 'current' because overrides for vite can cause type mismatches
48+
const skipLibCheck = process.env.MATRIX_VITE != null && process.env.MATRIX_VITE !== 'current';
49+
execSync(`pnpm testtypes${skipLibCheck ? ' --skipLibCheck' : ''}`, {
50+
cwd: path.join(cwd, dir)
51+
});
4752
} catch (e) {
4853
console.error(/** @type {any} */ (e).stdout.toString());
4954
throw new Error(`${dir} type tests failed`);

packages/kit/test/apps/async/src/routes/remote/event/+page.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<script>
2-
import { get_event } from './data.remote.js';
2+
import { get_event } from './data.remote.ts';
33
44
const event = await get_event();
55
</script>

packages/kit/test/apps/async/src/routes/remote/form/[test_name]/+page.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<script>
2-
import { get_message, set_message, resolve_deferreds } from './form.remote.js';
2+
import { get_message, set_message, resolve_deferreds } from './form.remote.ts';
33
44
const { params } = $props();
55

packages/kit/test/apps/async/src/routes/remote/form/preflight-only/+page.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<script>
2-
import { get, set } from './form.remote.js';
2+
import { get, set } from './form.remote.ts';
33
import * as v from 'valibot';
44
55
const data = get();

0 commit comments

Comments
 (0)