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

Fix negated assertions #3268

Closed
wants to merge 49 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 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
15593de
add "be.focused" to chai_jquery
kuceb Jan 24, 2019
69eb24d
add comment explaining the mess
kuceb Jan 24, 2019
e513ff1
add type definitions
kuceb Jan 24, 2019
8f7c31c
Update PLUGINS to BACKGROUND in errors spec
lilaconlee Jan 24, 2019
f932b13
refactor assertion to use jquery assertion
kuceb Jan 25, 2019
34b52d3
remove trailing whitespace
jennifer-shehane Jan 25, 2019
e4436cf
Update snapshot for background events spec
lilaconlee Jan 25, 2019
47f03a8
add test for multiple elements, update typedefs
kuceb Jan 25, 2019
314e0f1
fix failing tests: not.be.visible -> not.exist
kuceb Jan 25, 2019
8d3ace6
allow should(not.be.visible) for failed selectors
kuceb Jan 30, 2019
ab14758
remove unrelated visibility changes
kuceb Jan 30, 2019
23f590b
Merge branch 'develop' into v4.0
chrisbreiding Jan 31, 2019
b401c32
Merge remote-tracking branch 'origin/develop' into issue-97-focus-ass…
kuceb Jan 31, 2019
763066a
extract only focus assertion
kuceb Jan 31, 2019
7467dc3
fix negated assertion bug, allow not.visible to pass for non-existent
kuceb Jan 31, 2019
7964c4f
Revert "Merge remote-tracking branch 'origin/develop' into issue-97-f…
kuceb Jan 31, 2019
48a166e
Revert "Revert "Merge remote-tracking branch 'origin/develop' into is…
kuceb 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
9b2b615
Merge branch 'v4.0' into issue-205-negated-assertions
kuceb Feb 18, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
@@ -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
3 changes: 3 additions & 0 deletions circle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -717,6 +717,9 @@ linux-workflow: &linux-workflow
- desktop-gui-integration-tests-2x:
requires:
- build
- reporter-integration-tests:
requires:
- build
- run-launcher:
requires:
- build
Expand Down
6 changes: 3 additions & 3 deletions cli/schema/cypress.schema.json
Original file line number Diff line number Diff line change
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
9 changes: 6 additions & 3 deletions cli/test/lib/tasks/cache_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,12 @@ describe('lib/tasks/cache', () => {
describe('.clear', () => {
it('deletes cache folder and everything inside it', () => {
return cache.clear()
.then(() =>
fs.pathExistsAsync('/.cache/Cypress')
.then((exists) => expect(exists).to.eql(false))
.then(() => {
return fs.pathExistsAsync('/.cache/Cypress')
.then((exists) => {
return expect(exists).to.eql(false)
})
}
)
})
})
Expand Down
72 changes: 41 additions & 31 deletions cli/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1931,10 +1931,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 @@ -2163,14 +2163,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
jennifer-shehane marked this conversation as resolved.
Show resolved Hide resolved

/**
* Whether to fail on response codes other than 2xx and 3xx
Expand Down Expand Up @@ -3803,7 +3803,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 @@ -3831,7 +3841,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 @@ -3846,20 +3856,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) | Agent<sinon.SinonSpy> | Agent<sinon.SinonStub>): void
(action: 'page:confirm', fn: ((text: string) => false | void) | Agent<sinon.SinonSpy> | Agent<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 @@ -3869,87 +3879,87 @@ declare namespace Cypress {
```
* @see https://on.cypress.io/catalog-of-events#App-Events
*/
(action: 'window:alert', fn: ((text: string) => void) | Agent<sinon.SinonSpy> | Agent<sinon.SinonStub>): void
(action: 'page:alert', fn: ((text: string) => void) | Agent<sinon.SinonSpy> | Agent<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
jennifer-shehane marked this conversation as resolved.
Show resolved Hide resolved
/**
* 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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
Expand Up @@ -45,21 +45,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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@
]
},
{
"name": "plugins",
"name": "background",
"children": [
{
"name": "index.js"
Expand Down
Loading