Skip to content

Commit

Permalink
chore: fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
antfu committed Jun 13, 2021
1 parent 3531c0f commit 4d8f397
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
4 changes: 2 additions & 2 deletions packages/playground/fs-serve/__tests__/fs-serve.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { isBuild } from '../../testUtils'

const json = require('../../json/test.json')
const json = require('../safe.json')
const stringified = JSON.stringify(json)

if (!isBuild) {
Expand All @@ -9,7 +9,7 @@ if (!isBuild) {
})

test('named import', async () => {
expect(await page.textContent('.named')).toBe(json.hello)
expect(await page.textContent('.named')).toBe(json.msg)
})

test('safe fetch', async () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,17 @@
import { resolve } from 'path'
import { dirname } from 'path'
import { defineConfig } from 'vite'

const root = resolve(__dirname, 'root')

export default defineConfig({
root,
server: {
fsServe: {
root,
root: __dirname,
strict: true
},
hmr: {
overlay: false
}
},
define: {
ROOT: JSON.stringify(__dirname.replace(/\\/g, '/'))
ROOT: JSON.stringify(dirname(__dirname).replace(/\\/g, '/'))
}
})
6 changes: 5 additions & 1 deletion scripts/jestPerTestSetup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,12 @@ beforeAll(async () => {
return
}

// when `root` dir is present, use it as vite's root
let testCustomRoot = resolve(tempDir, 'root')
if (!fs.existsSync(testCustomRoot)) testCustomRoot = tempDir

const options: UserConfig = {
root: tempDir,
root: testCustomRoot,
logLevel: 'silent',
server: {
watch: {
Expand Down

0 comments on commit 4d8f397

Please sign in to comment.