trigo / trigo-web /vitest.config.ts
k-l-lambda's picture
updated
502af73
import { defineConfig, Plugin } from 'vitest/config'
import vue from '@vitejs/plugin-vue'
import { fileURLToPath } from 'node:url'
// Plugin to handle /lib/tgnParser.cjs imports in Node.js environment
const libParserPlugin: Plugin = {
name: 'lib-parser-bypass',
enforce: 'pre',
transform(code, id) {
// Only transform parserInit.ts
if (id.includes('parserInit')) {
// Replace import calls of /lib/tgnParser.cjs with a marker that won't be analyzed
return code.replace(
/await import\(.*?\/lib\/tgnParser\.cjs/g,
'await import("" + "/lib/tgnParser.cjs'
)
}
}
}
export default defineConfig({
plugins: [libParserPlugin, vue()],
test: {
globals: true,
environment: 'node', // Changed from jsdom to node since we're testing pure logic
include: ['tests/**/*.test.ts'], // All tests
},
resolve: {
alias: {
'@': fileURLToPath(new URL('./app/src', import.meta.url)),
'@inc': fileURLToPath(new URL('./inc', import.meta.url))
}
},
ssr: {
external: ['/lib/tgnParser.cjs']
}
})