fix(testing): set TS_NODE_PROJECT before running Jest so j.config.ts file transpile using the root tsconfig file (#20372)

This commit is contained in:
Jack Hsu 2023-11-22 16:23:24 -05:00 committed by GitHub
parent d2b444c23b
commit 729bb5c398
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -15,6 +15,8 @@ import {
import { getSummary } from './summary'; import { getSummary } from './summary';
import { readFileSync } from 'fs'; import { readFileSync } from 'fs';
import type { BatchResults } from 'nx/src/tasks-runner/batch/batch-messages'; import type { BatchResults } from 'nx/src/tasks-runner/batch/batch-messages';
import { getRootTsConfigPath } from '@nx/js';
process.env.NODE_ENV ??= 'test'; process.env.NODE_ENV ??= 'test';
export async function jestExecutor( export async function jestExecutor(
@ -22,6 +24,7 @@ export async function jestExecutor(
context: ExecutorContext context: ExecutorContext
): Promise<{ success: boolean }> { ): Promise<{ success: boolean }> {
const config = await jestConfigParser(options, context); const config = await jestConfigParser(options, context);
process.env['TS_NODE_PROJECT'] ??= getRootTsConfigPath();
const { results } = await runCLI(config, [options.jestConfig]); const { results } = await runCLI(config, [options.jestConfig]);