1- import { resolve } from 'path' ;
1+ import { TsJestGlobalOptions } from '../types' ;
2+ import { resolve , relative } from 'path' ;
3+ import spyThese from './spy-these' ;
4+ import realFs from 'fs' ;
25
3- export function filePathMock ( relPath : string ) : string {
6+ export function filePath ( relPath : string ) : string {
47 return resolve ( __dirname , '..' , '..' , relPath ) ;
58}
69
7- export function transpiledTsSourceMock ( ) {
10+ export const rootDir = filePath ( '' ) ;
11+
12+ export function transpiledTsSource ( ) {
813 return `
914"use strict";
1015var __importDefault = (this && this.__importDefault) || function (mod) {
@@ -23,7 +28,7 @@ describe('hello', function () {
2328` ;
2429}
2530
26- export function tsSourceMock ( ) {
31+ export function typescriptSource ( ) {
2732 return `
2833import upper from './upper';
2934import lower from './lower';
@@ -39,3 +44,24 @@ describe('hello', () => {
3944});
4045` ;
4146}
47+
48+ export function tsJestConfig < T extends TsJestGlobalOptions > (
49+ options ?: TsJestGlobalOptions ,
50+ ) : T {
51+ return { ...options } as any ;
52+ }
53+
54+ export function jestConfig < T extends jest . ProjectConfig > (
55+ options ?: jest . InitialOptions ,
56+ tsJestOptions ?: TsJestGlobalOptions ,
57+ ) : T {
58+ const res = {
59+ globals : { } ,
60+ moduleFileExtensions : [ 'ts' , 'js' ] ,
61+ ...options ,
62+ } as any ;
63+ if ( tsJestOptions ) {
64+ res . globals [ 'ts-jest' ] = tsJestConfig ( tsJestOptions ) ;
65+ }
66+ return res ;
67+ }
0 commit comments