Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configuration and events overhaul (v6.0) #4225

Closed
wants to merge 61 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
cd4a164
start of 4.0
chrisbreiding Dec 3, 2018
bb43e6f
Rename plugins to background (#2408)
chrisbreiding Dec 3, 2018
a5bd2f6
Upgrade mocha to latest version (5.2.0) (#2703)
chrisbreiding Dec 3, 2018
e929086
Yield null from cy.writeFile (#2731)
lilaconlee Dec 3, 2018
18a87de
Upgrade Sinon to 7.1.1 (#2881)
lilaconlee Dec 4, 2018
aac89a1
Add plugin events that mirror driver events (#2309)
chrisbreiding Dec 4, 2018
9ef9146
Merge branch 'develop' into v4.0
chrisbreiding Dec 5, 2018
586161f
Merge branch 'develop' into v4.0
chrisbreiding Dec 5, 2018
d5bf693
Upgrade to Chai 4 (#2862)
lilaconlee Dec 5, 2018
e170e58
Merge branch 'develop' into v4.0
chrisbreiding Dec 11, 2018
0aa2216
Merge branch 'v4.0' of github.com:cypress-io/cypress into v4.0
chrisbreiding Dec 11, 2018
c2fdf3d
Rename events (#2935)
chrisbreiding Dec 12, 2018
dd770bf
Merge branch 'develop' into v4.0
brian-mann Jan 9, 2019
50b595c
Add back updated jquery code after develop merge
lilaconlee Jan 9, 2019
05fd432
Remove duplicate blank line from index.d.ts
lilaconlee Jan 9, 2019
0b376d1
Remove some try statements
lilaconlee Jan 9, 2019
cb14b34
Properly check for _spreadArray on a subject
lilaconlee Jan 9, 2019
7c23ea1
Update jquery check to use lodash
lilaconlee Jan 9, 2019
763db65
Merge branch 'develop' into v4.0
chrisbreiding Jan 10, 2019
16f52cc
Update alias UI (#2960)
lilaconlee Jan 18, 2019
ac9340d
Add new plugin events 'before:spec', 'after:spec', 'before:run', and …
chrisbreiding Jan 23, 2019
913a5d9
Merge branch 'develop' into v4.0
lilaconlee Jan 24, 2019
dde64d8
Remove only from open_project_spec
lilaconlee Jan 24, 2019
681d6ce
Update return value spec snapshot for filename santization changes
lilaconlee Jan 24, 2019
bb99962
Update background driver events spec for changes to error logging in …
lilaconlee Jan 24, 2019
0adde83
Update onReady/onLoad and onStart/onBeforeLoad in driver
lilaconlee Jan 24, 2019
d98427b
Remove plugins spec that got merged back in
lilaconlee Jan 24, 2019
6a63ee8
Update background index tests for new error messages
lilaconlee Jan 24, 2019
8f7c31c
Update PLUGINS to BACKGROUND in errors spec
lilaconlee Jan 24, 2019
e4436cf
Update snapshot for background events spec
lilaconlee Jan 25, 2019
23f590b
Merge branch 'develop' into v4.0
chrisbreiding Jan 31, 2019
1930c92
Log event changes (#3313)
chrisbreiding Feb 6, 2019
50b9446
Merge branch 'develop' into v4.0
chrisbreiding Feb 13, 2019
d845d0d
Merge branch 'develop' into v4.0
chrisbreiding Feb 13, 2019
b5455eb
Merge branch 'develop' into v4.0
chrisbreiding Feb 22, 2019
637b2b7
try rolling back jsdom version
chrisbreiding Feb 25, 2019
0f681e7
Merge branch 'develop' into v4.0
chrisbreiding Feb 25, 2019
224db65
Merge branch 'develop' into v4.0
chrisbreiding Feb 26, 2019
8c5ae7b
Merge branch 'develop' into v4.0
chrisbreiding Feb 26, 2019
1fe4df2
fix driver events so that errors are properly ignored
chrisbreiding Feb 27, 2019
742b299
Merge branch 'develop' into v4.0
chrisbreiding Feb 27, 2019
a4ae1f7
fail -> test:fail
chrisbreiding Feb 27, 2019
7c71b07
Merge branch 'develop' into v4.0
chrisbreiding Feb 28, 2019
b2a685a
Fix flaky background events e2e test (#3331)
chrisbreiding Mar 5, 2019
4687f3b
Merge branch 'develop' into v4.0
chrisbreiding Mar 6, 2019
6fac021
Merge branch 'develop' into v4.0
chrisbreiding Mar 8, 2019
89d7ae2
Merge branch 'develop' into v4.0
chrisbreiding Mar 18, 2019
ca4d79f
fix/clean up failing test
chrisbreiding Mar 19, 2019
2e3f158
Merge branch 'develop' into v4.0
chrisbreiding Mar 25, 2019
05acda9
Merge branch 'develop' into v4.0
chrisbreiding Apr 15, 2019
ce81bad
Merge branch 'develop' into v5.0
chrisbreiding May 23, 2019
eaef0f9
fixes
chrisbreiding May 23, 2019
edbd0a5
fix reporter tests
chrisbreiding May 23, 2019
c21e4ec
fix server integration tests
chrisbreiding May 23, 2019
9472488
fix failing tests
chrisbreiding May 23, 2019
9fa314f
fix driver tests
chrisbreiding May 23, 2019
4efdc71
update snapshots
chrisbreiding May 23, 2019
e69b946
fix tests
chrisbreiding May 23, 2019
8ee129d
fix more tests
chrisbreiding May 23, 2019
9f14449
fix more tests
chrisbreiding May 23, 2019
97ffa34
Merge branch 'develop' into v5.0
chrisbreiding May 30, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion .eslintignore
@@ -1,5 +1,5 @@
__snapshots__
packages/server/lib/scaffold/plugins/index.js
packages/server/lib/scaffold/background/index.js
packages/server/lib/scaffold/support/index.js
packages/server/lib/scaffold/support/commands.js
packages/server/test/fixtures
Expand Down
6 changes: 3 additions & 3 deletions cli/schema/cypress.schema.json
Expand Up @@ -84,10 +84,10 @@
"default": "cypress/integration",
"description": "Path to folder containing integration test files"
},
"pluginsFile": {
"backgroundFile": {
"type": ["string", "boolean"],
"default": "cypress/plugins/index.js",
"description": "Path to plugins file. (Pass false to disable)"
"default": "cypress/background/index.js",
"description": "Path to background file. (Pass false to disable)"
},
"screenshotsFolder": {
"type": "string",
Expand Down
7 changes: 5 additions & 2 deletions cli/test/lib/logger_spec.js
@@ -1,7 +1,7 @@
require('../spec_helper')

const la = require('lazy-ass')
const {stripIndent, stripIndents} = require('common-tags')
const { stripIndent, stripIndents } = require('common-tags')
const snapshot = require('../support/snapshot')

describe('stripIndent', () => {
Expand All @@ -12,6 +12,7 @@ describe('stripIndent', () => {
third line
last line
`

// should preserve the structure of the text
snapshot(removed)
})
Expand All @@ -21,7 +22,8 @@ describe('stripIndent', () => {
const removed = stripIndent(text)
// removed 1 level of indentation and trimmed the string
const expected = 'foo\n bar'
la(removed === expected, 'removed indent is\n' + removed)

la(removed === expected, `removed indent is\n${removed}`)
})

it('can be used with nested message', () => {
Expand All @@ -33,6 +35,7 @@ describe('stripIndent', () => {

last line
`

// should have NO indents
// first line
//
Expand Down
72 changes: 41 additions & 31 deletions cli/types/index.d.ts
Expand Up @@ -1995,10 +1995,10 @@ declare namespace Cypress {
*/
integrationFolder: string
/**
* Path to plugins file. (Pass false to disable)
* @default "cypress/plugins/index.js"
* Path to background file. (Pass false to disable)
* @default "cypress/background/index.js"
*/
pluginsFile: string
backgroundFile: string
/**
* Path to folder where screenshots will be saved from [cy.screenshot()](https://on.cypress.io/screenshot) command or after a headless or CI run’s test failure
* @default "cypress/screenshots"
Expand Down Expand Up @@ -2266,14 +2266,14 @@ declare namespace Cypress {
*
* @param {Window} contentWindow the remote page's window object
*/
onBeforeLoad(win: Window): void
onStart(win: Window): void

/**
* Called once your page has fired its load event.
*
* @param {Window} contentWindow the remote page's window object
*/
onLoad(win: Window): void
onReady(win: Window): void

/**
* Cypress will automatically apply the right authorization headers
Expand Down Expand Up @@ -3931,7 +3931,17 @@ declare namespace Cypress {
(fn: (currentSubject: Subject) => void): Chainable<Subject>
}

// for just a few events like "window:alert" it makes sense to allow passing cy.stub() or
/**
* Page details included with actions like 'page:start'
*/
interface PageDetails {
win: Window
url: string
statusCode?: number
headers?: { [key: string]: string }
}

// for just a few events like "page:alert" it makes sense to allow passing cy.stub() or
// a user callback function. Others probably only need a callback function.

/**
Expand Down Expand Up @@ -3959,7 +3969,7 @@ declare namespace Cypress {
// stub "window.alert" in a single test
it('shows alert', () => {
const stub = cy.stub()
cy.on('window:alert', stub)
cy.on('page:alert', stub)
// trigger application code that calls alert(...)
.then(() => {
expect(stub).to.have.been.calledOnce
Expand All @@ -3974,20 +3984,20 @@ declare namespace Cypress {
* @see https://on.cypress.io/catalog-of-events#App-Events
* @example
```
cy.on('window:confirm', (str) => {
cy.on('page:confirm', (str) => {
console.log(str)
return false // simulate "Cancel"
})
```
*/
(action: 'window:confirm', fn: ((text: string) => false | void) | SinonSpyAgent<sinon.SinonSpy> | SinonSpyAgent<sinon.SinonStub>): void
(action: 'page:confirm', fn: ((text: string) => false | void) | SinonSpyAgent<sinon.SinonSpy> | SinonSpyAgent<sinon.SinonStub>): void
/**
* Fires when your app calls the global `window.alert()` method.
* Cypress will auto accept alerts. You cannot change this behavior.
* @example
```
const stub = cy.stub()
cy.on('window:alert', stub)
cy.on('page:alert', stub)
// assume the button calls window.alert()
cy.get('.my-button')
.click()
Expand All @@ -3997,87 +4007,87 @@ declare namespace Cypress {
```
* @see https://on.cypress.io/catalog-of-events#App-Events
*/
(action: 'window:alert', fn: ((text: string) => void) | SinonSpyAgent<sinon.SinonSpy> | SinonSpyAgent<sinon.SinonStub>): void
(action: 'page:alert', fn: ((text: string) => void) | SinonSpyAgent<sinon.SinonSpy> | SinonSpyAgent<sinon.SinonStub>): void
/**
* Fires as the page begins to load, but before any of your applications JavaScript has executed. This fires at the exact same time as `cy.visit()` `onBeforeLoad` callback. Useful to modify the window on a page transition.
* Fires as the page begins to load, but before any of your applications JavaScript has executed. This fires at the exact same time as `cy.visit()` `onStart` callback. Useful to modify the window on a page transition.
* @see https://on.cypress.io/catalog-of-events#App-Events
*/
(action: 'window:before:load', fn: (win: Window) => void): void
(action: 'page:start', fn: (details: PageDetails) => void): void
/**
* Fires after all your resources have finished loading after a page transition. This fires at the exact same time as a `cy.visit()` `onLoad` callback.
* Fires after all your resources have finished loading after a page transition. This fires at the exact same time as a `cy.visit()` `onReady` callback.
* @see https://on.cypress.io/catalog-of-events#App-Events
*/
(action: 'window:load', fn: (win: Window) => void): void
(action: 'page:ready', fn: (details: PageDetails) => void): void
/**
* Fires when your application is about to navigate away. The real event object is provided to you. Your app may have set a `returnValue` on the event, which is useful to assert on.
* Fires when your application is has unloaded and is navigating away. The real event object is provided to you. This event is not cancelable.
* @see https://on.cypress.io/catalog-of-events#App-Events
*/
(action: 'window:before:unload', fn: (event: BeforeUnloadEvent) => void): void
(action: 'page:end', fn: (details: PageDetails) => void): void
/**
* Fires when your application is has unloaded and is navigating away. The real event object is provided to you. This event is not cancelable.
* Fires when your application is about to navigate away. The real event object is provided to you. Your app may have set a `returnValue` on the event, which is useful to assert on.
* @see https://on.cypress.io/catalog-of-events#App-Events
*/
(action: 'window:unload', fn: (event: Event) => void): void
(action: 'before:window:unload', fn: (event: BeforeUnloadEvent) => void): void
/**
* Fires whenever Cypress detects that your application's URL has changed.
* @see https://on.cypress.io/catalog-of-events#App-Events
*/
(action: 'url:changed', fn: (url: string) => void): void
(action: 'page:url:changed', fn: (url: string) => void): void
/**
* Fires when the test has failed. It is technically possible to prevent the test from actually failing by binding to this event and invoking an async `done` callback. However this is **strongly discouraged**. Tests should never legitimately fail. This event exists because it's extremely useful for debugging purposes.
* @see https://on.cypress.io/catalog-of-events#App-Events
*/
(action: 'fail', fn: (error: Error, mocha: Mocha.IRunnable) => void): void
(action: 'test:fail', fn: (error: Error, mocha: Mocha.IRunnable) => void): void
/**
* Fires whenever the viewport changes via a `cy.viewport()` or naturally when Cypress resets the viewport to the default between tests. Useful for debugging purposes.
* @see https://on.cypress.io/catalog-of-events#App-Events
*/
(action: 'viewport:changed', fn: (viewport: Viewport) => void): void
(action: 'viewport:change', fn: (viewport: Viewport) => void): void
/**
* Fires whenever **Cypress** is scrolling your application. This event is fired when Cypress is {% url 'waiting for and calculating actionability' interacting-with-elements %}. It will scroll to 'uncover' elements currently being covered. This event is extremely useful to debug why Cypress may think an element is not interactive.
* @see https://on.cypress.io/catalog-of-events#App-Events
*/
(action: 'scrolled', fn: ($el: JQuery) => void): void
(action: 'internal:scrolled', fn: ($el: JQuery) => void): void
/**
* Fires when a cy command is first invoked and enqueued to be run later. Useful for debugging purposes if you're confused about the order in which commands will execute.
* @see https://on.cypress.io/catalog-of-events#App-Events
*/
(action: 'command:enqueued', fn: (command: EnqueuedCommand) => void): void
(action: 'internal:commandEnqueue', fn: (command: EnqueuedCommand) => void): void
/**
* Fires when cy begins actually running and executing your command. Useful for debugging and understanding how the command queue is async.
* @see https://on.cypress.io/catalog-of-events#App-Events
*/
(action: 'command:start', fn: (command: CommandQueue) => void): void
(action: 'internal:commandStart', fn: (command: CommandQueue) => void): void
/**
* Fires when cy finishes running and executing your command. Useful for debugging and understanding how commands are handled.
* @see https://on.cypress.io/catalog-of-events#App-Events
*/
(action: 'command:end', fn: (command: CommandQueue) => void): void
(action: 'internal:commandEnd', fn: (command: CommandQueue) => void): void
/**
* Fires whenever a command begins its retrying routines. This is called on the trailing edge after Cypress has internally waited for the retry interval. Useful to understand **why** a command is retrying, and generally includes the actual error causing the retry to happen. When commands fail the final error is the one that actually bubbles up to fail the test. This event is essentially to debug why Cypress is failing.
* @see https://on.cypress.io/catalog-of-events#App-Events
*/
(action: 'command:retry', fn: (command: CommandQueue) => void): void
(action: 'internal:commandRetry', fn: (command: CommandQueue) => void): void
/**
* Fires whenever a command emits this event so it can be displayed in the Command Log. Useful to see how internal cypress commands utilize the {% url 'Cypress.log()' cypress-log %} API.
* @see https://on.cypress.io/catalog-of-events#App-Events
*/
(action: 'log:added', fn: (log: any, interactive: boolean) => void): void
(action: 'internal:log', fn: (log: any, interactive: boolean) => void): void
/**
* Fires whenever a command's attributes changes. This event is debounced to prevent it from firing too quickly and too often. Useful to see how internal cypress commands utilize the {% url 'Cypress.log()' cypress-log %} API.
* @see https://on.cypress.io/catalog-of-events#App-Events
*/
(action: 'log:changed', fn: (log: any, interactive: boolean) => void): void
(action: 'internal:logChange', fn: (log: any, interactive: boolean) => void): void
/**
* Fires before the test and all **before** and **beforeEach** hooks run.
* @see https://on.cypress.io/catalog-of-events#App-Events
*/
(action: 'test:before:run', fn: (attributes: ObjectLike, test: Mocha.ITest) => void): void
(action: 'test:start', fn: (attributes: ObjectLike, test: Mocha.ITest) => void): void
/**
* Fires after the test and all **afterEach** and **after** hooks run.
* @see https://on.cypress.io/catalog-of-events#App-Events
*/
(action: 'test:after:run', fn: (attributes: ObjectLike, test: Mocha.ITest) => void): void
(action: 'test:end', fn: (attributes: ObjectLike, test: Mocha.ITest) => void): void
}

// $CommandQueue from `command_queue.coffee` - a lot to type. Might be more useful if it was written in TS
Expand Down
44 changes: 22 additions & 22 deletions cli/types/tests/actions.ts
Expand Up @@ -3,77 +3,77 @@ Cypress.on('uncaught:exception', (error, runnable) => {
runnable // $ExpectType IRunnable
})

Cypress.on('window:confirm', (text) => {
Cypress.on('page:confirm', (text) => {
text // $ExpectType string
})

Cypress.on('window:alert', (text) => {
Cypress.on('page:alert', (text) => {
text // $ExpectType string
})

Cypress.on('window:before:load', (win) => {
win // $ExpectType Window
Cypress.on('page:start', (details) => {
details // $ExpectType PageDetails
})

Cypress.on('window:load', (win) => {
win // $ExpectType Window
Cypress.on('page:ready', (details) => {
details // $ExpectType PageDetails
})

Cypress.on('window:before:unload', (event) => {
event // $ExpectType BeforeUnloadEvent
Cypress.on('page:end', (details) => {
details // $ExpectType PageDetails
})

Cypress.on('window:unload', (event) => {
event // $ExpectType Event
Cypress.on('before:window:unload', (event) => {
event // $ExpectType BeforeUnloadEvent
})

Cypress.on('url:changed', (url) => {
Cypress.on('page:url:changed', (url) => {
url // $ExpectType string
})

Cypress.on('fail', (error, mocha) => {
Cypress.on('test:fail', (error, mocha) => {
error // $ExpectType Error
mocha // $ExpectType IRunnable
})

Cypress.on('viewport:changed', (viewport) => {
Cypress.on('viewport:change', (viewport) => {
viewport // $ExpectType Viewport
})

Cypress.on('scrolled', ($el) => {
Cypress.on('internal:scrolled', ($el) => {
$el // $ExpectType JQuery<HTMLElement>
})

Cypress.on('command:enqueued', (command) => {
Cypress.on('internal:commandEnqueue', (command) => {
command // $ExpectType EnqueuedCommand
})

Cypress.on('command:start', (command) => {
Cypress.on('internal:commandStart', (command) => {
command // $ExpectType CommandQueue
})

Cypress.on('command:end', (command) => {
Cypress.on('internal:commandEnd', (command) => {
command // $ExpectType CommandQueue
})

Cypress.on('command:retry', (command) => {
Cypress.on('internal:commandRetry', (command) => {
command // $ExpectType CommandQueue
})

Cypress.on('log:added', (log, interactive: boolean) => {
Cypress.on('internal:log', (log, interactive: boolean) => {
log // $ExpectTyped any
})

Cypress.on('log:changed', (log, interactive: boolean) => {
Cypress.on('internal:logChange', (log, interactive: boolean) => {
log // $ExpectTyped any
})

Cypress.on('test:before:run', (attributes , test) => {
Cypress.on('test:start', (attributes , test) => {
attributes // $ExpectType ObjectLike
test // $ExpectType ITest
})

Cypress.on('test:after:run', (attributes , test) => {
Cypress.on('test:end', (attributes , test) => {
attributes // $ExpectType ObjectLike
test // $ExpectType ITest
})
24 changes: 12 additions & 12 deletions cli/types/tests/kitchen-sink.ts
Expand Up @@ -48,21 +48,21 @@ Cypress.browser // $ExpectType Browser

// stubbing window.alert type on "Cypress" should
// work with plain function or with a Sinon stub
Cypress.on('window:alert', () => { })
Cypress.on('window:alert', cy.spy())
Cypress.on('window:alert', cy.stub())
Cypress.on('page:alert', () => { })
Cypress.on('page:alert', cy.spy())
Cypress.on('page:alert', cy.stub())
// same for a single test
cy.on('window:alert', () => { })
cy.on('window:alert', cy.spy())
cy.on('window:alert', cy.stub())
cy.on('page:alert', () => { })
cy.on('page:alert', cy.spy())
cy.on('page:alert', cy.stub())

// window:confirm stubbing
Cypress.on('window:confirm', () => { })
Cypress.on('window:confirm', cy.spy())
Cypress.on('window:confirm', cy.stub())
cy.on('window:confirm', () => { })
cy.on('window:confirm', cy.spy())
cy.on('window:confirm', cy.stub())
Cypress.on('page:confirm', () => { })
Cypress.on('page:confirm', cy.spy())
Cypress.on('page:confirm', cy.stub())
cy.on('page:confirm', () => { })
cy.on('page:confirm', cy.spy())
cy.on('page:confirm', cy.stub())

// specifying HTTP method directly in the options object
cy.request({
Expand Down
2 changes: 1 addition & 1 deletion packages/desktop-gui/cypress.json
@@ -1,6 +1,6 @@
{
"projectId": "ypt4pf",
"pluginsFile": false,
"backgroundFile": false,
"viewportWidth": 800,
"viewportHeight": 550
}
2 changes: 1 addition & 1 deletion packages/desktop-gui/cypress/fixtures/config.json
Expand Up @@ -159,7 +159,7 @@
]
},
{
"name": "plugins",
"name": "background",
"children": [
{
"name": "index.js"
Expand Down