Initial testing framework

This commit is contained in:
adilallo
2025-08-28 21:17:27 -06:00
parent f9ff2d0c08
commit 165f7f8179
15 changed files with 9400 additions and 60 deletions
+29 -29
View File
@@ -1,35 +1,35 @@
import path from 'node:path';
import { fileURLToPath } from 'node:url';
import { defineConfig } from "vitest/config";
import react from "@vitejs/plugin-react";
import { defineConfig } from 'vitest/config';
import { storybookTest } from '@storybook/addon-vitest/vitest-plugin';
const dirname =
typeof __dirname !== 'undefined' ? __dirname : path.dirname(fileURLToPath(import.meta.url));
// More info at: https://storybook.js.org/docs/next/writing-tests/integrations/vitest-addon
export default defineConfig({
plugins: [
// Enables React transform
react({ jsxRuntime: "automatic" }),
],
// Key part: make .js be parsed as JSX *before* import-analysis
esbuild: {
jsx: "automatic",
loader: "jsx", // default loader
include: /(?:^|\/)(app|components|pages|src|tests)\/.*\.[jt]sx?$/, // match your folders
exclude: [/node_modules/],
},
test: {
projects: [
{
extends: true,
plugins: [
// The plugin will run tests for the stories defined in your Storybook config
// See options at: https://storybook.js.org/docs/next/writing-tests/integrations/vitest-addon#storybooktest
storybookTest({ configDir: path.join(dirname, '.storybook') }),
],
test: {
name: 'storybook',
browser: {
enabled: true,
headless: true,
provider: 'playwright',
instances: [{ browser: 'chromium' }]
},
setupFiles: ['.storybook/vitest.setup.js'],
},
},
environment: "jsdom",
setupFiles: ["./vitest.setup.ts"], // match your actual filename
include: [
"tests/unit/**/*.test.{js,jsx,ts,tsx}",
"tests/integration/**/*.test.{js,jsx,ts,tsx}",
],
css: true,
transformMode: { web: [/\.[jt]sx?$/] }, // ensure web transform for JSX
coverage: {
provider: "v8",
reporter: ["text", "lcov"],
thresholds: { lines: 85, functions: 85, statements: 85, branches: 80 },
},
pool: "threads",
testTimeout: 10000,
},
});