{
  "doc": {
    "id": "api/node-events/after-run-api",
    "title": "After Run Event | Cypress Node Events",
    "description": "The after:run event fires after a run is finished in Cypress.",
    "section": "api",
    "source_path": "/llm/markdown/api/node-events/after-run-api.md",
    "version": "3cf5b86b3403f604bdf7f3e35025c3bc3865e02c",
    "updated_at": "2026-05-07T17:44:31.931Z",
    "headings": [
      {
        "id": "api/node-events/after-run-api#after-run-event",
        "text": "After Run Event",
        "level": 1
      },
      {
        "id": "api/node-events/after-run-api#syntax",
        "text": "Syntax",
        "level": 2
      },
      {
        "id": "api/node-events/after-run-api#usage",
        "text": "Usage",
        "level": 2
      },
      {
        "id": "api/node-events/after-run-api#log-the-number-of-passed-tests-of-a-run",
        "text": "Log the number of passed tests of a run",
        "level": 3
      },
      {
        "id": "api/node-events/after-run-api#see-also",
        "text": "See also",
        "level": 2
      }
    ]
  },
  "chunks": [
    {
      "id": "api/node-events/after-run-api#syntax",
      "doc_id": "api/node-events/after-run-api",
      "heading": "Syntax",
      "heading_level": 2,
      "content_markdown": "## Syntax\n\n⚠️ This code is part of the [setupNodeEvents](/llm/markdown/app/plugins/plugins-guide.md#Using-a-plugin) function and thus executes in the Node environment. You cannot call `Cypress` or `cy` commands in this function, but you do have the direct access to the file system and the rest of the operating system.\n\n⚠️ When running via `cypress open`, the `after:run` event only fires if the [experimentalInteractiveRunEvents flag](/llm/markdown/app/references/configuration.md#Experiments) is enabled.\n\n*   cypress.config.js\n*   cypress.config.ts\n\n```\nconst { defineConfig } = require('cypress')module.exports = defineConfig({  // setupNodeEvents can be defined in either  // the e2e or component configuration  e2e: {    setupNodeEvents(on, config) {      on('after:run', (results) => {        /* ... */      })    },  },})\n```\n\n```\nimport { defineConfig } from 'cypress'export default defineConfig({  // setupNodeEvents can be defined in either  // the e2e or component configuration  e2e: {    setupNodeEvents(on, config) {      on('after:run', (results) => {        /* ... */      })    },  },})\n```\n\n**results _(Object)_**\n\nResults of the run, including the total number of passes/failures/etc, the project config, and details about the browser and system. It is the same as the results object resolved by the [Module API](/llm/markdown/app/references/module-api.md#Results).\n\nResults are only provided when running via `cypress run`. When running via `cypress open`, the results will be undefined.\n",
      "section": "api",
      "anchors": [
        "syntax"
      ],
      "path": "/llm/json/chunked/api/node-events/after-run-api.json",
      "token_estimate": 263
    },
    {
      "id": "api/node-events/after-run-api#usage",
      "doc_id": "api/node-events/after-run-api",
      "heading": "Usage",
      "heading_level": 2,
      "content_markdown": "## Usage\n\nYou can return a promise from the `after:run` event handler and it will be awaited before Cypress proceeds running your specs.\n\n### Log the number of passed tests of a run\n\n*   cypress.config.js\n*   cypress.config.ts\n\n```\nconst { defineConfig } = require('cypress')module.exports = defineConfig({  // setupNodeEvents can be defined in either  // the e2e or component configuration  e2e: {    setupNodeEvents(on, config) {      on('after:run', (results) => {        // results will look something like this when run via `cypress run`:        // {        //   totalDuration: 81,        //   totalSuites: 0,        //   totalTests: 1,        //   totalFailed: 0,        //   totalPassed: 1,        //   totalPending: 0,        //   totalSkipped: 0,        //   browserName: 'electron',        //   browserVersion: '59.0.3071.115',        //   osName: 'darwin',        //   osVersion: '16.7.0',        //   cypressVersion: '3.1.0',        //   config: {        //     projectId: '1qv3w7',        //     baseUrl: 'http://example.com',        //     viewportWidth: 1000,        //     viewportHeight: 660,        //     // ... more properties...        //   }        //   // ... more properties...        //   }        // }        if (results) {          // results will be undefined in interactive mode          console.log(            results.totalPassed,            'out of',            results.totalTests,            'passed'          )        }      })    },  },})\n```\n\n```\nimport { defineConfig } from 'cypress'export default defineConfig({  // setupNodeEvents can be defined in either  // the e2e or component configuration  e2e: {    setupNodeEvents(on, config) {      on('after:run', (results) => {        // results will look something like this when run via `cypress run`:        // {        //   totalDuration: 81,        //   totalSuites: 0,        //   totalTests: 1,        //   totalFailed: 0,        //   totalPassed: 1,        //   totalPending: 0,        //   totalSkipped: 0,        //   browserName: 'electron',        //   browserVersion: '59.0.3071.115',        //   osName: 'darwin',        //   osVersion: '16.7.0',        //   cypressVersion: '3.1.0',        //   config: {        //     projectId: '1qv3w7',        //     baseUrl: 'http://example.com',        //     viewportWidth: 1000,        //     viewportHeight: 660,        //     // ... more properties...        //   }        //   // ... more properties...        //   }        // }        if (results) {          // results will be undefined in interactive mode          console.log(            results.totalPassed,            'out of',            results.totalTests,            'passed'          )        }      })    },  },})\n```\n",
      "section": "api",
      "anchors": [
        "usage"
      ],
      "path": "/llm/json/chunked/api/node-events/after-run-api.json",
      "token_estimate": 409
    },
    {
      "id": "api/node-events/after-run-api#log-the-number-of-passed-tests-of-a-run",
      "doc_id": "api/node-events/after-run-api",
      "heading": "Log the number of passed tests of a run",
      "heading_level": 3,
      "content_markdown": "### Log the number of passed tests of a run\n\n*   cypress.config.js\n*   cypress.config.ts\n\n```\nconst { defineConfig } = require('cypress')module.exports = defineConfig({  // setupNodeEvents can be defined in either  // the e2e or component configuration  e2e: {    setupNodeEvents(on, config) {      on('after:run', (results) => {        // results will look something like this when run via `cypress run`:        // {        //   totalDuration: 81,        //   totalSuites: 0,        //   totalTests: 1,        //   totalFailed: 0,        //   totalPassed: 1,        //   totalPending: 0,        //   totalSkipped: 0,        //   browserName: 'electron',        //   browserVersion: '59.0.3071.115',        //   osName: 'darwin',        //   osVersion: '16.7.0',        //   cypressVersion: '3.1.0',        //   config: {        //     projectId: '1qv3w7',        //     baseUrl: 'http://example.com',        //     viewportWidth: 1000,        //     viewportHeight: 660,        //     // ... more properties...        //   }        //   // ... more properties...        //   }        // }        if (results) {          // results will be undefined in interactive mode          console.log(            results.totalPassed,            'out of',            results.totalTests,            'passed'          )        }      })    },  },})\n```\n\n```\nimport { defineConfig } from 'cypress'export default defineConfig({  // setupNodeEvents can be defined in either  // the e2e or component configuration  e2e: {    setupNodeEvents(on, config) {      on('after:run', (results) => {        // results will look something like this when run via `cypress run`:        // {        //   totalDuration: 81,        //   totalSuites: 0,        //   totalTests: 1,        //   totalFailed: 0,        //   totalPassed: 1,        //   totalPending: 0,        //   totalSkipped: 0,        //   browserName: 'electron',        //   browserVersion: '59.0.3071.115',        //   osName: 'darwin',        //   osVersion: '16.7.0',        //   cypressVersion: '3.1.0',        //   config: {        //     projectId: '1qv3w7',        //     baseUrl: 'http://example.com',        //     viewportWidth: 1000,        //     viewportHeight: 660,        //     // ... more properties...        //   }        //   // ... more properties...        //   }        // }        if (results) {          // results will be undefined in interactive mode          console.log(            results.totalPassed,            'out of',            results.totalTests,            'passed'          )        }      })    },  },})\n```\n",
      "section": "api",
      "anchors": [
        "log-the-number-of-passed-tests-of-a-run"
      ],
      "path": "/llm/json/chunked/api/node-events/after-run-api.json",
      "token_estimate": 379
    }
  ]
}