bahmutov / cypress-split

Split Cypress specs across parallel CI machines for speed
MIT License
201 stars 23 forks source link

feat: split specs based on timings from a JSON file #125

Closed bahmutov closed 9 months ago

bahmutov commented 9 months ago

Split specs based on timings

If you know the spec timings, you can create a JSON file and pass the timings to this plugin. The list of specs will be split into N machines to make the total durations for each machine approximately equal. You can see an example timings.json file:

{
  "durations": [
    {
      "spec": "cypress/e2e/chunks.cy.js",
      "duration": 300
    },
    {
      "spec": "cypress/e2e/spec-a.cy.js",
      "duration": 10050
    },
    ...
  ]
}

You can pass the JSON filename via SPLIT_FILE environment variable or Cypressenv variable.

# split all specs across 3 machines using known spec timings
# loaded from "timings.json" file
$ SPLIT_FILE=timings.json SPLIT=3 npx cypress run

# the equivalent syntax using Cypress --env argument
$ npx cypress run --env split=3,splitFile=timings.json

For specs not in the timings file, it will use average duration of the known specs.

github-actions[bot] commented 9 months ago

:tada: This PR is included in version 1.7.0 :tada:

The release is available on:

Your semantic-release bot :package::rocket: