Skip to content

Commit

Permalink
fix(vitest-angular): set watch mode flag when passed from CLI args (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
brandonroberts authored Dec 17, 2024
1 parent aafebef commit f4fbe77
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
12 changes: 10 additions & 2 deletions packages/vite-plugin-angular/src/lib/angular-vite-plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ export function angular(options?: PluginOptions): Plugin[] {
let nextProgram: NgtscProgram | undefined | ts.Program;
let builderProgram: ts.EmitAndSemanticDiagnosticsBuilderProgram;
let watchMode = false;
let testWatchMode = false;
let testWatchMode = process.env['ANALOG_VITEST_WATCH'] === 'true';
const sourceFileCache = new SourceFileCache();
const isTest = process.env['NODE_ENV'] === 'test' || !!process.env['VITEST'];
const isStackBlitz = !!process.versions['webcontainer'];
Expand Down Expand Up @@ -214,7 +214,15 @@ export function angular(options?: PluginOptions): Plugin[] {
},
configResolved(config) {
resolvedConfig = config;
testWatchMode = !(config.server.watch === null);

// set test watch mode
// - environment variable from vitest-angular
// - @nx/vite executor set server.watch explicitly to undefined (watch)/null (watch=false)
// - vite config for test.watch variable
testWatchMode =
testWatchMode ||
!(config.server.watch === null) ||
config.test?.watch === true;
},
configureServer(server) {
viteServer = server;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ async function vitestBuilder(
): Promise<BuilderOutput> {
process.env['TEST'] = 'true';
process.env['VITEST'] = 'true';
process.env['ANALOG_VITEST_WATCH'] = `${options.watch === true}`;

const { startVitest } = await (Function(
'return import("vitest/node")'
Expand Down

0 comments on commit f4fbe77

Please sign in to comment.