Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/v4.0-release' into deprecated-pl…
Browse files Browse the repository at this point in the history
…ugins-before-browser-launch
  • Loading branch information
kuceb committed Feb 5, 2020
2 parents 431554a + 9417614 commit 2fef577
Show file tree
Hide file tree
Showing 37 changed files with 1,241 additions and 215 deletions.
2 changes: 1 addition & 1 deletion cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
"proxyquire": "2.1.0",
"shelljs": "0.8.3",
"sinon": "7.2.2",
"snap-shot-it": "7.9.1",
"snap-shot-it": "7.9.2",
"spawn-mock": "1.0.0",
"strip-ansi": "4.0.0"
},
Expand Down
51 changes: 51 additions & 0 deletions cli/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ declare namespace Cypress {
type RequestBody = string | object
type ViewportOrientation = "portrait" | "landscape"
type PrevSubject = "optional" | "element" | "document" | "window"
type PluginConfig = (on: PluginEvents, config: ConfigOptions) => void

interface CommandOptions {
prevSubject: boolean | PrevSubject | PrevSubject[]
Expand Down Expand Up @@ -4283,6 +4284,56 @@ declare namespace Cypress {
* These are the most useful events for you to listen to.
* @see https://on.cypress.io/catalog-of-events#App-Events
*/

interface browserLaunchOptions {
extensions: string[],
preferences: {[key: string]: any}
args: string[],
}

interface dimensions {
width: number
height: number
}

interface screenshotDetails {
size: number
takenAt: string
duration: number
dimensions: dimensions
multipart: boolean
pixelRatio: number
name: string
specName: string
testFailure: boolean
path: string
scaled: boolean
blackout: string[]
}

interface afterScreenshotReturnObject {
path?: string
size?: number
dimensions?: dimensions
}

interface fileObject {
filePath: string
outputPath: string
shouldWatch: boolean
}

interface tasks {
[key: string]: (value: any) => any
}

interface PluginEvents {
(action: 'before:browser:launch', fn: (browser: Browser, browserLaunchOptions: browserLaunchOptions) => browserLaunchOptions): void
(action: 'after:screenshot', fn: (details: screenshotDetails) => afterScreenshotReturnObject | Promise<afterScreenshotReturnObject>): void
(action: 'file:preprocessor', fn: (file: fileObject) => string | Promise<string>): void
(action: 'task', tasks: tasks): void
}

interface Actions {
/**
* Fires when an uncaught exception occurs in your application.
Expand Down
3 changes: 3 additions & 0 deletions packages/driver/test/cypress/plugins/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ const webpack = require('@cypress/webpack-preprocessor')

const webpackOptions = require('@packages/runner/webpack.config.ts').default

/**
* @type {Cypress.PluginConfig}
*/
module.exports = (on) => {
on('file:preprocessor', webpack({ webpackOptions }))

Expand Down
182 changes: 148 additions & 34 deletions packages/server/__snapshots__/1_deprecated_spec.ts.js

Large diffs are not rendered by default.

109 changes: 109 additions & 0 deletions packages/server/__snapshots__/4_before_browser_launch_spec.ts.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
exports['e2e before:browser:launch / modifies preferences on disk if DNE'] = `
====================================================================================================
(Run Starting)
┌────────────────────────────────────────────────────────────────────────────────────────────────┐
│ Cypress: 1.2.3 │
│ Browser: FooBrowser 88 │
│ Specs: 1 found (spec.js) │
│ Searched: cypress/integration/spec.js │
└────────────────────────────────────────────────────────────────────────────────────────────────┘
────────────────────────────────────────────────────────────────────────────────────────────────────
Running: spec.js (1 of 1)
chrome browser prefs e2e
✓ has the expected prefs
1 passing
(Results)
┌────────────────────────────────────────────────────────────────────────────────────────────────┐
│ Tests: 1 │
│ Passing: 1 │
│ Failing: 0 │
│ Pending: 0 │
│ Skipped: 0 │
│ Screenshots: 0 │
│ Video: false │
│ Duration: X seconds │
│ Spec Ran: spec.js │
└────────────────────────────────────────────────────────────────────────────────────────────────┘
====================================================================================================
(Run Finished)
Spec Tests Passing Failing Pending Skipped
┌────────────────────────────────────────────────────────────────────────────────────────────────┐
│ ✔ spec.js XX:XX 1 1 - - - │
└────────────────────────────────────────────────────────────────────────────────────────────────┘
✔ All specs passed! XX:XX 1 1 - - -
`

exports['e2e before:browser:launch / can add extensions'] = `
====================================================================================================
(Run Starting)
┌────────────────────────────────────────────────────────────────────────────────────────────────┐
│ Cypress: 1.2.3 │
│ Browser: FooBrowser 88 │
│ Specs: 1 found (spec.js) │
│ Searched: cypress/integration/spec.js │
└────────────────────────────────────────────────────────────────────────────────────────────────┘
────────────────────────────────────────────────────────────────────────────────────────────────────
Running: spec.js (1 of 1)
before:browser:launch extension e2e
✓ has the expected extension
1 passing
(Results)
┌────────────────────────────────────────────────────────────────────────────────────────────────┐
│ Tests: 1 │
│ Passing: 1 │
│ Failing: 0 │
│ Pending: 0 │
│ Skipped: 0 │
│ Screenshots: 0 │
│ Video: false │
│ Duration: X seconds │
│ Spec Ran: spec.js │
└────────────────────────────────────────────────────────────────────────────────────────────────┘
====================================================================================================
(Run Finished)
Spec Tests Passing Failing Pending Skipped
┌────────────────────────────────────────────────────────────────────────────────────────────────┐
│ ✔ spec.js XX:XX 1 1 - - - │
└────────────────────────────────────────────────────────────────────────────────────────────────┘
✔ All specs passed! XX:XX 1 1 - - -
`
Loading

0 comments on commit 2fef577

Please sign in to comment.