{"id":15552079,"url":"https://github.com/bahmutov/cypress-time-marks","last_synced_at":"2025-09-29T00:32:56.016Z","repository":{"id":64071008,"uuid":"573175314","full_name":"bahmutov/cypress-time-marks","owner":"bahmutov","description":"Custom Cypress commands to measure elapsed time","archived":false,"fork":false,"pushed_at":"2025-09-23T20:59:57.000Z","size":412,"stargazers_count":7,"open_issues_count":2,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-09-23T22:29:52.908Z","etag":null,"topics":["cypress-plugin"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bahmutov.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2022-12-01T21:32:55.000Z","updated_at":"2024-12-18T04:34:03.000Z","dependencies_parsed_at":"2023-12-27T02:21:27.548Z","dependency_job_id":"43447993-22f0-4a23-b9cb-c8e3760a1e25","html_url":"https://github.com/bahmutov/cypress-time-marks","commit_stats":{"total_commits":51,"total_committers":3,"mean_commits":17.0,"dds":0.5098039215686274,"last_synced_commit":"aa4cc990c30d194de3c099f6c453a7a0c3d37df4"},"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"purl":"pkg:github/bahmutov/cypress-time-marks","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bahmutov%2Fcypress-time-marks","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bahmutov%2Fcypress-time-marks/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bahmutov%2Fcypress-time-marks/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bahmutov%2Fcypress-time-marks/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bahmutov","download_url":"https://codeload.github.com/bahmutov/cypress-time-marks/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bahmutov%2Fcypress-time-marks/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":277450939,"owners_count":25819971,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-28T02:00:08.834Z","response_time":79,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cypress-plugin"],"created_at":"2024-10-02T14:09:05.978Z","updated_at":"2025-09-29T00:32:55.605Z","avatar_url":"https://github.com/bahmutov.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# cypress-time-marks ![cypress version](https://img.shields.io/badge/cypress-13.6.4-brightgreen)\n\n\u003e Custom Cypress commands to measure elapsed time\n\n```js\ncy.timeMark('start').wait(1500).timeSince('start').wait(500).timeSince('start')\n```\n\n![Time marks](./images/marks.png)\n\nSee [spec.cy.js](./cypress/e2e/spec.cy.js)\n\n- 📺 Watch the video [Measure The Elapsed Time In Your Cypress Tests](https://youtu.be/3ASVKBgYAYc)\n- 🎓 Covered in my course [Cypress Network Testing Exercises](https://cypress.tips/courses/network-testing)\n  - [Bonus 52: Measure the time it takes to show the loaded data on the page](https://cypress.tips/courses/network-testing/lessons/bonus52)\n  - [Bonus 85: Measure cy.requests and parts of tests](https://cypress.tips/courses/network-testing/lessons/bonus85)\n- 🎓 Covered in my course [Cypress Plugins](https://cypress.tips/courses/cypress-plugins)\n  - [Lesson p1: Time how long the app takes to add an item](https://cypress.tips/courses/cypress-plugins/lessons/p1)\n  - [Lesson p2: Test a Toast component timing](https://cypress.tips/courses/cypress-plugins/lessons/p2)\n  - [Lesson p3: Confirm timings after the functional test](https://cypress.tips/courses/cypress-plugins/lessons/p3)\n\n## Install\n\nAdd this plugin as a dev dependency\n\n```\n# if using NPM\n$ npm i -D cypress-time-marks\n# if using Yarn\n$ yarn add -D cypress-time-marks\n```\n\nImport this plugin from the spec file or from the support file\n\n```js\n// cypress/e2e/spec.cy.js or cypress/support/e2e.js\nimport 'cypress-time-marks'\n```\n\nThis should give you two new custom commands `cy.timeMark(name)` and `cy.timeSince(name)`. If you want TypeScript definitions, this module [includes them](./src/index.d.ts):\n\n```js\n// my spec JS file\n/// \u003creference types=\"cypress-time-marks\" /\u003e\n```\n\n## Options\n\n```ts\ncy.timeSince(markName: string, label?: string, timeLimit?: number, throwError?: boolean)\n```\n\n### labels\n\nYou can log a label when using `cy.timeSince(name, label)`\n\n```js\ncy.timeMark('start')\n  .wait(1500)\n  .timeSince('start', 'initial wait')\n  .wait(500)\n  .timeSince('start', 'final load')\n```\n\n![Time marks with labels](./images/labels.png)\n\n### time limit warning\n\nYou can pass a time limit after the mark name to warn if the elapsed time is longer than the limit. It won't fail the test, but it will change the icon to warn you.\n\n```js\ncy.timeMark('start')\n  .wait(100)\n  .timeSince('start', 'under time limit', 200)\n  .wait(500)\n  .timeSince('start', 'over time limit', 200)\n  .timeSince('start', 200)\n```\n\n![Time limit warnings](./images/time-limit.png)\n\n### fail the test\n\nYou can fail the test if the elapsed time is above the given limit.\n\n```js\ncy.timeMark('start').wait(100).timeSince(\n  'start', // mark name\n  'waiting', // message\n  50, // time limit (ms)\n  true, // throw an error if above the time limit\n)\n```\n\n![Failing test because of the time limit](./images/throw.png)\n\n## timeBetween\n\nSometimes you want to measure time, but assert the durations after the fact.\n\n```js\n// run commands and capture the marks\ncy.timeMark('start').wait(400).timeMark('finish')\n// confirm the durations between two marks\ncy.timeBetween('start', 'finish')\n```\n\nYou can add a label, set maximum duration, and even throw an error if the duration is above the given limit.\n\n```js\n// label this duration \"loading time\" in the command log\n// and if it exceeds 1 second, throw an error failing the test\ncy.timeBetween('start', 'finish', 'loading time', 1000, true)\n```\n\n## See also\n\n- [cypress-timestamps](https://github.com/bahmutov/cypress-timestamps) plugin\n\n## Small print\n\nAuthor: Gleb Bahmutov \u0026lt;gleb.bahmutov@gmail.com\u0026gt; \u0026copy; 2022\n\n- [@bahmutov](https://twitter.com/bahmutov)\n- [glebbahmutov.com](https://glebbahmutov.com)\n- [blog](https://glebbahmutov.com/blog)\n- [videos](https://www.youtube.com/glebbahmutov)\n- [presentations](https://slides.com/bahmutov)\n- [cypress.tips](https://cypress.tips)\n- [Cypress Tips \u0026 Tricks Newsletter](https://cypresstips.substack.com/)\n- [my Cypress courses](https://cypress.tips/courses)\n\nLicense: MIT - do anything with the code, but don't blame me if it does not work.\n\nSupport: if you find any problems with this module, email / tweet /\n[open issue](https://github.com/bahmutov/cypress-time-marks/issues) on Github\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbahmutov%2Fcypress-time-marks","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbahmutov%2Fcypress-time-marks","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbahmutov%2Fcypress-time-marks/lists"}