Skip to content

Commit

Permalink
fix(js-vitest,ts-vitest): force vitest to transform solid-testing-lib…
Browse files Browse the repository at this point in the history
…rary

For why this is necessary, see solidjs/solid-testing-library#10.
  • Loading branch information
thislooksfun committed Jul 4, 2022
1 parent 492c5a2 commit 3fd1a8e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 11 deletions.
18 changes: 11 additions & 7 deletions js-vitest/vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,28 @@ import { defineConfig } from 'vite';
import solidPlugin from 'vite-plugin-solid';

export default defineConfig({
plugins: [solidPlugin()],
test: {
globals: true,
environment: 'jsdom',
globals: true,
transformMode: {
web: [/\.jsx?$/],
},
setupFiles: './setupVitest.js',
// solid needs to be inline to work around
// a resolution issue in vitest:
deps: {
inline: [/solid-js/],
// solid and solid-testing-library need to be inline to work around a
// resolution issue in vitest. If you encounter an error like:
// `'solid-js/web' does not provide an export named 'hydrate'`,
// you probably need to add something to this list. Setting this to
// `[/node_modules/`] will almost certainly solve the problem, but might
// impact performance.
inline: [/solid-js/, /solid-testing-library/],
},
// if you have few tests, try commenting one
// or both out to improve performance:
// threads: false,
// isolate: false,
threads: false,
isolate: false,
},
plugins: [solidPlugin()],
build: {
target: 'esnext',
polyfillDynamicImport: false,
Expand Down
13 changes: 9 additions & 4 deletions ts-vitest/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,15 @@ export default defineConfig({
web: [/\.[jt]sx?$/],
},
setupFiles: './setupVitest.ts',
// solid needs to be inline to work around
// a resolution issue in vitest:
deps: {
inline: [/solid-js/],
// solid and solid-testing-library need to be inline to work around a
// resolution issue in vitest. If you encounter an error like:
// `'solid-js/web' does not provide an export named 'hydrate'`,
// you probably need to add something to this list. Setting this to
// `[/node_modules/`] will almost certainly solve the problem, but might
// impact performance. For more infor see solidjs/solid-testing-library#10
// and vitest-dev/vitest#1588.
inline: [/solid-js/, /solid-testing-library/],
},
// if you have few tests, try commenting one
// or both out to improve performance:
Expand All @@ -29,5 +34,5 @@ export default defineConfig({
},
resolve: {
conditions: ['development', 'browser'],
}
},
});

0 comments on commit 3fd1a8e

Please sign in to comment.