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