{"id":14989752,"url":"https://github.com/martinkr/chigai-api","last_synced_at":"2025-04-12T00:32:14.792Z","repository":{"id":25701931,"uuid":"105947877","full_name":"martinkr/chigai-api","owner":"martinkr","description":"Modern visual regression testing. API for the visual regression tests.","archived":false,"fork":false,"pushed_at":"2022-12-09T03:07:05.000Z","size":850,"stargazers_count":21,"open_issues_count":11,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-05-29T01:58:25.028Z","etag":null,"topics":["automation","bdd","chai","image-diff","mocha","puppeteer","regression-tests","tdd","test-framework","test-runner","testing","visual-regression","visual-regression-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/martinkr.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-10-05T22:46:08.000Z","updated_at":"2024-03-25T14:24:57.000Z","dependencies_parsed_at":"2023-01-14T03:13:15.453Z","dependency_job_id":null,"html_url":"https://github.com/martinkr/chigai-api","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/martinkr%2Fchigai-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/martinkr%2Fchigai-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/martinkr%2Fchigai-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/martinkr%2Fchigai-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/martinkr","download_url":"https://codeload.github.com/martinkr/chigai-api/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248501414,"owners_count":21114674,"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":["automation","bdd","chai","image-diff","mocha","puppeteer","regression-tests","tdd","test-framework","test-runner","testing","visual-regression","visual-regression-testing"],"created_at":"2024-09-24T14:18:52.002Z","updated_at":"2025-04-12T00:32:14.461Z","avatar_url":"https://github.com/martinkr.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# chigai-api [![Build Status](https://travis-ci.org/martinkr/chigai-api.svg?branch=master)](https://travis-ci.org/martinkr/chigai-api)\nModern visual regression testing with ```puppeteer``` and ```blink-diff```\n\n## Visual regression testing\nVisual regression testing: compare your current state against your baseline.\nIt's nothing new. We've done this for ages. Comparing two images. Looking at the current version and the previous one. Searching for the difference. On our own. Manually.\n\nWell, Chiagi does this automatically. It takes a screenshot from a given URI and compares it to the previous version.\n\n## Automated. Always\nChigai is designed to be used in your tests. You can use it in your favourite testrunner. As a regression tool. If your layout changes, it won't go on unnoticed.\n\n# How to use this?\nChigai-api provides a clean facade for chigai-core. The regression testing of a given url and creating a fresh reference item beforehand.\nChigai-api is designed to be used with your favourite testrunner.\n\n## Regression testing\nProvide a url and options such as the viewport width (default: 1024), viewport height (default: 720) or a threshold (default: 0.01 = 1%) for the image comparison. Chigai-api creates a new screenshot of the whole page and compares it to the last specified reference. If their difference is lower than the given threshold it will resolve with ```true``, otherwise ```false```\n\n## Installation\n```$ yarn add chigai-api chigai-cli```\n\n## Example\n```JavaScript\n// with mocha\nconst regression = require(\"chigai-api\");\n\ndescribe(\"Perform regression on my page.\", () =\u003e {\n\tit(\"should not change.\", (async () =\u003e {\n\t\tlet result;\n\t\t// set the viewport to 1200x800 and wait for 250ms between onload and screenshotting. expect the delta to be lower than 1%\n\t\tresult = await regression(\"http://example.com\", {\"vw\": 1200, \"vh\": 800, \"threshold\": 0.01, \"wait\": 250});\n\t\tresult.should.be.ok;\n\t}));\n});\n```\n\n\n### Configuration options\nOptions can either be passed as arguments per call or globally  via .chigairs.json file. The options-object takes precedence.\n\n#### ```vw```\nDefault: ```1024```. The with of the viewport you cant to screenshot. This will be part of the unique identifier.\n#### ```vh```\nDefault: ```786```. The height of the viewport you cant to screenshot. This will be part of the unique identifier.\n\n#### ```threshold```\nDefault: ```0.01```. The threshold to use for the comparison. This will not be part of the unique identifier.\n\n#### ```path```\nDefault: ```./screenshots``` There's the possiblitly to pass a custom path to chigai. It's relative to your working directory.\nUse this to share your reference items (e.g. via source control, rsync ...).\n\n#### ```wait```\nDefault: ```0```. Wait this amount of miliseconds after the page's ```load-event``` before making the screenshot. This will not be part of the unique identifier.\n\n#### .chigai.json\nYou can store project wide setttings in this file. It takes the same key-value-pairs as the options-object. Plus an additional ```path``` property.\n\n\n```JavaScript\n{\n\t\"path\" : \"./myscreenshots\",\n\t\"threshold\": 0.5,\n\t\"vw\": 1200,\n\t\"vh\" : 800,\n\t\"wait\": 5000\n}\n```\n\n\n## Create a fresh reference on the CLI\nIf you need a new reference item, e.g. because you changed the page - use chigai-cli:\n\n```$ chigai reference http://example.com -w 1200 -h 800 -t 0.01```\n\n```$ ./node-modules/.bin/chigai reference http://example.com -w 1200 -h 800 -t 0.01```\n\n\n\n## Tech Stack\n- ECMAScript 2018 on ```nodejs v8.5.0```\n- ```blink-diff v^1.0.1```\n- ```fs-extra-plus v0.1.3```\n- ```puppeteer v0.11.0```\n- 100% code coverage using ```mocha v3.5.2```, ```chai v4.1.2``` and ```nyc v11.2.1```,\n\n## Resources\n- [GoogleChrome/puppeteer - Headless Chrome Node API](https://github.com/GoogleChrome/puppeteer)\n- [yahoo/blink-diff - A lightweight image comparison tool](https://github.com/yahoo/blink-diff)\n\n## License\nLicensed under the [MIT license](http://www.opensource.org/licenses/mit-license.php).\n\nCopyright (c) 2016, 2017 Martin Krause \u003cgithub@mkrause.info\u003e [http://martinkr.github.io)](http://martinkr.github.io)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmartinkr%2Fchigai-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmartinkr%2Fchigai-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmartinkr%2Fchigai-api/lists"}