1
1
import type * as http from 'node:http'
2
- import path , { dirname , resolve } from 'node:path '
3
- import fs from 'fs-extra '
2
+ import fs from 'node:fs '
3
+ import path from 'node:path '
4
4
import { chromium } from 'playwright-chromium'
5
5
import type {
6
6
ConfigEnv ,
@@ -25,7 +25,7 @@ import { beforeAll, inject } from 'vitest'
25
25
26
26
// #region env
27
27
28
- export const workspaceRoot = resolve ( __dirname , '../' )
28
+ export const workspaceRoot = path . resolve ( __dirname , '../' )
29
29
30
30
export const isBuild = ! ! process . env . VITE_TEST_BUILD
31
31
export const isServe = ! isBuild
@@ -125,20 +125,20 @@ beforeAll(async (s) => {
125
125
126
126
testPath = suite . filepath !
127
127
testName = slash ( testPath ) . match ( / p l a y g r o u n d \/ ( [ \w - ] + ) \/ / ) ?. [ 1 ]
128
- testDir = dirname ( testPath )
128
+ testDir = path . dirname ( testPath )
129
129
130
130
// if this is a test placed under playground/xxx/__tests__
131
131
// start a vite server in that directory.
132
132
if ( testName ) {
133
- testDir = resolve ( workspaceRoot , 'playground-temp' , testName )
133
+ testDir = path . resolve ( workspaceRoot , 'playground-temp' , testName )
134
134
135
135
// when `root` dir is present, use it as vite's root
136
- const testCustomRoot = resolve ( testDir , 'root' )
136
+ const testCustomRoot = path . resolve ( testDir , 'root' )
137
137
rootDir = fs . existsSync ( testCustomRoot ) ? testCustomRoot : testDir
138
138
139
139
const testCustomServe = [
140
- resolve ( dirname ( testPath ) , 'serve.ts' ) ,
141
- resolve ( dirname ( testPath ) , 'serve.js' ) ,
140
+ path . resolve ( path . dirname ( testPath ) , 'serve.ts' ) ,
141
+ path . resolve ( path . dirname ( testPath ) , 'serve.js' ) ,
142
142
] . find ( ( i ) => fs . existsSync ( i ) )
143
143
144
144
if ( testCustomServe ) {
@@ -182,7 +182,7 @@ async function loadConfig(configEnv: ConfigEnv) {
182
182
let config : UserConfig | null = null
183
183
184
184
// config file named by convention as the *.spec.ts folder
185
- const variantName = path . basename ( dirname ( testPath ) )
185
+ const variantName = path . basename ( path . dirname ( testPath ) )
186
186
if ( variantName !== '__tests__' ) {
187
187
const configVariantPath = path . resolve (
188
188
rootDir ,
0 commit comments