Initial testing framework
This commit is contained in:
+29
-29
@@ -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,
|
||||
},
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user