Run multi command in testcafe

Viewed 28

Right now I'm using testcafe-blink-diff (ScreenCompare) to check UI, but right now need to run 3 command to run it (capture base, actual and compare base and actual , so in package.json in script, can we merge all 3 command in 1 keyword like this ?

"HomePage": "testcafe chrome tests/specs/HomePage.js

so we only need to call npm run HomePage, it will run all 3 command

1 Answers

You can create separate commands in your package and run them in HomePage with &&. For example:

{
  "scripts": {
    "HomePage:base": "testcafe chrome test.js -s tests/screenshots --take-snapshot base",
    "HomePage:actual": "testcafe chrome test.js -s tests/screenshots --take-snapshot actual",
    "HomePage:compare": "npx testcafe-blink-diff tests/screenshots --compare base:actual --open --threshold 0.03",
    "HomePage": "npm run HomePage:base && npm run HomePage:actual && npm run HomePage:compare"
  }
}
Related