Skip to content

Commit

Permalink
fix(tests): fix tests run fail in the Chinese directory (#3586)
Browse files Browse the repository at this point in the history
  • Loading branch information
ygj6 committed May 29, 2021
1 parent 4afb743 commit 3cab2c2
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 5 deletions.
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
5 changes: 4 additions & 1 deletion packages/playground/testUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 4 additions & 2 deletions packages/vite/scripts/patchTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')

Expand All @@ -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
*/
Expand Down
5 changes: 4 additions & 1 deletion scripts/jestPerTestSetup.ts
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit 3cab2c2

Please sign in to comment.