Skip to content

Commit

Permalink
fix(vite-plugin-angular): honour user's test.pool choice (#1080)
Browse files Browse the repository at this point in the history
  • Loading branch information
yjaaidi authored May 3, 2024
1 parent f1f1298 commit b3d27eb
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 2 deletions.
33 changes: 33 additions & 0 deletions packages/vite-plugin-angular/src/lib/angular-vitest-plugin.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { describe, it, expect } from 'vitest';
import { angularVitestPlugin } from './angular-vitest-plugin';
import { defineConfig, resolveConfig } from 'vite';

describe(angularVitestPlugin.name, () => {
/* Setting the pool to vmThreads by default to avoid issues related to global conflicts when using JSDOM.
* This also aligns with the default pool setting in Jest.
* This is not ideal as vmThreads comes with its own set of issues, but it's the best option we have for now.
* Cf. https://github.com/vitest-dev/vitest/issues/4685
* Cf. https://vitest.dev/config/#vmthreads */
it('should set pool to vmThreads', async () => {
const config = await resolveConfig(
defineConfig({
plugins: [angularVitestPlugin()],
}),
'serve'
);
expect(config.test?.pool).toBe('vmThreads');
});

it('should not override pool option if already set by user', async () => {
const config = await resolveConfig(
defineConfig({
plugins: [angularVitestPlugin()],
test: {
pool: 'threads',
},
}),
'serve'
);
expect(config.test?.pool).toBe('threads');
});
});
4 changes: 2 additions & 2 deletions packages/vite-plugin-angular/src/lib/angular-vitest-plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ export function angularVitestPlugin(): Plugin {
name: '@analogjs/vitest-angular-esm-plugin',
apply: 'serve',
enforce: 'post',
config() {
config(userConfig) {
return {
ssr: {
noExternal: [/cdk\/fesm2022/],
},
test: {
pool: 'vmThreads',
pool: userConfig.test?.pool ?? 'vmThreads',
},
} as UserConfig;
},
Expand Down

0 comments on commit b3d27eb

Please sign in to comment.