mirror of
https://github.com/HamzaSha1/zod-backend.git
synced 2026-03-10 21:11:46 +00:00
feat:mvp1 initial commit
This commit is contained in:
35
jest.base.config.ts
Normal file
35
jest.base.config.ts
Normal file
@ -0,0 +1,35 @@
|
||||
import type { Config as JestConfig } from 'jest';
|
||||
import { pathsToModuleNameMapper } from 'ts-jest';
|
||||
import { compilerOptions as tsConfigCompilerOptions } from './tsconfig.json';
|
||||
|
||||
type ArrayElement<A> = A extends readonly (infer T)[] ? T : never;
|
||||
type JestProjectConfig = Exclude<ArrayElement<JestConfig['projects']>, string>;
|
||||
|
||||
const baseJestConfig: JestConfig = {
|
||||
// ...
|
||||
};
|
||||
const baseJestProjectConfig: JestProjectConfig = {
|
||||
testEnvironment: 'node',
|
||||
transform: {
|
||||
'^.+\\.(t|j)s$': 'ts-jest',
|
||||
},
|
||||
moduleNameMapper: pathsToModuleNameMapper(tsConfigCompilerOptions.paths, { prefix: '<rootDir>' }),
|
||||
globalSetup: '<rootDir>/test/global-setup.ts',
|
||||
};
|
||||
const projects: { name?: string; rootDir: string }[] = [{ rootDir: '.' }];
|
||||
|
||||
export function buildJestConfig(config?: {
|
||||
jestConfigs?: JestConfig;
|
||||
jestProjectConfigs?: JestProjectConfig;
|
||||
}): JestConfig {
|
||||
return {
|
||||
...baseJestConfig,
|
||||
...config?.jestConfigs,
|
||||
projects: projects.map(({ name, rootDir }) => ({
|
||||
...baseJestProjectConfig,
|
||||
...config?.jestProjectConfigs,
|
||||
...(name && { displayName: name }),
|
||||
rootDir,
|
||||
})),
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user