Run scripts on a VM before or after a test

On Windows machines, if you need to run scripts on a VM before or after running Cypress tests, perform the following configuration steps:

  1. In the perfecto-config.json file, add a new option called runScripts that can contain any of the following:

    • A before key, where the value is the name of the script that should be run before Cypress tests

    • An after key, where the value is the name of the script that should be run after Cypress tests

    Copy

    Sample code with before and after key

    "runScripts": {
      "before" : "test",
      "after" : "endtest"
    },
  2. In the package.json file, add a scripts object. For more information, see the documentation.

    The key name must match the script name that is defined in the perfecto-config.json file.

    Copy

    Sample code

    "scripts": {
      "test": "echo this script will run before cypress tests",
      "endtest": "echo this script will run after cypress tests"
    },