dennisbergevin / cypress-plugin-last-failed

A companion Cypress plugin for `cy-grep` that re-runs the last failed test(s).
MIT License
12 stars 2 forks source link

feat: Reformat last-run failed test file as json for easier readability #8

Closed dennisbergevin closed 4 months ago

dennisbergevin commented 4 months ago

Overview

Relates to: Reformat last-run failed test file as json for easier readability #7

Reformats the test-results/last-run file to a .json to improve readability of the failed test file, showing spec, parent (suite) name, and test name.

Example test-results/last-run.json file after a cypress run showing failed tests (spec, parent(s), test):

[
  {
    "spec": "cypress/e2e/spec.cy.ts",
    "parent": ["template spec"],
    "test": "fails"
  },
  {
    "spec": "cypress/e2e/1-getting-started/todo.cy.js",
    "parent": ["example to-do app"],
    "test": "can check off an item as completed"
  },
  {
    "spec": "cypress/e2e/2-advanced-examples/assertions.cy.js",
    "parent": ["Assertions", "Explicit Assertions"],
    "test": "pass your own callback function to should()"
  }
]

Example CI run: https://github.com/dennisbergevin/cypress-plugin-last-failed/actions/runs/9734252741/job/26862054893

Parent suite title(s) inclusive

In addition to the specific test title, the grep will also use the parent suite title(s) preceding the test title to guard against the scenario when the same test title could be in a different spec file.

Example:

cy-grep: tests with "Should run expected tests should run; Should run expected tests needs to run; Should run expected tests will be included in failed tests" in their names