{"id":24529262,"url":"https://github.com/opencomponents/oh-see","last_synced_at":"2025-04-14T17:11:07.500Z","repository":{"id":57313821,"uuid":"58535704","full_name":"opencomponents/oh-see","owner":"opencomponents","description":"Test OC components in production","archived":false,"fork":false,"pushed_at":"2017-09-30T22:59:10.000Z","size":27,"stargazers_count":6,"open_issues_count":3,"forks_count":0,"subscribers_count":21,"default_branch":"master","last_synced_at":"2025-03-28T05:51:03.353Z","etag":null,"topics":["nightmare","opencomponents","screenshot"],"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/opencomponents.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}},"created_at":"2016-05-11T10:30:45.000Z","updated_at":"2018-01-24T12:18:56.000Z","dependencies_parsed_at":"2022-09-20T23:30:35.268Z","dependency_job_id":null,"html_url":"https://github.com/opencomponents/oh-see","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/opencomponents%2Foh-see","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/opencomponents%2Foh-see/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/opencomponents%2Foh-see/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/opencomponents%2Foh-see/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/opencomponents","download_url":"https://codeload.github.com/opencomponents/oh-see/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248923764,"owners_count":21183954,"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","opencomponents","screenshot"],"created_at":"2025-01-22T07:35:41.210Z","updated_at":"2025-04-14T17:11:07.481Z","avatar_url":"https://github.com/opencomponents.png","language":"JavaScript","readme":"oh-see [![Build Status](https://secure.travis-ci.org/opencomponents/oh-see.png?branch=master)](http://travis-ci.org/opencomponents/oh-see)\n======\n\nSo that you can see how [OC components](https://github.com/opencomponents/oc) look in production **before** publishing them to production.\n\nOh-see is a wrapper for [mirror-mirror](https://github.com/matteofigus/mirror-mirror) which is a wrapper for [Nightmare.js](https://github.com/segmentio/nightmare). Oh-see is been built for:\n\n* Opening a matrix of urls and viewports with Chrome\n* Optionally specify a set of operations to perform\n* Take a screenshot\n* Replace a component's baseUrl and re-render it\n* Optionally specify another set of operations to perform\n* Take another screenshot\n* Compare the screenshots and save a diff file with the highlighted differences\n\nMost important features:\n* Crazy quick compare to Selenium with Phantom\n* Able to hide/show Browser\n* Works with any OS\n* Able to use DevTools and do debugging with Chrome\n\n# Requirements:\n\n* Node version: min: **6**\n* `\u003coc-component\u003e` container needs to be present in rendered components to make `oh-see` work.\n\n### Install\n\n```js\nnpm install oh-see\n```\n\n### Usage example\n\n```js\nconst OhSee = require('oh-see');\n\nconst oh = OhSee({\n  // Nightmare.js options\n  openDevTools: true,\n  show: false\n});\n\noh.setup({\n  concurrency: 5,\n  timeout: 20000,\n  debug: true,\n  componentName: 'a-component',\n\n  urls: {\n    com_home: 'http://www.mywebsite.com',\n    com_search: 'http://www.mywebsite.com/?s=something',\n    com_product: 'https://www.mywebsite.com/item'\n  },\n\n  transformation: {\n    type: 'replaceBaseUrl',\n    newUrl: 'http://localhost:3030/',\n    oldUrl: 'https://oc-registry.mywebsite.com/'\n  },\n\n  screenshotsPath: './screenshots'\n});\n\noh.run((err, result) =\u003e {\n  console.log(arguments);\n  process.exit(0);\n});\n```\n\n### API\n\n1. [Set up an instance](#set-up-an-instance)\n2. [Configure the runner](#configure-the-runner)\n  * [action examples](#nightmare-actions-example)\n  * [transformation types](#transformation-types)\n3. [Start the runner](#start-the-runner)\n\n### Set up an instance\n\n`var ohSee = new OhSee([NighmareOptions]);`\n\nLook at [Nighmare.js options](https://github.com/segmentio/nightmare#nightmareoptions).\n\n### Configure the runner\n\n`ohSee.setup(ohSeeOptions);`\n\nThis is an object with the following structure:\n\n|name|type|mandatory|description|\n|----|----|---------|-----------|\n|componentName|`string`|yes|The component name|\n|concurrency|`number`|no|Default 3, is the concurrency of tests|\n|cookies|`object`|no|Allows to specify cookies to be used for each request|\n|debug|`boolean`|no|When true, shows stuff in the console|\n|headers|`object`|no|Allows to specify headers to be used for each request|\n|preRendering|`array of functions`|no|An array of nightmareJs actions to perform before the first screenshots. [Look at the example below](#nightmare-actions-example)|\n|postRendering|`array of functions`|no|An array of nightmareJs actions to perform after the transformation and before the second screenshots. [Look at the example below](#nightmare-actions-example)|\n|retries|`number`|no|Default 3, number of retries after a failing session|\n|screenshotsPath|`string`|yes|The path where to save the screenshots|\n|timeout|`number`|no|Default 20000, when the session is going to be restarted|\n|transformation|`object`|yes|The transformation to apply to the component. Look at the [Transformation types below](#transformation-types)|\n|tryAppendLang|`boolean`|no|Default `false`, when `true` appends to the component's href the `__ocAcceptLanguage` parameter, inheriting the value from `html` DOM element's `lang` attribute. This is required when re-rendering a server-side rendered component that depends on `Accept-Language` attribute for being rendered in the correct language|\n|urls|`object`|yes|The urls to test. Key is used to generate screenshots file name so keep it simple and without spaces and stuff|\n|viewports|`array of arrays`|no|Default `[[800, 600]]`, the viewports for executing the tests|\n\n#### Nightmare actions example\n\nThis example shows how to make a screenshot with a menu opened, assuming the transformation replaces the menu and then needs to run another javascript initialisation and then wait to complete before performing the same action again.\n\n```js\nohSee.setup({\n  ...\n  preRender: [\n    (nightmare) =\u003e nightmare.evaluate(() =\u003e $('#navbar-button').click()\n  ],\n  postRender: [\n    (nightmare) =\u003e nightmare.evaluate(() =\u003e {\n      window.menusReady = false;\n      window.menus.initialise(() =\u003e window.menusReady = true);\n    }),\n\n    (nightmare) =\u003e nightmare.wait(() =\u003e window.menusReady === true),\n\n    (nightmare) =\u003e nightmare.evaluate(() =\u003e $('#navbar-button').click())\n  ]\n});\n```\n\n#### Transformation types\n\n##### Base url replacement\n\nReplaces the components' base url to another one. Useful for comparing a local one with the production one.\n\n```js\nconst transformation = {\n  type: 'replaceBaseUrl',\n  oldUrl: 'https://my-registry.my-company.com',\n  newUrl: 'http://localhost:3000/'\n};\n...\n```\n\n### Start the runner\n\n`ohSee.run(callback);`\n\nWhere callback is going to have an error and/or a response with the results. If any of the requests fails, the callback will include both an error + the response with succeeding screenshot links.\n\n# Contributing\n\nYes please. Open an issue first.\n\n### License\n\nMIT\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopencomponents%2Foh-see","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fopencomponents%2Foh-see","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopencomponents%2Foh-see/lists"}