Skip to content

Commit c90a902

Browse files
committed
chore(e2e): migration to Cypress
1 parent ebe9c71 commit c90a902

12 files changed

+1410
-59
lines changed

.github/workflows/daily-project-check.yml

+10-6
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ jobs:
1616
os: [ubuntu-latest, windows-latest, macOS-latest]
1717

1818
steps:
19-
- uses: actions/checkout@v3
19+
- uses: actions/checkout@v4
2020
- name: Use Node.js ${{ matrix.node-version }}
21-
uses: actions/setup-node@v3
21+
uses: actions/setup-node@v4
2222
with:
2323
node-version: ${{ matrix.node-version }}
2424
- name: project check
@@ -32,18 +32,22 @@ jobs:
3232

3333
e2e-chrome:
3434

35-
runs-on: windows-latest
35+
runs-on: ubuntu-latest
3636

3737
steps:
38-
- uses: actions/checkout@v3
38+
- name: Checkout
39+
uses: actions/checkout@v4
3940
- name: Use Node.js 18
40-
uses: actions/setup-node@v3
41+
uses: actions/setup-node@v4
4142
with:
4243
node-version: 18
4344
- name: e2e chrome test
45+
uses: cypress-io/github-action@v6
46+
with:
47+
browser: chrome
4448
run: |
45-
choco install googlechrome --version=114.0.5735.199 --ignorechecksum -y
4649
npm i
50+
npm run build-lib:prod
4751
npm run e2e
4852
env:
4953
BROWSER: chrome

.github/workflows/project-check.yml

+9-6
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ jobs:
2020
os: [ubuntu-latest, windows-latest, macOS-latest]
2121

2222
steps:
23-
- uses: actions/checkout@v3
23+
- uses: actions/checkout@v4
2424
- name: Use Node.js ${{ matrix.node-version }}
25-
uses: actions/setup-node@v3
25+
uses: actions/setup-node@v4
2626
with:
2727
node-version: ${{ matrix.node-version }}
2828
- name: project check
@@ -36,17 +36,20 @@ jobs:
3636

3737
e2e-chrome:
3838

39-
runs-on: windows-latest
39+
runs-on: ubuntu-latest
4040

4141
steps:
42-
- uses: actions/checkout@v3
42+
- name: Checkout
43+
uses: actions/checkout@v4
4344
- name: Use Node.js 18
44-
uses: actions/setup-node@v3
45+
uses: actions/setup-node@v4
4546
with:
4647
node-version: 18
4748
- name: e2e chrome test
49+
uses: cypress-io/github-action@v6
50+
with:
51+
browser: chrome
4852
run: |
49-
choco install googlechrome --version=114.0.5735.199 --ignorechecksum -y
5053
npm i
5154
npm run build-lib:prod
5255
npm run e2e

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
##### `v2.15.1`
44

5+
- chore(e2e): migration to Cypress
56
- fix(testapp): remove Ivy incompatible ngx-perfect-scrollbar
67
- chore(workflows): update to npm 18, lock googlechrome v114
78
- chore(dependencies): update

angular.json

+33-11
Original file line numberDiff line numberDiff line change
@@ -104,18 +104,36 @@
104104
"src/assets"
105105
]
106106
}
107-
}
108-
}
109-
},
110-
"coreui-e2e": {
111-
"root": "e2e/",
112-
"projectType": "application",
113-
"architect": {
114-
"e2e": {
115-
"builder": "@angular-devkit/build-angular:protractor",
107+
},
108+
"cypress-run": {
109+
"builder": "@cypress/schematic:cypress",
116110
"options": {
117-
"protractorConfig": "e2e/protractor.conf.js",
118111
"devServerTarget": "coreui:serve"
112+
},
113+
"configurations": {
114+
"production": {
115+
"devServerTarget": "coreui:serve:production"
116+
}
117+
}
118+
},
119+
"cypress-open": {
120+
"builder": "@cypress/schematic:cypress",
121+
"options": {
122+
"watch": true,
123+
"headless": false
124+
}
125+
},
126+
"e2e": {
127+
"builder": "@cypress/schematic:cypress",
128+
"options": {
129+
"devServerTarget": "coreui:serve",
130+
"watch": false,
131+
"headless": true
132+
},
133+
"configurations": {
134+
"production": {
135+
"devServerTarget": "coreui:serve:production"
136+
}
119137
}
120138
}
121139
}
@@ -153,6 +171,10 @@
153171
}
154172
},
155173
"cli": {
156-
"analytics": false
174+
"analytics": false,
175+
"schematicCollections": [
176+
"@cypress/schematic",
177+
"@schematics/angular"
178+
]
157179
}
158180
}

cypress.config.ts

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { defineConfig } from 'cypress'
2+
3+
export default defineConfig({
4+
5+
e2e: {
6+
'baseUrl': 'http://localhost:4200'
7+
},
8+
9+
})

cypress/e2e/spec.cy.ts

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/// <reference types="cypress" />
2+
3+
describe('CoreUI v2 template', () => {
4+
5+
beforeEach(() => {
6+
cy.visit('/');
7+
});
8+
9+
it('should display CoreUI Dashboard', () => {
10+
cy.viewport(600, 800);
11+
const paragraph = cy.get('ng-component');
12+
paragraph.should('contain.text', 'CoreUI Dashboard');
13+
});
14+
15+
it('should toggle `sidebar-minimized` body.class on `sidebar-minimizer` click', () => {
16+
cy.viewport('macbook-16');
17+
cy.get('.app').invoke('attr', 'class').should('not.contain', 'sidebar-minimized');
18+
cy.get('.sidebar-minimizer').click();
19+
cy.get('.app').invoke('attr', 'class').should('contain', 'sidebar-minimized');
20+
cy.get('.sidebar-minimizer').click();
21+
cy.get('.app').invoke('attr', 'class').should('not.contain', 'sidebar-minimized');
22+
});
23+
24+
it('should toggle `sidebar-show` body.class on `navbar-toggler` click', () => {
25+
cy.viewport(600, 800);
26+
cy.get('.app').invoke('attr', 'class').should('not.contain', 'sidebar-show');
27+
cy.get('.navbar-toggler.d-lg-none').first().click();
28+
cy.get('.app').invoke('attr', 'class').should('contain', 'sidebar-show');
29+
cy.get('.navbar-toggler').first().click();
30+
cy.get('.app').invoke('attr', 'class').should('not.contain', 'sidebar-show');
31+
});
32+
33+
it('should toggle `aside-menu-lg-show` body.class on `navbar-toggler` click', () => {
34+
cy.viewport('macbook-16');
35+
cy.get('.app').invoke('attr', 'class').should('not.contain', 'aside-menu-lg-show');
36+
cy.get('.navbar-toggler.d-none.d-lg-block').last().click();
37+
cy.get('.app').invoke('attr', 'class').should('contain', 'aside-menu-lg-show');
38+
cy.get('.navbar-toggler.d-none.d-lg-block').last().click();
39+
cy.get('.app').invoke('attr', 'class').should('not.contain', 'aside-menu-lg-show');
40+
});
41+
});

cypress/fixtures/example.json

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"name": "Using fixtures to represent data",
3+
"email": "[email protected]"
4+
}
5+

cypress/support/commands.ts

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
// ***********************************************
2+
// This example namespace declaration will help
3+
// with Intellisense and code completion in your
4+
// IDE or Text Editor.
5+
// ***********************************************
6+
// declare namespace Cypress {
7+
// interface Chainable<Subject = any> {
8+
// customCommand(param: any): typeof customCommand;
9+
// }
10+
// }
11+
//
12+
// function customCommand(param: any): void {
13+
// console.warn(param);
14+
// }
15+
//
16+
// NOTE: You can use it like so:
17+
// Cypress.Commands.add('customCommand', customCommand);
18+
//
19+
// ***********************************************
20+
// This example commands.js shows you how to
21+
// create various custom commands and overwrite
22+
// existing commands.
23+
//
24+
// For more comprehensive examples of custom
25+
// commands please read more here:
26+
// https://on.cypress.io/custom-commands
27+
// ***********************************************
28+
//
29+
//
30+
// -- This is a parent command --
31+
// Cypress.Commands.add("login", (email, password) => { ... })
32+
//
33+
//
34+
// -- This is a child command --
35+
// Cypress.Commands.add("drag", { prevSubject: 'element'}, (subject, options) => { ... })
36+
//
37+
//
38+
// -- This is a dual command --
39+
// Cypress.Commands.add("dismiss", { prevSubject: 'optional'}, (subject, options) => { ... })
40+
//
41+
//
42+
// -- This will overwrite an existing command --
43+
// Cypress.Commands.overwrite("visit", (originalFn, url, options) => { ... })

cypress/support/e2e.ts

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// ***********************************************************
2+
// This example support/e2e.ts is processed and
3+
// loaded automatically before your test files.
4+
//
5+
// This is a great place to put global configuration and
6+
// behavior that modifies Cypress.
7+
//
8+
// You can change the location of this file or turn off
9+
// automatically serving support files with the
10+
// 'supportFile' configuration option.
11+
//
12+
// You can read more here:
13+
// https://on.cypress.io/configuration
14+
// ***********************************************************
15+
16+
// When a command from ./commands is ready to use, import with `import './commands'` syntax
17+
// import './commands';

cypress/tsconfig.json

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"extends": "../tsconfig.json",
3+
"include": ["**/*.ts"],
4+
"compilerOptions": {
5+
"sourceMap": false,
6+
"types": ["cypress"],
7+
}
8+
}

0 commit comments

Comments
 (0)