2

I am trying to inject a json as an argument value within npm script, like this: (https://medium.com/typeforms-engineering-blog/codeceptjs-puppeteer-setting-up-multiple-configurations-32d95e65adf2)

"scripts": {
        "example": "bash -c 'cat ./sample.json | tr -d ' \t\n\r''",
        "test:override": "codeceptjs run --steps --config ./codecept.conf.js --override <expecting_output_json_here_from_example_script>",
    }

The first script command 'example' executes well and displays the output json correctly in the console (same as input):

 {
   "helpers":{
   "Puppeteer":{
     "url":"http://yahoo.com",
     "show":false,
     "windowSize":"1920x1080"
   }
 }

however, I couldn't find the way to pass it as an argument value for the --override in the "test:override" script

I have tried various StackOverflow questions/answers, however, I couldn't find a way to achieve it.

I am using Git Bash in VS Code in Win10.

Please suggest a solution/alternate approach or point me to the right document/SO question.

To the best of my knowledge and efforts, I believe that it is not a duplicate question.

picsoung
  • 6,314
  • 1
  • 18
  • 35
curiousTester
  • 121
  • 1
  • 12
  • Did you try ```"test:override": "codeceptjs run --steps --config ./codecept.conf.js --override $(npm run example)"```? – edemaine Jul 06 '21 at 21:58
  • hi @edemaine, yes, tried that one already, however, the script just fails with JSON error, saying '$' at line 0 – curiousTester Jul 07 '21 at 01:31
  • How about `"test:override": "bash -c 'codeceptjs run --steps --config ./codecept.conf.js --override $(npm run example)'"` – edemaine Jul 07 '21 at 17:51

0 Answers0