Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Addon Test: Merge viteFinal config into vitest config #29806

Merged
merged 9 commits into from
Dec 10, 2024
9 changes: 8 additions & 1 deletion code/addons/test/src/vitest-plugin/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/* eslint-disable no-underscore-dangle */
import type { Plugin } from 'vitest/config';
import { mergeConfig } from 'vitest/config';

import {
getInterpretedFile,
Expand Down Expand Up @@ -71,8 +72,11 @@ export const storybookTest = (options?: UserOptions): Plugin => {
return {
name: 'vite-plugin-storybook-test',
enforce: 'pre',
async config(config) {
async config(input) {
JReinhold marked this conversation as resolved.
Show resolved Hide resolved
let config = input;

const configDir = finalOptions.configDir;

try {
await validateConfigurationFiles(configDir);
} catch (err) {
Expand Down Expand Up @@ -130,6 +134,9 @@ export const storybookTest = (options?: UserOptions): Plugin => {
// plugin.name?.startsWith('vitest:browser')
// )

const viteConfigFromStorybook = await presets.apply('viteFinal', {});
config = mergeConfig(viteConfigFromStorybook, config);
ndelangen marked this conversation as resolved.
Show resolved Hide resolved
ndelangen marked this conversation as resolved.
Show resolved Hide resolved

config.test ??= {};

if (config.test.include?.length > 0) {
Expand Down
Loading