{"id":13583538,"url":"https://github.com/segmentio/niffy","last_synced_at":"2025-04-06T21:32:23.671Z","repository":{"id":51775106,"uuid":"84752993","full_name":"segmentio/niffy","owner":"segmentio","description":"Perceptual diffing suite built on Nightmare","archived":true,"fork":false,"pushed_at":"2023-07-11T01:21:05.000Z","size":177,"stargazers_count":537,"open_issues_count":33,"forks_count":32,"subscribers_count":7,"default_branch":"master","last_synced_at":"2024-05-09T16:46:54.973Z","etag":null,"topics":["nightmare","nightmarejs","perceptual-diffing","ui-testing"],"latest_commit_sha":null,"homepage":"https://open.segment.com/niffy","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/segmentio.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}},"created_at":"2017-03-12T19:54:49.000Z","updated_at":"2024-01-04T16:12:16.000Z","dependencies_parsed_at":"2024-01-24T13:04:52.666Z","dependency_job_id":null,"html_url":"https://github.com/segmentio/niffy","commit_stats":{"total_commits":19,"total_committers":4,"mean_commits":4.75,"dds":0.5789473684210527,"last_synced_commit":"229cf1da6b1619eeb6a51d447375a44b656c189a"},"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/segmentio%2Fniffy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/segmentio%2Fniffy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/segmentio%2Fniffy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/segmentio%2Fniffy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/segmentio","download_url":"https://codeload.github.com/segmentio/niffy/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223264855,"owners_count":17116222,"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":["nightmare","nightmarejs","perceptual-diffing","ui-testing"],"created_at":"2024-08-01T15:03:34.103Z","updated_at":"2024-11-06T00:30:25.447Z","avatar_url":"https://github.com/segmentio.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\u003cimg alt=\"mail-a-tron logo\" src=\"http://i.imgur.com/xv9y0Te.png\" width=\"150\"\u003e\u003c/p\u003e\n\u003cp align=\"center\"\u003e\n\u003cstrong\u003ePerceptual diffing suite\u003c/strong\u003e\n\u003cbr\u003e\nbuilt on \u003ca href=\"https://github.com/segmentio/nightmare\"\u003eNightmare\u003c/a\u003e by \u003ca href=\"https://segment.com\"\u003eSegment\u003c/a\u003e\n\u003cbr\u003e\u003cbr\u003e\n\u003ca href=\"https://circleci.com/gh/segmentio/niffy\"\u003e\u003cimg src=\"https://circleci.com/gh/segmentio/niffy.svg?style=shield\" /\u003e\u003c/a\u003e\n\u003ca href=\"https://npmjs.com/package/niffy\"\u003e\u003cimg src=\"https://img.shields.io/npm/v/niffy.svg\" /\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n## Getting Started\nYou can look at [`test/index.js`](https://github.com/segmentio/niffy/blob/master/test/index.js) as an example for how to use Niffy. To run the example test just do `make test` after cloning this repo.\n\n## Reference\nNiffy is built on [Nightmare](https://github.com/segmentio/nightmare) and used in combination with [Mocha](https://mochajs.org/). You'll also need to read and use both of those library's APIs to use niffy effectively.\n\n### Niffy(basehost, testhost[, options])\nTo create a new Niffy differ:\n\n```js\nlet niffy = new Niffy(basehost, testhost, nightmareOptions);\n```\n\n* `basehost` is the url that is assumed \"good\"\n* `testhost` is the url that you are comparing to the base\n* `nightmareOptions` can be seen [here in the Nightmare docs](https://github.com/segmentio/nightmare#nightmareoptions)\n  * `.threshold` is the maximum percentage difference for a passing test (default: 0.2%)\n\n### .test(url[, fn])\nThis method instructs niffy to go to a `url` (and optionally take additional actions like clicking, typing or checkboxing via the `fn` argument), and test `basehost` vs. `testhost` screenshots for pixel differences, and output the diff-highlight image. Typically you'll use `.test(url, fn)` in the body of a mocha test, like this:\n\n```js\nit('/news', function* () {\n  yield niffy.test('/news');\n});\n```\n\n### .goto(url[, fn])\nThis method instructs niffy to go to a `url` and optionally take additional actions like clicking, typing or checkboxing via the `fn` argument. Typically you'll use `.goto(url, fn)` in the `before` method of a mocha test suite, like this:\n\n```js\nbefore(function* () {\n  yield niffy.goto('/logout', function* (nightmare) {\n    yield nightmare\n      .type('input[name=\"email\"]', 'fake@faketestfaketest.com')\n      .type('input[name=\"password\"]', 'fakepassword')\n      .click('button[type=\"submit\"]');\n  });\n});\n```\n\n### .end()\nThis method closes the underlying Nightmare instance (e.g. freeing up memory). Typically you'll use `.end()` in the `after` method of a mocha test suite, like this:\n\n```js\nafter(function* () {\n  yield niffy.end();\n});\n```\n\n\n## License (MIT)\n\n```\nWWWWWW||WWWWWW\n W W W||W W W\n      ||\n    ( OO )__________\n     /  |           \\\n    /o o|    MIT     \\\n    \\___/||_||__||_|| *\n         || ||  || ||\n        _||_|| _||_||\n       (__|__|(__|__|\n```\nCopyright (c) 2017 Segment.io, Inc. friends@segment.com\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsegmentio%2Fniffy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsegmentio%2Fniffy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsegmentio%2Fniffy/lists"}