File tree 3 files changed +9
-7
lines changed
3 files changed +9
-7
lines changed Original file line number Diff line number Diff line change 1
1
{
2
2
"name" : " @eresearchqut/jest-testcontainers" ,
3
- "version" : " 3.6.0 " ,
3
+ "version" : " 3.6.1 " ,
4
4
"description" : " Jest preset for starting docker containers that stay up while your tests run." ,
5
5
"main" : " dist/index" ,
6
6
"types" : " dist/index" ,
Original file line number Diff line number Diff line change 1
1
import { readFileSync } from "fs" ;
2
2
import NodeEnvironment from "jest-environment-node" ;
3
- import { join } from "path" ;
4
3
import { Script } from "vm" ;
4
+ import { log } from "./logger" ;
5
+ import { GLOBAL_VARS_JSON_PATH } from "./setup" ;
5
6
6
- const GLOBAL_VARS_JSON_PATH = join ( __dirname , "global.vars.json" ) ;
7
7
8
8
export function setGlobalsWithJsonString ( globals : any , jsonString : string ) {
9
9
const globalVars = JSON . parse ( jsonString ) ;
10
10
const globalVarKeys = Object . keys ( globalVars ) ;
11
11
12
12
globalVarKeys . forEach ( globalVarKey => {
13
+ log . debug ( `${ globals [ globalVarKey ] } =${ globalVars [ globalVarKey ] } ` ) ;
13
14
// @ts -ignore
14
15
globals [ globalVarKey ] = globalVars [ globalVarKey ] ;
16
+
15
17
} ) ;
16
18
}
17
19
@@ -22,8 +24,8 @@ export class TestcontainersEnvironment extends NodeEnvironment {
22
24
}
23
25
24
26
public async setup ( ) {
27
+ log . debug ( `Reading global vars from ${ GLOBAL_VARS_JSON_PATH } ` ) ;
25
28
const globalVarsJsonString = readFileSync ( GLOBAL_VARS_JSON_PATH , "utf-8" ) ;
26
-
27
29
setGlobalsWithJsonString ( this . global , globalVarsJsonString ) ;
28
30
await super . setup ( ) ;
29
31
}
Original file line number Diff line number Diff line change 6
6
startAllContainers
7
7
} from "./containers" ;
8
8
9
- import { log } from "./logger" ;
10
9
11
- const GLOBAL_VARS_JSON_PATH = join ( __dirname , "global.vars.json" ) ;
10
+
11
+ export const GLOBAL_VARS_JSON_PATH = join ( __dirname , "global.vars.json" ) ;
12
12
const createEnv = ( name : string , key : string ) =>
13
13
`__TESTCONTAINERS_${ name . toUpperCase ( ) } _${ key . toUpperCase ( ) } __` ;
14
14
@@ -48,7 +48,7 @@ async function setup(opts: any) {
48
48
allStartedContainersMetaInfo
49
49
) ;
50
50
51
- log . debug ( `Writing global env: ${ JSON . stringify ( { location : GLOBAL_VARS_JSON_PATH , globalEnv } ) } ` ) ;
51
+
52
52
writeFileSync ( GLOBAL_VARS_JSON_PATH , JSON . stringify ( globalEnv ) , "utf-8" ) ;
53
53
// @ts -ignore
54
54
global . __TESTCONTAINERS__ = Object . values ( allStartedContainersMetaInfo ) . map (
You can’t perform that action at this time.
0 commit comments