Skip to content

Commit 62f8ee2

Browse files
test(integration): Add cypress e2e tests
1 parent daa35dd commit 62f8ee2

File tree

5 files changed

+851
-38
lines changed

5 files changed

+851
-38
lines changed

test/integration/.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
*/cypress/fixtures
2+
*/cypress/plugins
3+
*/cypress/screenshots
4+
*/cypress/videos
5+
*/cypress/support
6+
**/bundle.js
7+
*/yarn.lock
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"baseUrl": "http://localhost:4000",
3+
"videoRecording": false
4+
}
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
describe('Angular v5 app', () => {
2+
beforeEach(() => {
3+
window.sessionStorage.clear();
4+
});
5+
6+
it('loads', () => {
7+
cy.visit('');
8+
});
9+
10+
it('loads home state by default', () => {
11+
cy.visit('');
12+
cy.url().should('include', '/home');
13+
});
14+
15+
it('renders uisref as links', () => {
16+
cy.visit('');
17+
cy.get('a').contains('home');
18+
cy.get('a').contains('about');
19+
cy.get('a').contains('lazy');
20+
cy.get('a').contains('lazy.child');
21+
cy.get('a').contains('lazy.child.viewtarget');
22+
});
23+
24+
it('renders home', () => {
25+
cy.visit('/home');
26+
cy
27+
.get('a')
28+
.contains('home')
29+
.should('have.class', 'active');
30+
cy
31+
.get('a')
32+
.contains('about')
33+
.should('not.have.class', 'active');
34+
cy.get('#default').contains('home works');
35+
});
36+
37+
it('renders about', () => {
38+
cy.visit('/home');
39+
cy.visit('/about');
40+
cy
41+
.get('a')
42+
.contains('home')
43+
.should('not.have.class', 'active');
44+
cy
45+
.get('a')
46+
.contains('about')
47+
.should('have.class', 'active');
48+
cy.get('#default').contains('about works');
49+
});
50+
51+
it('loads lazy routes', () => {
52+
cy.visit('/home');
53+
cy.visit('/lazy');
54+
cy
55+
.get('a')
56+
.contains('home')
57+
.should('not.have.class', 'active');
58+
cy
59+
.get('a')
60+
.contains('lazy')
61+
.should('have.class', 'active');
62+
cy.get('#default').contains('lazy works');
63+
});
64+
65+
it('routes to lazy routes', () => {
66+
cy.visit('/lazy');
67+
cy
68+
.get('a')
69+
.contains('home')
70+
.should('not.have.class', 'active');
71+
cy
72+
.get('a')
73+
.contains('lazy')
74+
.should('have.class', 'active');
75+
cy.get('#default').contains('lazy works');
76+
});
77+
78+
it('routes to lazy child routes', () => {
79+
cy.visit('/lazy/child');
80+
cy
81+
.get('a')
82+
.contains('home')
83+
.should('not.have.class', 'active');
84+
cy
85+
.get('a')
86+
.contains('lazy.child')
87+
.should('have.class', 'active');
88+
cy.get('#default').contains('lazy.child works');
89+
});
90+
91+
it('targets named views', () => {
92+
cy.visit('/lazy/child/viewtarget');
93+
cy
94+
.get('a')
95+
.contains('home')
96+
.should('not.have.class', 'active');
97+
cy
98+
.get('a')
99+
.contains('lazy.child')
100+
.should('have.class', 'active');
101+
cy.get('#default').contains('lazy.child works');
102+
cy.get('#header').contains('lazy.child.viewtarget works');
103+
cy.get('#footer').contains('lazy.child.viewtarget works');
104+
});
105+
});

test/integration/angularV5/package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
"ng": "ng",
77
"start": "ng serve",
88
"build": "ng build --prod",
9-
"test": "ng test",
9+
"test": "npm run e2e",
1010
"lint": "ng lint",
11-
"e2e": "ng e2e"
11+
"e2e": "npm run build && cypress-runner run dist"
1212
},
1313
"private": true,
1414
"dependencies": {
@@ -33,6 +33,7 @@
3333
"@types/jasmine": "~2.5.53",
3434
"@types/jasminewd2": "~2.0.2",
3535
"@types/node": "~6.0.60",
36+
"@uirouter/cypress-runner": "^1.0.7",
3637
"codelyzer": "^4.0.1",
3738
"jasmine-core": "~2.6.2",
3839
"jasmine-spec-reporter": "~4.1.0",

0 commit comments

Comments
 (0)