{"id":18376922,"url":"https://github.com/bbc/nightwatch-vrt","last_synced_at":"2025-04-06T20:31:47.008Z","repository":{"id":32447719,"uuid":"140269796","full_name":"bbc/nightwatch-vrt","owner":"bbc","description":null,"archived":true,"fork":false,"pushed_at":"2024-10-18T10:03:51.000Z","size":65,"stargazers_count":7,"open_issues_count":13,"forks_count":6,"subscribers_count":23,"default_branch":"master","last_synced_at":"2025-03-19T17:18:24.888Z","etag":null,"topics":["nightwatch","testing"],"latest_commit_sha":null,"homepage":null,"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/bbc.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","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":"2018-07-09T10:28:30.000Z","updated_at":"2024-10-18T10:04:09.000Z","dependencies_parsed_at":"2024-06-19T22:49:09.067Z","dependency_job_id":"c796975d-aa07-4098-916b-4e5c379093e8","html_url":"https://github.com/bbc/nightwatch-vrt","commit_stats":{"total_commits":70,"total_committers":6,"mean_commits":"11.666666666666666","dds":0.5142857142857142,"last_synced_commit":"ed22b30c819e163abc3395effc71937ff07f14a4"},"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bbc%2Fnightwatch-vrt","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bbc%2Fnightwatch-vrt/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bbc%2Fnightwatch-vrt/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bbc%2Fnightwatch-vrt/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bbc","download_url":"https://codeload.github.com/bbc/nightwatch-vrt/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247547633,"owners_count":20956589,"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":["nightwatch","testing"],"created_at":"2024-11-06T00:25:24.617Z","updated_at":"2025-04-06T20:31:46.696Z","avatar_url":"https://github.com/bbc.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Archiving as no longer actively used or maintained within the BBC\n\n# Nightwatch VRT\n\nNightwatch Visual Regression Testing tools for `nightwatch.js`\n\n## Description\n\nNightwatch VRT extends [nightwatch.js](http://nightwatchjs.org/) with an assertion that captures a screenshot of a DOM element identified by a selector and compares the screenshot against a baseline screenshot. If the baseline screenshot does not exist, it will be created the first time you run the test and the assertion will pass.\n\n## Configuration\n\nInclude the following sections in the `nightwatch` [configuration file](http://nightwatchjs.org/gettingstarted#settings-file)\n\n#### Custom commands and assertions\n\nRegister `nightwatch-vrt`'s assertion and commands:\n\n```JavaScript\n    custom_commands_path: [\n        'node_modules/@bbc/nightwatch-vrt/commands'\n    ],\n    custom_assertions_path: [\n        'node_modules/@bbc/nightwatch-vrt/assertions'\n    ]\n```\n\n#### Nightwatch VRT custom settings\n\nThen, for global settings, add the `visual_regression_settings` entry to nightwatch's `globals` [`globals`](http://nightwatchjs.org/gettingstarted#test-settings) section\n\n```JSON\ndefault: {\n    \"globals\": {\n        \"visual_regression_settings\": {\n            \"generate_screenshot_path\": defaultScreenshotPathGenerator,\n            \"latest_screenshots_path\": \"vrt/latest\",\n            \"latest_suffix\": \"\",\n            \"baseline_screenshots_path\": \"vrt/baseline\",\n            \"baseline_suffix\": \"\",\n            \"diff_screenshots_path\": \"vrt/diff\",\n            \"diff_suffix\": \"\",\n            \"threshold\": 0,\n            \"prompt\": false,\n            \"always_save_diff_screenshot\": false\n        }\n    }\n}\n```\n\n| Property                    | Description                                                                                                      | Defaults       |\n|-----------------------------|------------------------------------------------------------------------------------------------------------------| -------------- |\n| generate_screenshot_path    | Passed function that will generate a screenshot path                                                             | none           |\n| latest_screenshots_path     | Path to the most recently captured screenshots                                                                   | \"vrt/latest\"   |\n| latest_suffix               | A string appended to the end of the latest captured screenshot*                                                  | \"\"             |\n| baseline_screenshots_path   | Path to the baseline expected screenshots                                                                        | \"vrt/baseline\" |\n| baseline_suffix             | A string appended to the end of the baseline screenshot*                                                         | \"\"             |\n| diff_screenshots_path       | Path to the diff image of the two screenshots                                                                    | \"vrt/diff\"     |\n| diff_suffix                 | A string appended to the end of the diff image*                                                                  | \"\"             |\n| threshold                   | Matching threshold, ranges from `0` to `1`. Smaller values make the comparison more sensitive.                   | 0.0            |\n| prompt                      | If true, the user will be prompted to override baseline screenshot when the recently captured screenshot differs | false          |\n| always_save_diff_screenshot | If true, recently captured screenshots will always override the baseline                                         | false          |\n\\* *Only necessary if screenshots are set to reside in the same directory*\n\n#### Nightwatch VRT screenshot path generator\n\nThe screenshot path generator option accepts a function that generates a dynamic path based on the test properties, and returns that string.\n\n| Parameter        | Description                                                                                    |\n|------------------|------------------------------------------------------------------------------------------------|\n| nightwatchClient | The nightwatch client test instance                                                            |\n| basePath         | The base path for the screenshot set in `visual_regression_settings` (e.g. *_screenshots_path) |\n| fileName         | The file name; either the selector used or the custom name given for the test                  |\n|  ***returns***   | A string which contains the full path - minus the file extension                               |\n\nFor example:\n\n```JavaScript\nfunction generateScreenshotFilePath(nightwatchClient, basePath, fileName) {\n    const moduleName = nightwatchClient.currentTest.module,\n        testName = nightwatchClient.currentTest.name\n\n    return path.join(process.cwd(), basePath, moduleName, testName, fileName)\n}\n```\n\n## Usage\n\nIn order to use `nightwatch-vrt`, you only need to invoke the `screenshotIdenticalToBaseline` assertion and pass a css selector for the DOM element to compare. You may also pass a custom filename, `visual_regression_settings` overrides, and a custom log message.\n\n| Parameter        | Description                                                                                    |\n|------------------|------------------------------------------------------------------------------------------------|\n| selector         | Identifies the element that will be captured in the screenshot.                                |\n| fileName         | Optional file name for this screenshot; defaults to the selector                               |\n| settings         | Optional settings to override the defaults and `visual_regression_settings`                    |\n| message          | Optional message for `nightwatch` to log upon completion                                       |\n\n\n```JavaScript\nmodule.exports = {\n    'Test Google UI loads correctly': (browser) =\u003e {\n        browser\n            .url('https://www.google.co.uk')\n            .assert.screenshotIdenticalToBaseline('body',  /* Optional */ 'custom-name', {threshold: 0.5}, 'VRT custom-name complete.')\n            .end()\n    }\n}\n```\n\nThe first time a test is run, a baseline screenshot will be created and stored on disk. You should always register the baseline screenshot in the code repository. Further executions of this test will compare against this baseline.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbbc%2Fnightwatch-vrt","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbbc%2Fnightwatch-vrt","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbbc%2Fnightwatch-vrt/lists"}