Skip to content

Commit

Permalink
test: ensure root option is set
Browse files Browse the repository at this point in the history
  • Loading branch information
aleclarson committed Nov 19, 2024
1 parent 0dc9a8b commit 16ef4b1
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions test/plugin.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { readdirSync, readFileSync } from 'fs'
import { join, resolve } from 'path'
import { execa } from 'execa'
import * as vite from 'vite'
import tsconfigPaths from '../src/index.js'
import tsconfigPaths, { type PluginOptions } from '../src/index.js'

const tscBinPath = resolve(__dirname, '../node_modules/.bin/tsc')

Expand Down Expand Up @@ -39,7 +39,7 @@ async function expectViteToSucceed(config: TestConfig) {
vite.build({
configFile: false,
root: config.root,
plugins: [tsconfigPaths()],
plugins: [tsconfigPaths(config.options)],
logLevel: 'error',
build: {
lib: {
Expand All @@ -55,7 +55,10 @@ type TestConfig = ReturnType<typeof readTestConfig>

function readTestConfig(fixtureDir: string) {
let config: {
/** Vite project root */
root?: string
/** Plugin options */
options?: PluginOptions
}
try {
config = JSON.parse(readFileSync(join(fixtureDir, 'config.json'), 'utf-8'))
Expand All @@ -68,5 +71,9 @@ function readTestConfig(fixtureDir: string) {
return {
root: fixtureDir,
...config,
options: {
...config.options,
root: resolve(fixtureDir, config.options?.root ?? config.root ?? ''),
},
}
}

0 comments on commit 16ef4b1

Please sign in to comment.