mirror of
https://github.com/goauthentik/authentik.git
synced 2026-08-30 18:51:39 -07:00
web: Allow oxc to transform co-located unit tests. Vite 8's vite:oxc plugin does per-file tsconfig discovery and refuses to transform src/**/*.unit.test.ts because the root tsconfig.json excludes src/**/*.test.ts. Disable tsconfig discovery for the Node "Unit Tests" project so oxc transforms those files, leaving tsconfig.json's excludes and tsgo -p . untouched.
89 lines
3.3 KiB
JavaScript
89 lines
3.3 KiB
JavaScript
/// <reference types="vitest/config" />
|
|
|
|
import { join } from "node:path";
|
|
|
|
import { createBundleDefinitions } from "#bundler/utils/node";
|
|
import { inlineCSSPlugin } from "#bundler/vite-plugin-lit-css/node";
|
|
|
|
import { resolvePackage } from "@goauthentik/core/paths/node";
|
|
|
|
import { playwright } from "@vitest/browser-playwright";
|
|
import { defineConfig } from "vite";
|
|
|
|
const patternflyPath = resolvePackage("@patternfly/patternfly", import.meta);
|
|
|
|
export default defineConfig({
|
|
define: createBundleDefinitions(),
|
|
resolve: {
|
|
alias: {
|
|
"./assets/fonts": join(patternflyPath, "assets", "fonts"),
|
|
"./assets/pficon": join(patternflyPath, "assets", "pficon"),
|
|
},
|
|
},
|
|
optimizeDeps: {
|
|
// Fixes dependency resolution issue associated with `npm link`ed packages.
|
|
include: ["@goauthentik/api"],
|
|
},
|
|
plugins: [
|
|
// ---
|
|
inlineCSSPlugin(),
|
|
],
|
|
|
|
test: {
|
|
dir: "./test",
|
|
exclude: [
|
|
"**/node_modules/**",
|
|
"**/dist/**",
|
|
"**/out/**",
|
|
"**/.{idea,git,cache,output,temp}/**",
|
|
"**/{karma,rollup,webpack,vite,vitest,jest,ava,babel,nyc,cypress,tsup,build,eslint,prettier}.config.*",
|
|
],
|
|
projects: [
|
|
{
|
|
// The root `tsconfig.json` excludes `src/**/*.test.ts`, so `vite:oxc`'s
|
|
// per-file tsconfig discovery bails with `[TSCONFIG_ERROR] Tsconfig not
|
|
// found` on co-located `src/**/*.unit.test.ts`. Disabling tsconfig
|
|
// discovery for this Node project lets oxc transform those files while
|
|
// leaving `lint:types` (`tsgo -p .`) and the root excludes untouched.
|
|
// `tsconfig` is forwarded to oxc's transform at runtime but is omitted
|
|
// from vite's `OxcOptions` type, so the assertion adds it back to keep
|
|
// `tsgo -p .` clean.
|
|
oxc: /** @type {import("vite").OxcOptions & { tsconfig: false }} */ ({
|
|
tsconfig: false,
|
|
}),
|
|
test: {
|
|
include: ["./test/unit/**/*.{test,spec}.ts", "**/*.unit.{test,spec}.ts"],
|
|
name: "Unit Tests",
|
|
environment: "node",
|
|
typecheck: {
|
|
tsconfig: "./tsconfig.unit.json",
|
|
},
|
|
},
|
|
},
|
|
{
|
|
// Projects do not inherit the root plugin list, and elements
|
|
// import their stylesheets as text for `unsafeCSS`. Without
|
|
// this the CSS resolves to a Vite style side-effect with no
|
|
// default export, and importing any AKElement throws.
|
|
plugins: [inlineCSSPlugin()],
|
|
test: {
|
|
setupFiles: ["./test/lit/setup.js"],
|
|
|
|
include: ["./browser/**/*.{test,spec}.ts", "**/*.browser.{test,spec}.ts"],
|
|
name: "Browser Tests",
|
|
browser: {
|
|
enabled: true,
|
|
provider: playwright(),
|
|
|
|
instances: [
|
|
{
|
|
browser: "chromium",
|
|
},
|
|
],
|
|
},
|
|
},
|
|
},
|
|
],
|
|
},
|
|
});
|