Skip to content

Commit ae854cb

Browse files
authored
chore: fix test setup (#1307)
* fix * revert to type assertion * revert * comment * comment
1 parent b325bcb commit ae854cb

File tree

6 files changed

+215
-220
lines changed

6 files changed

+215
-220
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
"typescript": "^5.9.3",
5757
"typescript-eslint": "^8.57.0",
5858
"vite": "^8.0.0-beta.7",
59-
"vitest": "^4.0.15"
59+
"vitest": "^4.1.0"
6060
},
6161
"lint-staged": {
6262
"*.{js,ts,svelte,html,md,svx}": "eslint --cache --fix",

packages/e2e-tests/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"devDependencies": {
66
"css-color-names": "^1.0.1",
77
"tree-kill": "^1.2.2",
8-
"vitest": "^4.0.15"
8+
"vitest": "^4.1.0"
99
},
1010
"type": "module"
1111
}

packages/e2e-tests/tsconfig.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
"include": ["."],
33
"exclude": ["**/dist/**", "**/build/**", "**/node_modules/**"],
44
"compilerOptions": {
5+
// TODO: we should enable strict type checking at some point
6+
// "strict": true,
57
"target": "ESNext",
68
"module": "ESNext",
79
"outDir": "dist",

packages/e2e-tests/vitestSetup.ts

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import fs from 'fs-extra';
22
import path from 'node:path';
33
import process from 'node:process';
44
import { chromium, type Browser, type Page } from 'playwright-core';
5-
import { beforeAll, type File } from 'vitest';
5+
import { beforeAll, type RunnerTestFile } from 'vitest';
66
import os from 'node:os';
77
import { fileURLToPath } from 'node:url';
88

@@ -80,11 +80,19 @@ const getUniqueTestPort = async (testRoot, testName, testMode) => {
8080
const DIR = path.join(os.tmpdir(), 'vitest_playwright_global_setup');
8181

8282
beforeAll(
83-
async (s) => {
84-
const suite = s as File;
83+
// eslint-disable-next-line no-empty-pattern -- The 1st argument inside a fixture must use object destructuring pattern, e.g. ({ task } => {}). so we cannot use _ to signal that it's unused
84+
async ({}, s) => {
85+
const suite = s as RunnerTestFile;
8586
if (!suite.filepath.includes('e2e-tests')) {
8687
return;
8788
}
89+
90+
const testPath = suite.filepath;
91+
const segments = testPath.split('/');
92+
const testName = segments.includes('e2e-tests')
93+
? segments[segments.indexOf('e2e-tests') + 1]
94+
: null;
95+
8896
try {
8997
const wsEndpoint = fs.readFileSync(path.join(DIR, 'wsEndpoint'), 'utf-8');
9098
if (!wsEndpoint) {
@@ -94,12 +102,6 @@ beforeAll(
94102
browser = await chromium.connect(wsEndpoint);
95103
page = await browser.newPage();
96104

97-
const testPath = suite.filepath;
98-
const segments = testPath.split('/');
99-
const testName = segments.includes('e2e-tests')
100-
? segments[segments.indexOf('e2e-tests') + 1]
101-
: null;
102-
103105
// if this is a test placed under e2e-tests/xxx/__tests__
104106
// start a vite server in that directory.
105107
if (testName) {

0 commit comments

Comments
 (0)