Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
0bbd683
Added initial version of cypress tests
sandeep-vedam Apr 30, 2024
8a47907
Added more tests and reporter and other optimizations
sandeep-vedam May 7, 2024
5a38c38
Removed only in the tests to make sure all tests are run
sandeep-vedam May 7, 2024
91ef72f
Added support for screenshot comparison and reported
sandeep-vedam May 10, 2024
068426b
Added more tests and optimized the code
sandeep-vedam May 15, 2024
87ee225
Added Script for Cypress tests
sandeep-vedam May 15, 2024
96bf6cb
Added documentation for Cypress tests
sandeep-vedam May 15, 2024
41bbaca
Updated few screenshots and tests
sandeep-vedam Jun 10, 2024
388389f
Merged master and resolved conflicts
sandeep-vedam Jun 27, 2024
e3d9b49
Updated base images and test cases to execute consistently
sandeep-vedam Jun 27, 2024
5c15bbb
Updated the script command to run Cypress in visual and headless mode
sandeep-vedam Jun 27, 2024
78b92c1
Merged master and resolved conflicts
sandeep-vedam Jul 3, 2024
4bf43bc
Updated few tests and added launching report
sandeep-vedam Jul 9, 2024
5159356
Removed only to run all tests
sandeep-vedam Jul 9, 2024
19e770a
Added command to launch the report after test run completed
sandeep-vedam Jul 11, 2024
cffcf46
Optimized code and added few tests
sandeep-vedam Jul 11, 2024
c7c690a
Added changes related to platform specific env var setting
sandeep-vedam Jul 11, 2024
75600f3
Updated the documentation
sandeep-vedam Jul 11, 2024
b4bcc41
Updated Blits version and tests
sandeep-vedam Jul 16, 2024
cacaa4a
Updated Readme and example env files
sandeep-vedam Jul 16, 2024
dd250e4
Removed Reports and Screenshots folder to the cypress folder
sandeep-vedam Jul 18, 2024
57b85ae
Removed static URl and made it configurable
sandeep-vedam Jul 18, 2024
78a879e
Updated readme.
michielvandergeest Jul 18, 2024
c3ad039
Added reports and screenshots to gitingore file
sandeep-vedam Jul 19, 2024
5a8a42c
Merged master
sandeep-vedam Jul 19, 2024
f40723d
Integrated backstopjs related changes and updated documentation
sandeep-vedam Jul 20, 2024
237f465
Merged master and resolved conflicts
sandeep-vedam Jul 23, 2024
16f3754
Merge branch 'master' into feat/cypress-automation
sandeep-vedam Aug 9, 2024
d923972
Merged Dev
sandeep-vedam Nov 2, 2024
863a860
Merged in latest dev
sandeep-vedam Nov 2, 2024
d0c22a1
Updated scripts to make sure the tests are platform independent and o…
sandeep-vedam Nov 5, 2024
ea17951
Updated baseline screens and added test cases
sandeep-vedam Nov 20, 2024
5bdb72b
Added new cases and updated baseline screenshots
sandeep-vedam Nov 20, 2024
e753855
Removed node env from example env file
sandeep-vedam Nov 22, 2024
cc3f5db
Merged dev and resolved conflicts
sandeep-vedam Feb 10, 2025
c9ad239
Merged master
sandeep-vedam Feb 27, 2025
188f2c6
Merge branch 'dev' into feat/cypress-automation
sandeep-vedam Mar 6, 2025
f9becdd
Merged master and resolved conflicts
sandeep-vedam Mar 6, 2025
3b45cf2
Added new baseline images and new test cases
sandeep-vedam Mar 13, 2025
10822a6
Merge remote-tracking branch 'origin/dev' into feat/cypress-automation
sandeep-vedam Mar 21, 2025
ced51fd
Merged dev and resolved conflicts
sandeep-vedam May 15, 2025
e12cdc5
Updated baseline images
sandeep-vedam May 15, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,7 @@ dist
.env
tests/backstopjs/bitmaps_test/
tests/backstopjs/html_report/
tests/cypress/screenshots/
tests/cypress/reports/cypress-image-diff-html-report/
tests/cypress/reports/cypress-image-diff-screenshots/comparison
tests/cypress/reports/cypress-image-diff-screenshots/diff
74 changes: 63 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,48 +10,56 @@ This Blits L3 Example App contains a demo of a TMDB integration. Head over to ht

You can also take a look at the [hosted version](http://blits-demo.lightningjs.io) of this App.

## Visual Regression Test

## Bugs or issues?

If you find any bugs or issues in this App, please feel free to file a GitHub issue or open a PR.

## Visual Regression Testing

The Blits Example App comes 2 reference implementations of Visual Regression testing: BackStopJS and Cypress.

### BackstopJS

[BackstopJS](https://github.com/garris/BackstopJS) is a tool that facilitates automated visual regression testing for responsive web user interfaces.
It accomplishes this by comparing DOM screenshots over time.

### Setup
#### Setup

To get started with BackstopJS, follow these steps:

1. Run the App via the command: `npm run start:test` or `NODE_ENV=testing npm run dev`
2. Run `npm test` to test the App against the reference bitmaps.
2. Run `npm run test:backstopjs` to test the App against the reference bitmaps.


> Note: To ensure consistency regarding the performance of the app while creating the reference bitmaps or running the tests, `asyncCaptureLimit` should be set to `1` in the `backstop.cjs` file. This will ensure that the tests are run sequentially and not in parallel (so concurrency won't affect the performance of the app).

> Note: The default host and port of the dev server is `http://localhost:5173`. If you are running the app on a different host or port, you should update `TEST_HOST` and `TEST_PORT` in the `.env` file. Or you can directly modify the `backstop.cjs` file.

### Creating Reference Bitmaps
#### Creating Reference Bitmaps

To create reference bitmaps for visual regression testing, use the following command in the terminal:

```bash
npm run test:reference
npm run test:backstopjs-reference
```

This command will remove any existing reference snapshots and generate new ones based on the provided configuration `URL` in the previous section.


### Creating Test Bitmaps
#### Creating Test Bitmaps

Generate test bitmaps by using the following command in the terminal:

```bash
$ npm test
$ npm run test:backstopjs
```

This command will produce a new set of bitmaps in the `bitmap_test/<timestamp>` folder. After bitmap generation is complete,
a report comparing the most recent bitmaps against the reference will be displayed.


### Browser Options
#### Browser Options

BackstopJS supports both Puppeteer and Playwright. The existing reference bitmaps were created using Puppeteer with its default browser (Chrome headless). Changing browser settings may change page load and animation timings so after a change reference bitmaps might not match with test bitmaps. In that case, reference bitmaps should be generated again.

Expand All @@ -70,15 +78,59 @@ To use webkit:

```

### Debugging
#### Debugging

In case you prefer to visually monitor your application's state during the tests, you can enable the debug window using the following setting:

```json
"debugWindow": true
```

## Bugs or issues?

If you find any bugs or issues, please feel free to file a GitHub issue or open a PR.
### Cypress

Cypress is a tool that facilitates both functional and visual regression testing for responsive web user interfaces. It accomplishes this by comparing DOM screenshots over time

#### Setup

To get started with Cypress, follow these steps:

1. Set the env variable `NODE_ENV=testing` in the .env file
2. Run the App via the command: `npm run start:test`


Run `npm run test:cypress` to test the App in headless mode against the reference images located at `tests/cypress/reports/cypress-image-diff-screenshots/base` folder of the application.


Note: The default url will be `'http://localhost:5173'` and can be configured in the cypress config file located in the root folder.

#### Creating Base Screenshots

To create base screenshots for visual regression testing, use the following command in the terminal:

```bash
npm run test:cypress-reference
```
This command will remove any existing base snapshots and generate new ones at the location `<Root_Folder>/tests/cypress/reports/cypress-image-diff-screenshots/baseline`

Note: By default base screenshots are available at the above location

#### Creating Base Screenshots using the test code:

Initially base screenshots are available. We can take the screen shot using the below code snippet in the test spec wherever required

cy.compareSnapshot({name : '<Name of the screenshot>', testThreshold: <percentage of difference>})


#### Testing Screenshots:

After the base Screenshots are created, when we run the command `npm run test:cypress`, again the screenshots are generated inside the
`tests/cypress/reports/cypress-image-diff-screenshots/comparison` folder.

The screen shots are compared with the baseline screenshots and if there is any discrepancy, then the difference of the images is captured at
`tests/cypress/reports/cypress-image-diff-screenshots/diff` folder

#### Report:

The report is generated at the `tests/cypress/reports/cypress-image-diff-html-report` folder.

5 changes: 5 additions & 0 deletions cypress-image-diff.config.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const config = {
ROOT_DIR: 'tests/cypress/reports/',
}

module.exports = config
18 changes: 18 additions & 0 deletions cypress.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { defineConfig } from 'cypress'
import getCompareSnapshotsPlugin from 'cypress-image-diff-js/plugin'

export default defineConfig({
defaultCommandTimeout: 15000,
e2e: {
baseUrl: 'http://localhost:5173',
supportFile: './tests/cypress/support/e2e.{js,jsx,ts,tsx}',
specPattern: './tests/cypress/e2e/*.{js,jsx,ts,tsx}',
screenshotsFolder: './tests/cypress/screenshots/',
viewportWidth: 1920,
viewportHeight: 1080,
setupNodeEvents(on, config) {
// implement node event listeners here
return getCompareSnapshotsPlugin(on, config)
},
},
})
Loading