|
| 1 | +# Getting started with Cypress [](https://runme.dev/api/runme?repository=git%40github.com%3Asaucelabs%2Fvisual-examples.git) |
| 2 | + |
| 3 | +## Prerequisites |
| 4 | + |
| 5 | +- OSX Ventura with Git and Brew |
| 6 | +- Linux with bash curl and git |
| 7 | +- Windows with NodeJS 18 (untested) |
| 8 | +- Sauce Labs Account |
| 9 | + |
| 10 | +## Run the demo |
| 11 | + |
| 12 | +- Install Node.js 18 on Mac: |
| 13 | + |
| 14 | +```sh { name=nodejs-mac } |
| 15 | +brew install node@18 |
| 16 | +``` |
| 17 | + |
| 18 | +- Install Node.js 18 + Dependencies on Linux: |
| 19 | + |
| 20 | +```sh { name=nodejs-linux } |
| 21 | +curl -fsSLO https://deb.nodesource.com/nsolid_setup_deb.sh |
| 22 | +chmod +x nsolid_setup_deb.sh |
| 23 | +./nsolid_setup_deb.sh 18 |
| 24 | +apt-get install nodejs -y |
| 25 | +apt-get install -y libgtk2.0-0 libgtk-3-0 libgbm-dev libnotify-dev libgconf-2-4 libnss3 libxss1 libasound2 libxtst6 xauth xvfb |
| 26 | +``` |
| 27 | + |
| 28 | +- Clone the repo: |
| 29 | + |
| 30 | +```sh { name=clone } |
| 31 | +git clone https://github.com/saucelabs/visual-examples |
| 32 | +cd visual-examples/cypress-cucumber |
| 33 | +``` |
| 34 | + |
| 35 | +- install npm dependencies: |
| 36 | + |
| 37 | +```sh { name=npm-install } |
| 38 | +npm install |
| 39 | +``` |
| 40 | + |
| 41 | +- Configure with your Sauce credentials from https://app.saucelabs.com/user-settings and run |
| 42 | + |
| 43 | +```sh { name=set-credentials } |
| 44 | +export SAUCE_USERNAME=__YOUR_SAUCE_USER_NAME__ |
| 45 | +export SAUCE_ACCESS_KEY=__YOUR_SAUCE_ACCESS_KEY__ |
| 46 | +# to change the region you are testing in please change the `region` property in the cypress.config.ts file. |
| 47 | +``` |
| 48 | + |
| 49 | +- Run the test |
| 50 | + |
| 51 | +```sh { name=npm-run } |
| 52 | +npm run sauce-visual |
| 53 | +``` |
| 54 | + |
| 55 | +- Review your screenshots by clicking on the url printed in the test or go to https://app.saucelabs.com/visual/builds. |
| 56 | +- Accept all diffs, so they become new baselines. |
| 57 | +- Re-run the tests |
| 58 | + |
| 59 | +```sh { name=npm-run-visual-check } |
| 60 | +npm run sauce-visual-check |
| 61 | +``` |
| 62 | + |
| 63 | +- Open the test or go to https://app.saucelabs.com/visual/builds to review changes. |
| 64 | + |
| 65 | +## Running with `saucectl` |
| 66 | + |
| 67 | +Alternatively, you can run your tests on Sauce Labs. |
| 68 | + |
| 69 | +- Install `saucectl` |
| 70 | + |
| 71 | +```sh { name=npm-install-saucectl} |
| 72 | +npm install saucectl |
| 73 | +``` |
| 74 | + |
| 75 | +- Install the plugin in your `.sauce/config.yml` |
| 76 | + |
| 77 | +```yml |
| 78 | +[...] |
| 79 | + |
| 80 | +npm: |
| 81 | + packages: |
| 82 | + "@saucelabs/cypress-visual-plugin": "^0.3.33" |
| 83 | + |
| 84 | +[...] |
| 85 | +``` |
| 86 | + |
| 87 | +- Run saucectl |
| 88 | + |
| 89 | +```sh { name=saucectl-run } |
| 90 | +npx saucectl run |
| 91 | +``` |
| 92 | + |
| 93 | +- Review your screenshots by clicking on the url printed in the test or go to https://app.saucelabs.com/visual/builds. |
| 94 | +- Accept all diffs, so they become new baselines. |
| 95 | + |
| 96 | +- Run saucectl (with a modified screen) |
| 97 | + |
| 98 | +```sh { name=saucectl-run-visual-check } |
| 99 | +VISUAL_CHECK=true npx saucectl run |
| 100 | +``` |
| 101 | + |
| 102 | +- Go to https://app.saucelabs.com/visual/builds to review changes. |
| 103 | + |
| 104 | +## Installation & Usage |
| 105 | + |
| 106 | +View installation and usage instructions on the [Sauce Docs website](https://docs.saucelabs.com/visual-testing/integrations/cypress/). |
0 commit comments