File tree Expand file tree Collapse file tree 1 file changed +8
-4
lines changed
Expand file tree Collapse file tree 1 file changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -4,7 +4,11 @@ import * as fs from 'fs';
44import { SpecificationFile } from './hooks/validation' ;
55import { Context } from './hooks/context/models' ;
66
7- export const CONTEXTFILE_PATH = path . resolve ( os . homedir ( ) , '.asyncapi' ) ;
7+ const isTestEnv = ( process . env [ 'NODE_ENV' ] === 'test' ) || ( process . env [ 'JEST_WORKER_ID' ] !== undefined ) || typeof jest !== 'undefined' ;
8+
9+ export const CONTEXT_FILENAME = isTestEnv ? ".test.asyncapi" : ".asyncapi" ;
10+
11+ export const CONTEXTFILE_PATH = path . resolve ( os . homedir ( ) , CONTEXT_FILENAME ) ;
812
913export class ContextTestingHelper {
1014 private _context : Context ;
@@ -25,14 +29,14 @@ export class ContextTestingHelper {
2529 }
2630
2731 createDummyContextFile ( ) {
28- fs . writeFileSync ( CONTEXTFILE_PATH , JSON . stringify ( this . _context ) , { encoding : 'utf-8' } ) ;
32+ fs . writeFileSync ( CONTEXTFILE_PATH , JSON . stringify ( this . _context ) , { encoding : 'utf-8' } ) ;
2933 }
3034
3135 deleteDummyContextFile ( ) {
32- if ( fs . existsSync ( CONTEXTFILE_PATH ) ) fs . unlinkSync ( CONTEXTFILE_PATH ) ;
36+ if ( fs . existsSync ( CONTEXTFILE_PATH ) ) fs . unlinkSync ( CONTEXTFILE_PATH ) ;
3337 }
3438
35- getPath ( key : string ) {
39+ getPath ( key : string ) {
3640 return this . _context . store [ key ] ;
3741 }
3842}
You can’t perform that action at this time.
0 commit comments