Skip to content

Commit a01f487

Browse files
committed
test: configure visual regression tests with chromatic
1 parent f75c699 commit a01f487

File tree

13 files changed

+4646
-3924
lines changed

13 files changed

+4646
-3924
lines changed
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
name: "Chromatic"
2+
3+
on: push
4+
5+
jobs:
6+
cypress:
7+
name: Run Cypress
8+
runs-on: ubuntu-latest
9+
container:
10+
image: cypress/browsers:node-22.13.1-chrome-132.0.6834.83-1-ff-134.0.2-edge-132.0.2957.115-1
11+
options: --user 1001
12+
steps:
13+
- uses: actions/checkout@v4
14+
with:
15+
fetch-depth: 0
16+
- uses: actions/setup-node@v4
17+
with:
18+
node-version: 22
19+
- name: Build InstUI
20+
run: npm ci && npm run bootstrap
21+
- name: Install dependencies
22+
run: npm ci
23+
working-directory: regression-test
24+
- name: Run Cypress tests
25+
uses: cypress-io/github-action@v6
26+
env:
27+
ELECTRON_EXTRA_LAUNCH_ARGS: "--remote-debugging-port=9222"
28+
with:
29+
start: npm run dev
30+
working-directory: regression-test
31+
- uses: actions/upload-artifact@v4
32+
with:
33+
name: test-results
34+
path: regression-test/cypress/downloads
35+
retention-days: 30
36+
37+
chromatic:
38+
name: Run Chromatic
39+
needs: cypress
40+
runs-on: ubuntu-latest
41+
steps:
42+
- name: Checkout code
43+
uses: actions/checkout@v4
44+
with:
45+
fetch-depth: 0
46+
- uses: actions/setup-node@v4
47+
with:
48+
node-version: 22.12.0
49+
- name: Install dependencies
50+
run: npm ci
51+
working-directory: regression-test
52+
- name: Download Cypress test results
53+
uses: actions/download-artifact@v4
54+
with:
55+
name: test-results
56+
path: regression-test/cypress/downloads
57+
- name: Run Chromatic
58+
uses: chromaui/action@latest
59+
with:
60+
cypress: true
61+
projectToken: ${{ secrets.CHROMATIC_APP_CODE }}
62+
workingDir: regression-test
63+
env:
64+
CHROMATIC_ARCHIVE_LOCATION: ./cypress/downloads

.github/workflows/vrt.yml

Lines changed: 0 additions & 36 deletions
This file was deleted.

regression-test/.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,6 @@ npm-debug.log*
3434
# typescript
3535
*.tsbuildinfo
3636
next-env.d.ts
37+
38+
# cypress
39+
/cypress/downloads

regression-test/cypress.config.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,14 @@
2020
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2121
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2222
* SOFTWARE.
23-
*/ import { defineConfig } from 'cypress'
23+
*/
24+
import { defineConfig } from 'cypress'
25+
import { installPlugin } from '@chromatic-com/cypress'
2426

2527
export default defineConfig({
2628
e2e: {
2729
setupNodeEvents(on, config) {
28-
// implement node event listeners here
30+
installPlugin(on, config)
2931
}
3032
}
3133
})

regression-test/cypress/e2e/spec.cy.ts

Lines changed: 4 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -20,31 +20,10 @@
2020
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2121
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2222
* SOFTWARE.
23-
*/ describe('regression test', () => {
24-
it('open dialog subpage', () => {
25-
cy.visit('http://localhost:3000')
26-
cy.get('a').contains('dialog').click()
27-
cy.get('button').click()
28-
cy.get('body').should('contain', 'Full name')
29-
cy.get('[class$="closeButton"]').click()
30-
})
31-
32-
it('open alert subpage', () => {
33-
cy.visit('http://localhost:3000')
34-
cy.get('a').contains('alert').click()
35-
cy.get('body').should('contain', 'Sample info text')
36-
})
23+
*/
3724

38-
it('open breadcrumb subpage', () => {
39-
cy.visit('http://localhost:3000')
40-
cy.get('a').contains('breadcrumb').click()
41-
cy.get('body').should('contain', 'Rabbit Is Rich')
42-
cy.get('body').contains('The Rabbit Novels').click()
43-
const redirect = 'https://instructure.design'
44-
cy.origin(redirect, { args: { redirect } }, ({ redirect }) => {
45-
cy.location().should((loc) => {
46-
loc.href.includes(redirect)
47-
})
48-
})
25+
describe('visual regression test', () => {
26+
it('check button', () => {
27+
cy.visit('http://localhost:3000/button')
4928
})
5029
})

regression-test/cypress/support/e2e.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@
2020
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2121
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2222
* SOFTWARE.
23-
*/ // ***********************************************************
23+
*/
24+
25+
// ***********************************************************
2426
// This example support/e2e.ts is processed and
2527
// loaded automatically before your test files.
2628
//
@@ -38,5 +40,7 @@
3840
// Import commands.js using ES2015 syntax:
3941
import './commands'
4042

43+
import '@chromatic-com/cypress/support'
44+
4145
// Alternatively you can use CommonJS syntax:
4246
// require('./commands')

0 commit comments

Comments
 (0)