@@ -9,6 +9,7 @@ const TestInteraction = require("./TestInteraction");
99const TestSuite = require ( "./TestSuite" ) ;
1010const Util = require ( "../util/Util" ) ;
1111const yaml = require ( "js-yaml-bespoken" ) ;
12+ const { isEmpty, get } = require ( "lodash" ) ;
1213
1314/**
1415 * Represents the parser used for converting a yaml file into a test suite
@@ -78,7 +79,7 @@ class TestParser {
7879 . map ( ( interaction ) => {
7980 const expected = interaction . expected ;
8081 const expressions = interaction . expressions ;
81- const hasExpressions = expressions && expressions . length > 0 ;
82+ const hasExpressions = expressions && expressions . length > 0 ;
8283 if ( expected . length === 1
8384 && expected [ 0 ] . action === "prompt"
8485 && ! Array . isArray ( expected [ 0 ] . value )
@@ -124,7 +125,7 @@ class TestParser {
124125 */
125126 parse ( configurationOverride ) {
126127 try {
127- const contents = this . findReplace ( this . contents ) ;
128+ const contents = this . findReplace ( this . contents , configurationOverride ) ;
128129 const documents = yaml . loadAll ( contents ) ;
129130 let configuration ;
130131 let tests = documents ;
@@ -470,8 +471,15 @@ class TestParser {
470471 * @param {string } script - the yaml file as a string
471472 * @return {string }
472473 */
473- findReplace ( script ) {
474- const findReplaceMap = Configuration . instance ( ) && Configuration . instance ( ) . findReplaceMap ( ) ;
474+ findReplace ( script , configurationOverride = { } ) {
475+ let findReplaceMap = { } ;
476+
477+ if ( isEmpty ( get ( configurationOverride , "findReplace" ) ) ) {
478+ findReplaceMap = Configuration . instance ( ) && Configuration . instance ( ) . findReplaceMap ( ) ;
479+ } else {
480+ findReplaceMap = get ( configurationOverride , "findReplace" , { } ) ;
481+ }
482+
475483 if ( ! findReplaceMap ) return script ;
476484 for ( const find of Object . keys ( findReplaceMap ) ) {
477485 const value = findReplaceMap [ find ] ;
0 commit comments