{"id":16175898,"url":"https://github.com/elaichenkov/cypress-should","last_synced_at":"2025-03-16T10:31:19.442Z","repository":{"id":186955166,"uuid":"672038937","full_name":"elaichenkov/cypress-should","owner":"elaichenkov","description":"Supercool assertion library for Cypress","archived":false,"fork":false,"pushed_at":"2024-09-30T10:35:36.000Z","size":1008,"stargazers_count":4,"open_issues_count":8,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-10-11T04:46:42.045Z","etag":null,"topics":["api","chai","cypress","testing"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/elaichenkov.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-07-28T18:56:20.000Z","updated_at":"2024-07-03T16:43:39.000Z","dependencies_parsed_at":"2023-08-08T11:56:23.846Z","dependency_job_id":"a4e559fd-b1f0-43fd-9a18-901102a085ec","html_url":"https://github.com/elaichenkov/cypress-should","commit_stats":null,"previous_names":["elaichenkov/cypress-should"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elaichenkov%2Fcypress-should","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elaichenkov%2Fcypress-should/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elaichenkov%2Fcypress-should/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elaichenkov%2Fcypress-should/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/elaichenkov","download_url":"https://codeload.github.com/elaichenkov/cypress-should/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":221662736,"owners_count":16859737,"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","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":["api","chai","cypress","testing"],"created_at":"2024-10-10T04:46:41.801Z","updated_at":"2024-10-27T10:25:32.170Z","avatar_url":"https://github.com/elaichenkov.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Stand With Ukraine](https://raw.githubusercontent.com/vshymanskyy/StandWithUkraine/main/banner-direct-single.svg)](https://vshymanskyy.github.io/StandWithUkraine)\n\n# cypress-should\n---\n[![tests](https://github.com/elaichenkov/cypress-should/actions/workflows/tests.yml/badge.svg)](https://github.com/elaichenkov/cypress-should/actions/workflows/tests.yml)\n[![NPM version](https://img.shields.io/npm/v/cypress-should.svg?style=flat\u0026color=red)](https://www.npmjs.com/package/cypress-should)\n[![monthly downloads](https://img.shields.io/npm/dm/cypress-should.svg?style=flat\u0026color=orange\u0026label=monthly%20downloads)](https://www.npmjs.com/package/cypress-should)\n[![downloads all time](https://img.shields.io/npm/dt/cypress-should.svg?style=flat\u0026color=yellow\u0026label=lifetime%20downloads)](https://www.npmjs.com/package/cypress-should)\n[![commits](https://img.shields.io/github/commit-activity/y/elaichenkov/cypress-should.svg?style=flat\u0026color=purple)](https://github.com/elaichenkov/cypress-should/commits/main)\n[![MIT licensed](https://img.shields.io/badge/license-MIT-blue.svg?style=flat\u0026color=blue)](LICENSE)\n\n\u003e Supercool assertion library for Cypress to verify API responses\n\n## Install\n\n```bash\nnpm install --save-dev cypress-should\n```\n\n## Usage\n\nIn your `cypress/support/index.js` file, add the following:\n\n```javascript\nrequire('cypress-should');\n```\n\nor if you are using TypeScript:\n\n```typescript\nimport 'cypress-should';\n```\n\nThen in your tests, you can use the `should` command with custom assertions to verify the response:\n\n```javascript\ncy.request('/api/users')\n  .should('have.status', 200)\n  .and('have.statusMessage', 'OK')\n  .and('have.contentType', 'application/json')\n  .and('have.body', { name: 'John Doe' });\n```\n\nor\n\n```javascript\ncy.request('/api/users').should((response) =\u003e {\n  expect(response).to.have.status(200);\n  expect(response).to.have.statusMessage('OK');\n  expect(response).to.haveContentType('application/json');\n  expect(response).to.have.body({ name: 'John Doe' });\n});\n```\n\n## API\n\n`have.status` - Asserts the response status code\n\n```javascript\ncy.request('/api/users').should('have.status', 200)\n```\n\n`have.statusMessage` - Asserts the response status message\n\n```javascript\ncy.request('/api/users').should('have.statusMessage', 'OK')\n```\n\n`have.contentType` - Asserts the response content type\n\n```javascript\ncy.request('/api/users').should('have.contentType', 'application/json')\n```\n\n`have.body` - Asserts the response body\n\n```javascript\ncy.request('/api/users').should('have.body', { name: 'John Doe' })\n```\n\n`have.header` - Asserts the response header\n\n```javascript\ncy.request('/api/users').should('have.header', 'x-powered-by', 'Express')\n```\n\n`have.cookie` - Asserts the response cookie\n\n```javascript\ncy.request('/profile').should('have.cookie', 'session_id')\n```\n\n`containBody` - Asserts the response body contains the given value\n\n```javascript\ncy.request('/api/users').should('containBody', { name: 'John Doe' });\n```\n\n`haveText` - Asserts the response body is equal to the given text\n\n```javascript\ncy.request('/home').should('haveText', 'Hello World!');\n```\n\n`containText` - Asserts the response body contains the given text\n\n```javascript\ncy.request('/home').should('containText', 'World!');\n```\n\n`be.json` - Asserts the response body is a valid JSON\n\n```javascript\ncy.request('/api/users').should('be.json');\n```\n\n`be.html` - Asserts the response body is a valid HTML\n\n```javascript\ncy.request('/home').should('be.html');\n```\n\n`be.text` - Asserts the response body is a valid text\n\n```javascript\ncy.request('/home').should('be.text');\n```\n\n`be.xml` - Asserts the response body is a valid XML\n\n```javascript\ncy.request('/home').should('be.xml');\n```\n\n## License\n\nMIT\n\n## Author\n\nYevhen Laichenkov \u003celaichenkov@gmail.com\u003e","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Felaichenkov%2Fcypress-should","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Felaichenkov%2Fcypress-should","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Felaichenkov%2Fcypress-should/lists"}