With Vitest getting "computations created outside a createRoot
or render
will never be disposed"
#1720
Replies: 4 comments 4 replies
-
Without seeing your vite(st) config and the code of the Button you are using, I could only take wild guesses at the source of the issue. |
Beta Was this translation helpful? Give feedback.
-
Thanks for quick response @atk // vite.config.ts
/// <reference types="vitest" />
import { defineConfig } from 'vite';
import solidPlugin from 'vite-plugin-solid';
import path from 'node:path';
import dts from 'vite-plugin-dts';
export default defineConfig({
plugins: [
solidPlugin(),
dts({
insertTypesEntry: true
})
],
build: {
lib: {
entry: path.resolve(__dirname, 'src/index.ts'),
name: 'components',
fileName: 'index'
},
target: 'esnext',
rollupOptions: {
external: ['solid-js']
}
},
test: {
environment: 'jsdom',
transformMode: {
web: [/\.[jt]sx?$/]
},
deps: {
inline: [/solid-js/]
},
threads: false,
isolate: false
}
}); And my import { clsx } from 'clsx';
import { JSX, Show, mergeProps, splitProps, createMemo } from 'solid-js';
export type ButtonVariant = 'primary' | 'secondary' | 'tertiary' | 'naked';
export type ButtonSize = 'xl' | 'lg' | 'md' | 'sm' | 'xs';
export interface ButtonProps extends JSX.ButtonHTMLAttributes<HTMLButtonElement> {
variant?: ButtonVariant;
size?: ButtonSize;
iconLeft?: JSX.Element;
}
export default function Button(props: ButtonProps) {
const merged = mergeProps({ variant: 'primary', size: 'lg' }, props);
const [otherProps, buttonProps] = splitProps(merged, ['variant', 'size', 'children', 'iconLeft']);
const buttonClasses = createMemo(() =>
clsx('font-semibold', {
'shadow-sm': otherProps.variant !== 'naked',
// etc, more styles
})
);
return (
<button {...buttonProps} class={buttonClasses()} type="button">
<Show when={otherProps?.iconLeft}>{otherProps?.iconLeft}</Show>
{merged.children}
</button>
);
} |
Beta Was this translation helpful? Give feedback.
-
Sorry that it took so long. The issue is the It seems the documentation was already fixed, because there's no mention of deps on this site anymore. |
Beta Was this translation helpful? Give feedback.
-
Hey there 👋 Running into this issue in a new setup (setting up a complex monorepo).
This ☝️ shows up once per test. I have tried all combinations of config and the issue persists. I am afraid it might be more than just noise and more complex tests . I have branched the repository for reproduction. sake. Moving on with my sprint, might have more details once I start adding the actual production code. Help appreciated 🙇 |
Beta Was this translation helpful? Give feedback.
-
I'm following the new documentation for Vitest closely and getting this error for each of my custom elements used in the test:
Following this code snippet, I'm even getting this error with a simple button component:
Beta Was this translation helpful? Give feedback.
All reactions