Skip to content

Commit 408819a

Browse files
test: add snapshot for app generator unit test
1 parent ccfccf1 commit 408819a

File tree

2 files changed

+244
-0
lines changed

2 files changed

+244
-0
lines changed
Lines changed: 237 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,237 @@
1+
// Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+
exports[`qwik-nx generator should run successfully 1`] = `
4+
"import { qwikVite } from '@builder.io/qwik/optimizer';
5+
import { qwikCity } from '@builder.io/qwik-city/vite';
6+
import { defineConfig } from 'vite';
7+
import tsconfigPaths from 'vite-tsconfig-paths';
8+
import { qwikNxVite } from 'qwik-nx/plugins';
9+
10+
export default defineConfig({
11+
plugins: [
12+
qwikNxVite(),
13+
qwikCity(),
14+
qwikVite({
15+
client: {
16+
outDir: '../../dist/apps/myapp/client',
17+
},
18+
ssr: {
19+
outDir: '../../dist/apps/myapp/server',
20+
},
21+
}),
22+
tsconfigPaths({ root: '../../' })
23+
],
24+
server: {
25+
fs: {
26+
// Allow serving files from the project root
27+
allow: ['../../'],
28+
},
29+
},
30+
preview: {
31+
headers: {
32+
'Cache-Control': 'public, max-age=600',
33+
},
34+
},
35+
36+
});
37+
"
38+
`;
39+
40+
exports[`qwik-nx generator should run successfully 2`] = `
41+
"{
42+
\\"name\\": \\"myapp\\",
43+
\\"$schema\\": \\"../../node_modules/nx/schemas/project-schema.json\\",
44+
\\"projectType\\": \\"application\\",
45+
\\"sourceRoot\\": \\"apps/myapp/src\\",
46+
\\"targets\\": {
47+
\\"build\\": {
48+
\\"executor\\": \\"qwik-nx:build\\",
49+
\\"options\\": {
50+
\\"runSequence\\": [
51+
\\"myapp:build.client\\",
52+
\\"myapp:build.ssr\\"
53+
],
54+
\\"outputPath\\": \\"dist/apps/myapp\\"
55+
},
56+
\\"configurations\\": {
57+
\\"preview\\": {}
58+
}
59+
},
60+
\\"build.client\\": {
61+
\\"executor\\": \\"@nrwl/vite:build\\",
62+
\\"options\\": {
63+
\\"outputPath\\": \\"dist/apps/myapp\\",
64+
\\"configFile\\": \\"apps/myapp/vite.config.ts\\"
65+
}
66+
},
67+
\\"build.ssr\\": {
68+
\\"executor\\": \\"@nrwl/vite:build\\",
69+
\\"defaultConfiguration\\": \\"preview\\",
70+
\\"options\\": {
71+
\\"outputPath\\": \\"dist/apps/myapp\\"
72+
},
73+
\\"configurations\\": {
74+
\\"preview\\": {
75+
\\"ssr\\": \\"src/entry.preview.tsx\\",
76+
\\"mode\\": \\"production\\"
77+
}
78+
}
79+
},
80+
\\"preview\\": {
81+
\\"executor\\": \\"@nrwl/vite:preview-server\\",
82+
\\"options\\": {
83+
\\"buildTarget\\": \\"myapp:build\\"
84+
}
85+
},
86+
\\"serve\\": {
87+
\\"executor\\": \\"@nrwl/vite:dev-server\\",
88+
\\"options\\": {
89+
\\"buildTarget\\": \\"myapp:build.client\\",
90+
\\"mode\\": \\"ssr\\"
91+
}
92+
},
93+
\\"serve.debug\\": {
94+
\\"executor\\": \\"nx:run-commands\\",
95+
\\"options\\": {
96+
\\"command\\": \\"node --inspect-brk ../../node_modules/vite/bin/vite.js --mode ssr --force\\",
97+
\\"cwd\\": \\"apps/myapp\\"
98+
}
99+
}
100+
},
101+
\\"tags\\": []
102+
}
103+
"
104+
`;
105+
106+
exports[`qwik-nx generator should run successfully 3`] = `
107+
Array [
108+
Object {
109+
"path": ".prettierrc",
110+
"type": "CREATE",
111+
},
112+
Object {
113+
"path": "package.json",
114+
"type": "CREATE",
115+
},
116+
Object {
117+
"path": "nx.json",
118+
"type": "CREATE",
119+
},
120+
Object {
121+
"path": "tsconfig.base.json",
122+
"type": "CREATE",
123+
},
124+
Object {
125+
"path": "apps/.gitignore",
126+
"type": "CREATE",
127+
},
128+
Object {
129+
"path": "libs/.gitignore",
130+
"type": "CREATE",
131+
},
132+
Object {
133+
"path": "apps/myapp/project.json",
134+
"type": "CREATE",
135+
},
136+
Object {
137+
"path": "apps/myapp/.eslintrc.json",
138+
"type": "CREATE",
139+
},
140+
Object {
141+
"path": "apps/myapp/.prettierignore",
142+
"type": "CREATE",
143+
},
144+
Object {
145+
"path": "apps/myapp/README.md",
146+
"type": "CREATE",
147+
},
148+
Object {
149+
"path": "apps/myapp/package.json",
150+
"type": "CREATE",
151+
},
152+
Object {
153+
"path": "apps/myapp/public/favicon.svg",
154+
"type": "CREATE",
155+
},
156+
Object {
157+
"path": "apps/myapp/public/manifest.json",
158+
"type": "CREATE",
159+
},
160+
Object {
161+
"path": "apps/myapp/public/robots.txt",
162+
"type": "CREATE",
163+
},
164+
Object {
165+
"path": "apps/myapp/src/components/header/header.css",
166+
"type": "CREATE",
167+
},
168+
Object {
169+
"path": "apps/myapp/src/components/header/header.tsx",
170+
"type": "CREATE",
171+
},
172+
Object {
173+
"path": "apps/myapp/src/components/icons/qwik.tsx",
174+
"type": "CREATE",
175+
},
176+
Object {
177+
"path": "apps/myapp/src/components/router-head/router-head.tsx",
178+
"type": "CREATE",
179+
},
180+
Object {
181+
"path": "apps/myapp/src/entry.dev.tsx",
182+
"type": "CREATE",
183+
},
184+
Object {
185+
"path": "apps/myapp/src/entry.preview.tsx",
186+
"type": "CREATE",
187+
},
188+
Object {
189+
"path": "apps/myapp/src/entry.ssr.tsx",
190+
"type": "CREATE",
191+
},
192+
Object {
193+
"path": "apps/myapp/src/global.css",
194+
"type": "CREATE",
195+
},
196+
Object {
197+
"path": "apps/myapp/src/root.tsx",
198+
"type": "CREATE",
199+
},
200+
Object {
201+
"path": "apps/myapp/src/routes/flower/flower.css",
202+
"type": "CREATE",
203+
},
204+
Object {
205+
"path": "apps/myapp/src/routes/flower/index.tsx",
206+
"type": "CREATE",
207+
},
208+
Object {
209+
"path": "apps/myapp/src/routes/index.tsx",
210+
"type": "CREATE",
211+
},
212+
Object {
213+
"path": "apps/myapp/src/routes/layout.tsx",
214+
"type": "CREATE",
215+
},
216+
Object {
217+
"path": "apps/myapp/src/routes/service-worker.ts",
218+
"type": "CREATE",
219+
},
220+
Object {
221+
"path": "apps/myapp/tsconfig.app.json",
222+
"type": "CREATE",
223+
},
224+
Object {
225+
"path": "apps/myapp/tsconfig.json",
226+
"type": "CREATE",
227+
},
228+
Object {
229+
"path": "apps/myapp/tsconfig.spec.json",
230+
"type": "CREATE",
231+
},
232+
Object {
233+
"path": "apps/myapp/vite.config.ts",
234+
"type": "CREATE",
235+
},
236+
]
237+
`;

packages/qwik-nx/src/generators/application/generator.spec.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,13 @@ describe('qwik-nx generator', () => {
3434
await generator(appTree, defaultOptions);
3535
const config = readProjectConfiguration(appTree, 'myapp');
3636
expect(config).toBeDefined();
37+
expect(
38+
appTree.read('apps/myapp/vite.config.ts', 'utf-8')
39+
).toMatchSnapshot();
40+
expect(appTree.read('apps/myapp/project.json', 'utf-8')).toMatchSnapshot();
41+
expect(
42+
appTree.listChanges().map((c) => ({ path: c.path, type: c.type }))
43+
).toMatchSnapshot();
3744
});
3845

3946
describe('e2e project', () => {

0 commit comments

Comments
 (0)