@@ -2,26 +2,30 @@ import {writeFile} from 'fs';
2
2
import { logger } from 'process-console-log' ;
3
3
import importPaths from './import-paths' ;
4
4
import exists from './helpers/exists' ;
5
- // import compiler from './helpers/ compiler';
5
+ // import compiler from './compiler';
6
6
import babelRegister from './helpers/babel-register' ;
7
+ import rewire from './helpers/rewire' ;
7
8
8
- export default function writeTest ( { dir, tests, testPath } : CombineTestsOptions ) {
9
- return new Promise ( ( resolve , reject ) => {
9
+ export default function writeTest ( { dir, tests, testPath } ) {
10
10
11
- // fix import paths relative to project dir instead of test runner
12
- const fixImports = importPaths ( dir , tests ) ;
13
- // const compiled = compiler(fixImports);
11
+ // fix import paths relative to project dir instead of test runner
12
+ const fixImports = importPaths ( dir , tests ) ;
13
+ // const compiled = compiler(fixImports);
14
14
15
- const output = ''
16
- // append logger
17
- . concat ( logger )
18
- // exists polyfill for file/folder exists checks
19
- . concat ( exists ( dir ) )
20
- // babel hook to handle import / export in other files
21
- . concat ( babelRegister )
22
- // compile using ts
23
- . concat ( fixImports ) ;
15
+ const output = '(function(){\n'
16
+ // babel hook to handle import / export in other files
17
+ . concat ( '// run time compiler\n' + babelRegister )
18
+ // append logger for capturing log values and types
19
+ . concat ( '// override console.log\n' + logger )
20
+ // exists polyfill for file/folder exists checks
21
+ . concat ( '// file exists function\n' + exists ( dir ) )
22
+ // allow access to module globals
23
+ . concat ( '// rewire\n' + rewire )
24
+ // fixed imports
25
+ . concat ( fixImports )
26
+ . concat ( '\n}());' ) ;
24
27
28
+ return new Promise ( ( resolve , reject ) => {
25
29
// write test file
26
30
writeFile ( testPath , output , ( err ) => {
27
31
if ( err ) { reject ( err ) ; }
0 commit comments