Skip to content

Commit b6c3480

Browse files
committed
Fix tests
1 parent 4c7cfc9 commit b6c3480

5 files changed

Lines changed: 54 additions & 6 deletions

File tree

apps/tests/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
"@solidjs/router": "0.17.0-next.1",
1919
"@solidjs/start": "workspace:*",
2020
"@solidjs/testing-library": "^0.8.10",
21+
"@solidjs/signals": "0.13.3",
2122
"@solidjs/web": "2.0.0-beta.3",
2223
"@testing-library/jest-dom": "^6.9.1",
2324
"@testing-library/user-event": "^14.6.1",

apps/tests/src/routes/treeshaking/(no-side-effects).tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { createAsync } from "@solidjs/router";
1+
import { createMemo } from "solid-js";
22

33
const a = 1;
44

@@ -13,6 +13,6 @@ async function getGetA() {
1313
}
1414

1515
export default function Treeshaking() {
16-
const s = createAsync(() => getGetA());
16+
const s = createMemo(() => getGetA());
1717
return <h1>hello: {s()}</h1>;
1818
}

apps/tests/src/routes/treeshaking/side-effects.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { createAsync } from "@solidjs/router";
1+
import { createMemo } from "solid-js";
22

33
export const a = 1;
44

@@ -13,7 +13,7 @@ async function getGetA() {
1313
}
1414

1515
export default function TreeshakingSideEffects() {
16-
const s = createAsync(() => getGetA());
16+
const s = createMemo(() => getGetA());
1717
return (
1818
<h1>
1919
hello:{a} {s()}

apps/tests/vitest.config.ts

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,53 @@
1+
import { createRequire } from "node:module";
12
import solid from "vite-plugin-solid";
23
import { defineConfig } from "vitest/config";
34
import { playwright } from "@vitest/browser-playwright";
45

6+
const require = createRequire(import.meta.url);
7+
58
export default defineConfig({
69
plugins: [solid()],
10+
resolve: {
11+
alias: {
12+
"solid-js/web": "@solidjs/web",
13+
"solid-js/store": "solid-js",
14+
},
15+
conditions: ["solid", "development", "browser"],
16+
},
17+
optimizeDeps: {
18+
include: ["@solidjs/testing-library"],
19+
esbuildOptions: {
20+
plugins: [
21+
{
22+
name: "solid-compat",
23+
setup(build) {
24+
// Let Vite resolve @solidjs/web at runtime with proper conditions
25+
build.onResolve({ filter: /^solid-js\/web$/ }, () => ({
26+
path: "@solidjs/web",
27+
external: true,
28+
}));
29+
build.onResolve({ filter: /^solid-js\/store$/ }, () => ({
30+
path: require.resolve("solid-js"),
31+
}));
32+
// Shim onMount/onError removed in Solid v2 for @solidjs/testing-library compat
33+
build.onResolve({ filter: /^solid-js$/ }, (args) => {
34+
if (args.importer?.includes("@solidjs/testing-library")) {
35+
return { path: args.path, namespace: "solid-compat" };
36+
}
37+
});
38+
build.onLoad({ filter: /.*/, namespace: "solid-compat" }, () => ({
39+
contents: `
40+
export * from ${JSON.stringify(require.resolve("solid-js"))};
41+
export function onMount(fn) { queueMicrotask(fn); }
42+
export function onError() {}
43+
`,
44+
resolveDir: ".",
45+
}));
46+
},
47+
},
48+
],
49+
},
50+
},
751
test: {
852
mockReset: true,
953
globals: true,

pnpm-lock.yaml

Lines changed: 5 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)