Skip to content

Commit 38f7011

Browse files
committed
Fix repeated dbResets so tests run faster
* Set config.baseUrl and visit relative URLs to avoid Cypress bug which runs "before" hooks twice (github.com/cypress-io/cypress/issues/2777) * Remove "after" hook dbResets; make tests responsible for their own initial state, not that of the subsequent test
1 parent f2514a5 commit 38f7011

10 files changed

Lines changed: 8 additions & 36 deletions

File tree

test/e2e/integration/allocations_spec.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,6 @@ describe('/allocations behaviour', () => {
55
cy.dbReset()
66
})
77

8-
after(() => {
9-
cy.dbReset()
10-
})
11-
128
afterEach(() => {
139
cy.visitPage('/logout')
1410
})

test/e2e/integration/benefits_spec.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,6 @@ describe('/login behaviour', () => {
55
cy.dbReset()
66
})
77

8-
after(() => {
9-
cy.dbReset()
10-
})
11-
128
afterEach(() => {
139
cy.visitPage('/logout')
1410
})

test/e2e/integration/contributions_spec.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,6 @@ describe('/contributions behaviour', () => {
55
cy.dbReset()
66
})
77

8-
after(() => {
9-
cy.dbReset()
10-
})
11-
128
afterEach(() => {
139
cy.visitPage('/logout')
1410
})

test/e2e/integration/login_spec.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,6 @@ describe('/login behaviour', () => {
55
cy.dbReset()
66
})
77

8-
after(() => {
9-
cy.dbReset()
10-
})
11-
128
afterEach(() => {
139
cy.visitPage('/logout')
1410
})

test/e2e/integration/logout_spec.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,6 @@ describe('/logout behaviour', () => {
55
cy.dbReset()
66
})
77

8-
after(() => {
9-
cy.dbReset()
10-
})
11-
128
it('Should redirect if the user has not logged in', () => {
139
cy.visitPage('/logout')
1410
cy.url().should('include', 'login')

test/e2e/integration/memos_spec.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,6 @@ describe('/memos behaviour', () => {
55
cy.dbReset()
66
})
77

8-
after(() => {
9-
cy.dbReset()
10-
})
11-
128
afterEach(() => {
139
cy.visitPage('/logout')
1410
})

test/e2e/integration/profile_spec.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,6 @@ describe('/profile behaviour', () => {
55
cy.dbReset()
66
})
77

8-
after(() => {
9-
cy.dbReset()
10-
})
11-
128
afterEach(() => {
139
cy.visitPage('/logout')
1410
})

test/e2e/integration/signup_spec.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,6 @@ describe('/signup behaviour', () => {
55
cy.dbReset()
66
})
77

8-
after(() => {
9-
cy.dbReset()
10-
})
11-
128
afterEach(() => {
139
cy.visitPage('/logout')
1410
})

test/e2e/plugins/index.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,16 @@
88
// https://on.cypress.io/plugins-guide
99
// ***********************************************************
1010

11+
const { port, hostName } = require('../../../config/env/all')
12+
1113
// This function is called when a project is opened or re-opened (e.g. due to
1214
// the project's config changing)
1315

1416
module.exports = (on, config) => {
1517
// `on` is used to hook into various events Cypress emits
1618
// `config` is the resolved Cypress config
19+
20+
config.baseUrl = `http://${hostName}:${port}`
21+
22+
return config
1723
}

test/e2e/support/commands.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
const { port, hostName } = require('../../../config/env/all')
2-
31
Cypress.Commands.add('signIn', (usr, pw) => {
4-
cy.visit(`http://${hostName}:${port}/login`)
2+
cy.visitPage('/login')
53
cy.get('#userName').type(usr)
64
cy.get('#password').type(pw)
75
cy.get('[type="submit"]').click()
@@ -22,7 +20,7 @@ Cypress.Commands.add('userSignIn', () => {
2220
})
2321

2422
Cypress.Commands.add('visitPage', (path = '/', config = {}) => {
25-
cy.visit(`http://${hostName}:${port}${path}`, config)
23+
cy.visit(path, config)
2624
})
2725

2826
Cypress.Commands.add('dbReset', () => {

0 commit comments

Comments
 (0)