{"id":18459216,"url":"https://github.com/smartbear/visualtest-cypress","last_synced_at":"2025-04-08T05:35:03.962Z","repository":{"id":62043548,"uuid":"554924748","full_name":"SmartBear/visualtest-cypress","owner":"SmartBear","description":"Cypress plugin for VisualTest screenshot captures","archived":false,"fork":false,"pushed_at":"2025-03-10T15:22:30.000Z","size":1714,"stargazers_count":6,"open_issues_count":1,"forks_count":2,"subscribers_count":10,"default_branch":"main","last_synced_at":"2025-03-23T07:12:14.951Z","etag":null,"topics":["visualtest","visualtesting"],"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/SmartBear.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":"2022-10-20T16:30:35.000Z","updated_at":"2024-12-10T02:48:59.000Z","dependencies_parsed_at":"2023-11-29T18:28:31.334Z","dependency_job_id":"8e0275e8-fef4-4e32-9d83-9201c8f47837","html_url":"https://github.com/SmartBear/visualtest-cypress","commit_stats":{"total_commits":42,"total_committers":6,"mean_commits":7.0,"dds":0.3571428571428571,"last_synced_commit":"955492c092ff7c04630351d43ce4d2196fd65cc6"},"previous_names":[],"tags_count":31,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SmartBear%2Fvisualtest-cypress","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SmartBear%2Fvisualtest-cypress/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SmartBear%2Fvisualtest-cypress/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SmartBear%2Fvisualtest-cypress/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SmartBear","download_url":"https://codeload.github.com/SmartBear/visualtest-cypress/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247785918,"owners_count":20995641,"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":["visualtest","visualtesting"],"created_at":"2024-11-06T08:22:17.703Z","updated_at":"2025-04-08T05:34:58.947Z","avatar_url":"https://github.com/SmartBear.png","language":"JavaScript","readme":"# Cypress VisualTest Plugin\n\n### Documentation\n\nClick [here](https://support.smartbear.com/visualtest/docs/en/software-development-kits--sdks-/cypress-sdk.html) for more detailed docs on SmartBear's website\n\n## Setup\n\nRun the following commands to setup \u0026 install VisualTest:\n\n```shell\nnpm install @smartbear/visualtest-cypress\nnpx visualtest-setup\n```\n\nExample console output:\n\n```console\nCommands installed.\nPlugin installed.\nvisualTest.config.js has been created.\nPlease enter your projectToken in visualTest.config.js\n```\n\nEnter your projectToken in visualTest.config.js:\n\n```javascript\nmodule.exports = {projectToken: 'PROJECT_TOKEN'}\n```\n\n## Implementation\n\nSimply change all instances of ```cy.screenshot``` with ```cy.sbvtCapture```.\n\nFor example, this will run regression tests against **Fullpage Home Capture** in that project\n\n```javascript\ncy.sbvtCapture('Home Page')\n```\n\nTo override project settings — take a capture with layout mode on low sensitivity\n\n```javascript\ncy.sbvtCapture('Home Page', {\n    comparisonMode: 'layout', // if 'layout', then sensitivity is requried, OR 'detailed' with no sensitivity\n    sensitivity: \"low\" // 'medium', or 'high'\n})\n```\n\nFor lazy-loaded websites use:\n\n```javascript\ncy.sbvtCapture('Home Page', {\n    lazyload: 250 //number is milliseconds between scrolls \n})\n```\n\nTo ignore elements on the comparison, add the cssSelector to the array:\n\n```javascript\ncy.sbvtCapture('Home Page', {\n    ignoreElements: ['.exampleClass', '.class1 \u003e div \u003e li:nth-child(1)']\n})\n```\n\nYou can also run tests against just certain elements, this will run regression tests against the header.\n\n```javascript\ncy.get('.container').eq(0).sbvtCapture('Home Page Header')\n```\n\nTo pass in other [arguments](https://docs.cypress.io/api/commands/screenshot#Arguments) , the syntax would be the same as ```cy.screenshot```\n\n```javascript\ncy.sbvtCapture('Home Page', {\n    capture: 'viewport',\n    overwrite: true,\n    clip: {x: 100, y: 100, width: 1000, height: 1000}\n})\n```\n\nTo print out the test run results to the command line ```cy.sbvtPrintReport()```\n\nTo assert the testrun passed, call ```cy.sbvtGetTestRunResult()```, which returns an object with total comparisons passed and failed. Example:\n\n```javascript\n{  // example cy.sbvtGetTestRunResult() response\n    passed: 10\n    failed: 0\n}\n```\n\n```javascript\n    it(\"The sbvtCapture's should pass\", function () {\n        cy.sbvtGetTestRunResult()\n            .then((response) =\u003e {\n                assert(response.passed === 10, `response.passed !== 10: ${JSON.stringify(response)}`);\n                assert(response.failed === 0, `There were failures in the test run: ${JSON.stringify(response)}`);\n            });\n    });\n```\n\n\nCallback arguments are not allowed, i.e. ```onBeforeScreenshot``` \u0026 ```onAfterScreenshot```\n\n## Running\n\n- ```npx cypress run``` is the recommended way to run our plugin.\n- Going into 'interactive mode' (```npx cypress open```) works, but each test can only be ran once without closing and relauching the Cypress application.\n\n## Requirements\n\nCypress 9.7.0+ (Recommend v10.10.0+)\n\nNode 18.17.0+\n\n## Assigning captures to a test group name\n\n```javascript   \n//visualtest.config.js\nmodule.exports = {\n    projectToken: 'PROJECT_TOKEN',\n    testGroupName: 'test group name'\n}\n// OR save on the environment variable \n// SBVT_TEST_GROUP_NAME = 'test group name'\n```\n## Assigning SCM data to a test run\n\nSave Source Control Manager data on the environment variable\n```bash\nSBVT_SCM_BRANCH=branch-name \nSBVT_SCM_COMMIT_ID=commit-hash\n```\n\n## Manual Setup\n\n- For manual setup:\n    - On versions 10+\n        - Add: ```require('@smartbear/visualtest-cypress')(module);``` at the bottom of **cypress.config.js**\n        - Add: ```import '@smartbear/visualtest-cypress/commands'``` at the bottom of cypress/support/**e2e.js**\n\n    - On versions 10-\n        - Add: ```require('@smartbear/visualtest-cypress')(module);``` at the bottom of cypress/plugins/**index.js**\n        - Add: ```import '@smartbear/visualtest-cypress/commands'``` at the bottom of cypress/support/**index.js**\n    - Create **visualTest.config.js** in the main test folder\n        - that file will contain:\n          ```module.exports = { projectToken: 'PROJECT_TOKEN' }```\n        - Insert your projectToken, or create a trial here: https://try.smartbear.com/visualtest\n     \n\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsmartbear%2Fvisualtest-cypress","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsmartbear%2Fvisualtest-cypress","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsmartbear%2Fvisualtest-cypress/lists"}