Skip to content

Commit 8f8793a

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

File tree

13 files changed

+4644
-3924
lines changed

13 files changed

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