Skip to content

Commit 6b7f0f9

Browse files
committed
test: add test for vitests
1 parent 9433d58 commit 6b7f0f9

File tree

2 files changed

+9
-28
lines changed

2 files changed

+9
-28
lines changed

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

+9-23
Original file line numberDiff line numberDiff line change
@@ -201,37 +201,23 @@ describe('app', () => {
201201
`);
202202
});
203203

204-
it('should generate a modified vite config file to allow the poolOptions when vitest is the test runner', async () => {
204+
it('should generate a vitest config file to allow the poolOptions when vitest is the test runner', async () => {
205205
await applicationGenerator(tree, {
206206
name: 'myWorkerApp',
207207
directory: 'myWorkerApp',
208208
projectNameAndRootFormat: 'as-provided',
209209
});
210-
expect(tree.read('myWorkerApp/vite.config.ts', 'utf-8'))
210+
expect(tree.read('myWorkerApp/vitest.config.ts', 'utf-8'))
211211
.toMatchInlineSnapshot(`
212-
"import { defineConfig } from 'vite';
213-
214-
import { nxViteTsPaths } from '@nx/vite/plugins/nx-tsconfig-paths.plugin';
215-
216-
export default defineConfig({
217-
root: __dirname,
218-
cacheDir: '../node_modules/.vite/myWorkerApp',
219-
220-
plugins: [nxViteTsPaths()],
221-
222-
// Uncomment this if you are using workers.
223-
// worker: {
224-
// plugins: [ nxViteTsPaths() ],
225-
// },
212+
"import { defineWorkersConfig } from '@cloudflare/vitest-pool-workers/config';
226213
214+
export default defineWorkersConfig({
227215
test: {
228-
watch: false,
229-
globals: true,
230-
cache: { dir: '../node_modules/.vitest/myWorkerApp' },
231-
environment: 'node',
232-
include: ['src/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'],
233-
reporters: ['default'],
234-
coverage: { reportsDirectory: '../coverage/myWorkerApp', provider: 'v8' },
216+
poolOptions: {
217+
workers: {
218+
wrangler: { configPath: './wrangler.toml' },
219+
},
220+
},
235221
},
236222
});
237223
"

packages/nx-cloudflare/src/generators/application/generator.ts

-5
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,6 @@ export async function applicationGenerator(tree: Tree, schema: Schema) {
5656
coverageProvider: 'v8',
5757
skipFormat: true,
5858
testEnvironment: 'node',
59-
poolOptions: {
60-
workers: {
61-
wrangler: { configPath: './wrangler.toml' },
62-
},
63-
},
6459
});
6560
tasks.push(vitestTask);
6661
createOrEditViteConfig(

0 commit comments

Comments
 (0)