{"id":40950570,"url":"https://github.com/gcirone/cypress-contract-stubs","last_synced_at":"2026-01-22T05:11:36.710Z","repository":{"id":65708908,"uuid":"373539272","full_name":"gcirone/cypress-contract-stubs","owner":"gcirone","description":"Cypress plugin for Spring Contract Stubs","archived":false,"fork":false,"pushed_at":"2023-02-05T22:26:40.000Z","size":265,"stargazers_count":3,"open_issues_count":1,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-27T02:57:44.598Z","etag":null,"topics":["contract-testing","cypress","cypress-plugin","e2e","mocks","spring-cloud-contract","stubs","stubserver","testing"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gcirone.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-06-03T14:37:11.000Z","updated_at":"2022-10-12T10:04:47.000Z","dependencies_parsed_at":"2023-02-19T02:30:47.271Z","dependency_job_id":null,"html_url":"https://github.com/gcirone/cypress-contract-stubs","commit_stats":null,"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"purl":"pkg:github/gcirone/cypress-contract-stubs","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gcirone%2Fcypress-contract-stubs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gcirone%2Fcypress-contract-stubs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gcirone%2Fcypress-contract-stubs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gcirone%2Fcypress-contract-stubs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gcirone","download_url":"https://codeload.github.com/gcirone/cypress-contract-stubs/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gcirone%2Fcypress-contract-stubs/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28655281,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-22T01:17:37.254Z","status":"online","status_checked_at":"2026-01-22T02:00:07.137Z","response_time":144,"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":["contract-testing","cypress","cypress-plugin","e2e","mocks","spring-cloud-contract","stubs","stubserver","testing"],"created_at":"2026-01-22T05:11:36.187Z","updated_at":"2026-01-22T05:11:36.699Z","avatar_url":"https://github.com/gcirone.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Cypress Contract Stubs\n\n\u003cp align=\"left\"\u003e\n  \u003ca href=\"https://www.npmjs.com/package/cypress-contract-stubs\"\u003e\n    \u003cimg src=\"https://img.shields.io/npm/v/cypress-contract-stubs.svg\" alt=\"Npm\"\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://github.com/gcirone/cypress-contract-stubs/actions\"\u003e\n    \u003cimg src=\"https://github.com/gcirone/cypress-contract-stubs/actions/workflows/release.yaml/badge.svg?style=shield\" alt=\"Github Action\"\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://www.cypress.io/\"\u003e\n    \u003cimg src=\"https://img.shields.io/badge/tested_with-cypress-162332.svg\" alt=\"Cypress\"\u003e\n  \u003c/a\u003e  \n  \u003ca href=\"https://github.com/facebook/jest\"\u003e\n    \u003cimg src=\"https://img.shields.io/badge/tested_with-jest-933e4c.svg\" alt=\"Jest\"\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://codecov.io/gh/gcirone/cypress-contract-stubs\"\u003e\n    \u003cimg src=\"https://codecov.io/gh/gcirone/cypress-contract-stubs/branch/master/graph/badge.svg\" alt=\"Codecov\" /\u003e\n  \u003c/a\u003e\n\u003c/p\u003e\n\nThe **cypress-contract-stubs** add support for using [Spring Cloud Contract Stub](https://spring.io/projects/spring-cloud-contract) entries when testing with Cypress. \nThis plugin can download artifacts from **nexus** and **nexus3** artifact repositories and cache them locally. \nProvide commands to automatically intercept application requests with stubs matched without the need of using the [stub runner](https://cloud.spring.io/spring-cloud-contract/1.2.x/multi/multi__spring_cloud_contract_stub_runner.html) server.\n\n## Get started\n\n### Installation\n\nInstall the plugin by running:\n\n```shell\nnpm install --save-dev cypress-contract-stubs\n```\n\n### Plugin configuration\n\nAdd it to your plugin file: `cypress/plugins/index.js`\n\n```javascript\nconst { contractStubsPlugin } = require('cypress-contract-stubs');\n\nmodule.exports = async (on, config) =\u003e {\n  await contractStubsPlugin(on, config);\n  \n  return config;\n}\n```\n\nAdd configuration for remote and local stubs to your `cypress.json` file.\n\nThe default *mode* is `remote` and the default *type* is `nexus3`. You can also configure default stub server and repository for the artifacts. \n\n```json\n{\n  \"env\": {\n    \"stubs_server\": \"http://nexus3.proxy.internal\",\n    \"stubs_repository\": \"maven-releases\",\n    \"stubs\": [\n      {\n        \"id\": \"internal.contracts:artifact-name:+:stubs\"\n      },\n      {\n        \"mode\": \"remote\",\n        \"id\": \"internal.contracts:artifact-name:+:stubs\",\n        \"type\": \"nexus\",\n        \"server\": \"http://nexus.proxy.internal\",\n        \"repository\": \"releases\"\n      },\n      {\n        \"mode\": \"local\",\n        \"file\": \"artifact-name-1.318-SNAPSHOT-stubs.jar\"\n      },\n      {\n        \"mode\": \"local\",\n        \"file\": \"artifact-name-stubs.jar\",\n        \"path\": \"cypress/fixtures\"\n      }\n    ]\n  }\n}\n```\n\n*Note: The plugin will download the latest artifact version if the `+` or `latest` is added to the stubs **id** coordinate*\n\n### Commands configuration\n\nAdd it to your support file: `cypress/support/index.js`\n\n```javascript\nimport 'cypress-contract-stubs/commands';\n```\n\nIn your test files, will be available the following commands:\n\n- `cy.interceptStubs` Intercept network requests with matched stubs\n- `cy.contractStubs` Get all available stub entries\n- `cy.contractStub` Get stub entry by options (if more stubs match the criteria will be returned the first occurrence)\n\n```javascript\ncy.interceptStubs();\ncy.contractStubs().then((stubs) =\u003e console.log(stubs));\ncy.contractStub({ name: 'stubName' }).then((stub) =\u003e console.log(stub));\n```\n\n## Intercept network request\n\n### Automatic intercept\n\nTo automatically intercept network requests use:\n\n```javascript\ncy.interceptStubs(); // Intercept all stub requests\ncy.interceptStubs({ names: ['stubNameA', 'stubNameB'] }); // Intercept stub requests filtered by names\n\ncy.visit('/')\n```\n\n*The command setup an intercept for each stub present with the syntax defined in [WireMock documentation](https://wiremock.org/docs/stubbing/)*\n\n### Manual intercept\n\nTo manually intercept network request use:\n\n```javascript\ncy.contractStub({ name: 'stubName' }).then((stub) =\u003e {\n  const { name, request, response } = stub;\n  \n  cy.intercept(request.url, (req) =\u003e {\n    req.reply(response.status, response.body, response.headers)\n  }).as(name);\n});\n\ncy.visit('/')\n```\n\n## Debug\n\nSet an environment variable `DEBUG=cypress:stubs:*` to log all stubs plugin operations.\n\nCheck the Cypress documentation for more info about [printing debug logs](https://docs.cypress.io/guides/references/troubleshooting#Print-DEBUG-logs).\n\n## Small print\n\nAuthor: Gianluca Cirone \u0026lt;gianluca.cirone@gmail.com\u0026gt; \u0026copy; 2022\n\n- [@freshdevit](https://twitter.com/freshdevit)\n- [gianlucacirone](https://www.linkedin.com/in/gianlucacirone)\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 an issue](https://github.com/gcirone/cypress-contract-stubs/issues) on Github\n\n## License\n\ncypress-contract-stubs is [MIT licensed](./LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgcirone%2Fcypress-contract-stubs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgcirone%2Fcypress-contract-stubs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgcirone%2Fcypress-contract-stubs/lists"}