fix(tests): fix tests run fail in the Chinese directory (#3586)

This commit is contained in:
ygj6 2021-05-29 22:04:32 +08:00 committed by GitHub
parent 4afb743547
commit 3cab2c2202
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 12 additions and 5 deletions

View File

@ -48,7 +48,6 @@
"rimraf": "^3.0.2",
"semver": "^7.3.4",
"sirv": "^1.0.10",
"slash": "^3.0.0",
"ts-jest": "^27.0.1",
"ts-node": "^9.1.1",
"typescript": "^4.1.2",

View File

@ -4,10 +4,13 @@
import fs from 'fs'
import path from 'path'
import slash from 'slash'
import colors from 'css-color-names'
import { ElementHandle } from 'playwright-chromium'
export function slash(p: string): string {
return p.replace(/\\/g, '/')
}
export const isBuild = !!process.env.VITE_TEST_BUILD
const testPath = expect.getState().testPath

View File

@ -2,10 +2,8 @@
const fs = require('fs')
const path = require('path')
const chalk = require('chalk')
const slash = require('slash')
const { parse } = require('@babel/parser')
const MagicString = require('magic-string').default
const tempDir = path.resolve(__dirname, '../temp/node')
const typesDir = path.resolve(__dirname, '../types')
@ -15,6 +13,10 @@ const typesDir = path.resolve(__dirname, '../types')
walkDir(tempDir)
console.log(chalk.green.bold(`patched types/* imports`))
function slash(p) {
return p.replace(/\\/g, '/')
}
/**
* @param {string} dir
*/

View File

@ -1,13 +1,16 @@
import fs from 'fs-extra'
import * as http from 'http'
import { resolve, dirname } from 'path'
import slash from 'slash'
import sirv from 'sirv'
import { createServer, build, ViteDevServer, UserConfig } from 'vite'
import { Page } from 'playwright-chromium'
const isBuildTest = !!process.env.VITE_TEST_BUILD
export function slash(p: string): string {
return p.replace(/\\/g, '/')
}
// injected by the test env
declare global {
// eslint-disable-next-line @typescript-eslint/no-namespace