-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
321 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
exports['e2e issue 1987 / can reload during spec run'] = ` | ||
==================================================================================================== | ||
(Run Starting) | ||
┌────────────────────────────────────────────────────────────────────────────────────────────────┐ | ||
│ Cypress: 1.2.3 │ | ||
│ Browser: FooBrowser 88 │ | ||
│ Specs: 1 found (beforehook-and-test-navigation.js) │ | ||
│ Searched: cypress/integration/beforehook-and-test-navigation.js │ | ||
└────────────────────────────────────────────────────────────────────────────────────────────────┘ | ||
──────────────────────────────────────────────────────────────────────────────────────────────────── | ||
Running: beforehook-and-test-navigation.js (1 of 1) | ||
suite | ||
✓ test | ||
✓ causes domain navigation | ||
2 passing | ||
(Results) | ||
┌────────────────────────────────────────────────────────────────────────────────────────────────┐ | ||
│ Tests: 2 │ | ||
│ Passing: 2 │ | ||
│ Failing: 0 │ | ||
│ Pending: 0 │ | ||
│ Skipped: 0 │ | ||
│ Screenshots: 0 │ | ||
│ Video: true │ | ||
│ Duration: X seconds │ | ||
│ Spec Ran: beforehook-and-test-navigation.js │ | ||
└────────────────────────────────────────────────────────────────────────────────────────────────┘ | ||
(Video) | ||
- Started processing: Compressing to 32 CRF | ||
- Finished processing: /XXX/XXX/XXX/cypress/videos/beforehook-and-test-navigation. (X second) | ||
js.mp4 | ||
==================================================================================================== | ||
(Run Finished) | ||
Spec Tests Passing Failing Pending Skipped | ||
┌────────────────────────────────────────────────────────────────────────────────────────────────┐ | ||
│ ✔ beforehook-and-test-navigation.js XX:XX 2 2 - - - │ | ||
└────────────────────────────────────────────────────────────────────────────────────────────────┘ | ||
✔ All specs passed! XX:XX 2 2 - - - | ||
` | ||
|
||
exports['e2e issue 1987 / can run proper amount of hooks'] = ` | ||
==================================================================================================== | ||
(Run Starting) | ||
┌────────────────────────────────────────────────────────────────────────────────────────────────┐ | ||
│ Cypress: 1.2.3 │ | ||
│ Browser: FooBrowser 88 │ | ||
│ Specs: 1 found (afterhooks.spec.js) │ | ||
│ Searched: cypress/integration/afterhooks.spec.js │ | ||
└────────────────────────────────────────────────────────────────────────────────────────────────┘ | ||
──────────────────────────────────────────────────────────────────────────────────────────────────── | ||
Running: afterhooks.spec.js (1 of 1) | ||
suite 1 | ||
✓ test 1 | ||
✓ test 2 | ||
suite 2 | ||
✓ s2t1 | ||
3 passing | ||
(Results) | ||
┌────────────────────────────────────────────────────────────────────────────────────────────────┐ | ||
│ Tests: 3 │ | ||
│ Passing: 3 │ | ||
│ Failing: 0 │ | ||
│ Pending: 0 │ | ||
│ Skipped: 0 │ | ||
│ Screenshots: 0 │ | ||
│ Video: true │ | ||
│ Duration: X seconds │ | ||
│ Spec Ran: afterhooks.spec.js │ | ||
└────────────────────────────────────────────────────────────────────────────────────────────────┘ | ||
(Video) | ||
- Started processing: Compressing to 32 CRF | ||
- Finished processing: /XXX/XXX/XXX/cypress/videos/afterhooks.spec.js.mp4 (X second) | ||
==================================================================================================== | ||
(Run Finished) | ||
Spec Tests Passing Failing Pending Skipped | ||
┌────────────────────────────────────────────────────────────────────────────────────────────────┐ | ||
│ ✔ afterhooks.spec.js XX:XX 3 3 - - - │ | ||
└────────────────────────────────────────────────────────────────────────────────────────────────┘ | ||
✔ All specs passed! XX:XX 3 3 - - - | ||
` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
const e2e = require('../support/helpers/e2e') | ||
const Fixtures = require('../support/helpers/fixtures') | ||
|
||
describe('e2e issue 1987', () => { | ||
e2e.setup({ | ||
servers: [{ | ||
port: 3434, | ||
static: true, | ||
}, | ||
{ | ||
port: 4545, | ||
static: true, | ||
}], | ||
}) | ||
|
||
// https://github.com/cypress-io/cypress/issues/1987 | ||
// before/after hooks should not be rerun on top navigation | ||
e2e.it('can reload during spec run', { | ||
project: Fixtures.projectPath('hooks-after-rerun'), | ||
spec: 'beforehook-and-test-navigation.js', | ||
snapshot: true, | ||
}) | ||
|
||
e2e.it('can run proper amount of hooks', { | ||
project: Fixtures.projectPath('hooks-after-rerun'), | ||
spec: 'afterhooks.spec.js', | ||
snapshot: true, | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
packages/server/test/support/fixtures/projects/hooks-after-rerun/cypress.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{} |
41 changes: 41 additions & 0 deletions
41
...r/test/support/fixtures/projects/hooks-after-rerun/cypress/integration/afterhooks.spec.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
describe('suite 1', () => { | ||
before(() => { | ||
cy.task('incrState', 'b1') | ||
}) | ||
|
||
it('test 1', () => { | ||
cy.task('incrState', 't1') | ||
cy.visit('http://localhost:3434') | ||
}) | ||
|
||
it('test 2', () => { | ||
cy.task('incrState', 't2') | ||
}) | ||
|
||
after(() => { | ||
cy.task('incrState', 'a1') | ||
}) | ||
}) | ||
|
||
describe('suite 2', () => { | ||
it('s2t1', () => { | ||
cy.task('incrState', 's2t1') | ||
cy.visit('http://localhost:4545') | ||
}) | ||
}) | ||
|
||
after(() => { | ||
cy.task('incrState', 'a2') | ||
cy.task('getState').then((state) => { | ||
expect(state).deep.eq({ | ||
// initial domain change causes 2 runs | ||
'b1': 2, | ||
't1': 2, | ||
't2': 1, | ||
'a1': 1, | ||
// domain change causes 2 runs | ||
's2t1': 2, | ||
'a2': 1, | ||
}) | ||
}) | ||
}) |
13 changes: 13 additions & 0 deletions
13
...fixtures/projects/hooks-after-rerun/cypress/integration/beforehook-and-test-navigation.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
describe('suite', () => { | ||
before(() => { | ||
// will cause infinite top navigation | ||
cy.visit('http://localhost:3434') | ||
}) | ||
|
||
it('test', () => { | ||
}) | ||
|
||
it('causes domain navigation', () => { | ||
cy.visit('http://localhost:4545') | ||
}) | ||
}) |
33 changes: 33 additions & 0 deletions
33
packages/server/test/support/fixtures/projects/hooks-after-rerun/cypress/plugins/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/// <reference types="cypress" /> | ||
// *********************************************************** | ||
// This example plugins/index.js can be used to load plugins | ||
// | ||
// You can change the location of this file or turn off loading | ||
// the plugins file with the 'pluginsFile' configuration option. | ||
// | ||
// You can read more here: | ||
// https://on.cypress.io/plugins-guide | ||
// *********************************************************** | ||
|
||
// This function is called when a project is opened or re-opened (e.g. due to | ||
// the project's config changing) | ||
|
||
const state = {} | ||
|
||
/** | ||
* @type {Cypress.PluginConfig} | ||
*/ | ||
module.exports = (on, config) => { | ||
on('task', { | ||
incrState (arg) { | ||
state[arg] = state[arg] + 1 || 1 | ||
|
||
return null | ||
}, | ||
getState () { | ||
return state | ||
} }) | ||
|
||
// `on` is used to hook into various events Cypress emits | ||
// `config` is the resolved Cypress config | ||
} |
25 changes: 25 additions & 0 deletions
25
packages/server/test/support/fixtures/projects/hooks-after-rerun/cypress/support/commands.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// *********************************************** | ||
// This example commands.js shows you how to | ||
// create various custom commands and overwrite | ||
// existing commands. | ||
// | ||
// For more comprehensive examples of custom | ||
// commands please read more here: | ||
// https://on.cypress.io/custom-commands | ||
// *********************************************** | ||
// | ||
// | ||
// -- This is a parent command -- | ||
// Cypress.Commands.add("login", (email, password) => { ... }) | ||
// | ||
// | ||
// -- This is a child command -- | ||
// Cypress.Commands.add("drag", { prevSubject: 'element'}, (subject, options) => { ... }) | ||
// | ||
// | ||
// -- This is a dual command -- | ||
// Cypress.Commands.add("dismiss", { prevSubject: 'optional'}, (subject, options) => { ... }) | ||
// | ||
// | ||
// -- This will overwrite an existing command -- | ||
// Cypress.Commands.overwrite("visit", (originalFn, url, options) => { ... }) |
20 changes: 20 additions & 0 deletions
20
packages/server/test/support/fixtures/projects/hooks-after-rerun/cypress/support/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// *********************************************************** | ||
// This example support/index.js is processed and | ||
// loaded automatically before your test files. | ||
// | ||
// This is a great place to put global configuration and | ||
// behavior that modifies Cypress. | ||
// | ||
// You can change the location of this file or turn off | ||
// automatically serving support files with the | ||
// 'supportFile' configuration option. | ||
// | ||
// You can read more here: | ||
// https://on.cypress.io/configuration | ||
// *********************************************************** | ||
|
||
// Import commands.js using ES2015 syntax: | ||
import './commands' | ||
|
||
// Alternatively you can use CommonJS syntax: | ||
// require('./commands') |