Skip to content

Commit 81e5f04

Browse files
Add SolidStart test
1 parent 92e5405 commit 81e5f04

File tree

1 file changed

+108
-0
lines changed

1 file changed

+108
-0
lines changed

integrations/vite/solidstart.test.ts

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
import { candidate, css, fetchStyles, js, json, retryAssertion, test, ts } from '../utils'
2+
3+
const WORKSPACE = {
4+
'package.json': json`
5+
{
6+
"type": "module",
7+
"dependencies": {
8+
"@solidjs/start": "^1",
9+
"solid-js": "^1",
10+
"vinxi": "^0",
11+
"@tailwindcss/vite": "workspace:^",
12+
"tailwindcss": "workspace:^"
13+
}
14+
}
15+
`,
16+
'jsconfig.json': json`
17+
{
18+
"compilerOptions": {
19+
"jsx": "preserve",
20+
"jsxImportSource": "solid-js"
21+
}
22+
}
23+
`,
24+
'app.config.js': ts`
25+
import { defineConfig } from '@solidjs/start/config'
26+
import tailwindcss from '@tailwindcss/vite'
27+
28+
export default defineConfig({
29+
vite: {
30+
plugins: [tailwindcss()],
31+
},
32+
})
33+
`,
34+
'src/entry-server.jsx': js`
35+
// @refresh reload
36+
import { createHandler, StartServer } from '@solidjs/start/server'
37+
38+
export default createHandler(() => (
39+
<StartServer
40+
document={({ assets, children, scripts }) => (
41+
<html lang="en">
42+
<head>{assets}</head>
43+
<body>
44+
<div id="app">{children}</div>
45+
{scripts}
46+
</body>
47+
</html>
48+
)}
49+
/>
50+
))
51+
`,
52+
'src/entry-client.jsx': js`
53+
// @refresh reload
54+
import { mount, StartClient } from '@solidjs/start/client'
55+
56+
mount(() => <StartClient />, document.getElementById('app'))
57+
`,
58+
'src/app.jsx': js`
59+
import './app.css'
60+
export default function App() {
61+
return <h1 class="underline">Hello world!</h1>
62+
}
63+
`,
64+
'src/app.css': css`@import 'tailwindcss';`,
65+
}
66+
67+
test(
68+
'dev mode',
69+
{
70+
fs: WORKSPACE,
71+
},
72+
async ({ fs, spawn, expect }) => {
73+
let process = await spawn('pnpm vinxi dev', {
74+
env: {
75+
TEST: 'false', // VERY IMPORTANT OTHERWISE YOU WON'T GET OUTPUT
76+
NODE_ENV: 'development',
77+
},
78+
})
79+
80+
let url = ''
81+
await process.onStdout((m) => {
82+
let match = /Local:\s*(http.*)\//.exec(m)
83+
if (match) url = match[1]
84+
return Boolean(url)
85+
})
86+
87+
await retryAssertion(async () => {
88+
let css = await fetchStyles(url)
89+
expect(css).toContain(candidate`underline`)
90+
})
91+
92+
await retryAssertion(async () => {
93+
await fs.write(
94+
'src/app.jsx',
95+
js`
96+
import './app.css'
97+
export default function App() {
98+
return <h1 class="underline font-bold">Hello world!</h1>
99+
}
100+
`,
101+
)
102+
103+
let css = await fetchStyles(url)
104+
expect(css).toContain(candidate`underline`)
105+
expect(css).toContain(candidate`font-bold`)
106+
})
107+
},
108+
)

0 commit comments

Comments
 (0)