Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisbreiding committed Mar 16, 2021
2 parents 0158158 + 5e08c10 commit 666c5f8
Show file tree
Hide file tree
Showing 32 changed files with 374 additions and 480 deletions.
563 changes: 275 additions & 288 deletions cli/schema/cypress.schema.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion cli/types/cypress.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ declare namespace Cypress {
type RequestBody = string | object
type ViewportOrientation = 'portrait' | 'landscape'
type PrevSubject = 'optional' | 'element' | 'document' | 'window'
type PluginConfig = (on: PluginEvents, config: PluginConfigOptions, mode: 'e2e' | 'component') => void | ConfigOptions | Promise<ConfigOptions>
type PluginConfig = (on: PluginEvents, config: PluginConfigOptions) => void | ConfigOptions | Promise<ConfigOptions>

interface CommandOptions {
prevSubject: boolean | PrevSubject | PrevSubject[]
Expand Down
6 changes: 1 addition & 5 deletions npm/react/cypress/plugins/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,7 @@ const webpackConfig = {
/**
* @type Cypress.PluginConfig
*/
module.exports = (on, config, mode) => {
if (mode !== 'component') {
throw Error('This is an component project. mode should be `component`.')
}

module.exports = (on, config) => {
on('dev-server:start', (options) => {
return startDevServer({ options, webpackConfig, disableLazyCompilation: false })
})
Expand Down
6 changes: 1 addition & 5 deletions npm/vue/cypress/plugins/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,7 @@ const webpackConfig = require('../../webpack.config')
/**
* @type Cypress.PluginConfig
*/
module.exports = (on, config, mode) => {
if (mode !== 'component') {
throw Error('This is a component testing project. mode should be `component`.')
}

module.exports = (on, config) => {
require('@cypress/code-coverage/task')(on, config)
on('dev-server:start', (options) => startDevServer({ options, webpackConfig }))

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cypress",
"version": "6.7.0",
"version": "6.7.1",
"description": "Cypress.io end to end testing tool",
"private": true,
"scripts": {
Expand Down
18 changes: 18 additions & 0 deletions packages/driver/cypress/integration/commands/actions/click_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1607,6 +1607,24 @@ describe('src/cy/commands/actions/click', () => {
expect(args[2]).to.eq(animationDistanceThreshold)
})
})

describe('scroll-behavior', () => {
afterEach(() => {
cy.get('html').invoke('css', 'scrollBehavior', 'inherit')
})

// https://github.com/cypress-io/cypress/issues/3200
it('can scroll to and click elements in html with scroll-behavior: smooth', () => {
cy.get('html').invoke('css', 'scrollBehavior', 'smooth')
cy.get('#table tr:first').click()
})

// https://github.com/cypress-io/cypress/issues/3200
it('can scroll to and click elements in ancestor element with scroll-behavior: smooth', () => {
cy.get('#dom').invoke('css', 'scrollBehavior', 'smooth')
cy.get('#table tr:first').click()
})
})
})

describe('assertion verification', () => {
Expand Down
32 changes: 31 additions & 1 deletion packages/driver/src/cy/actionability.js
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,32 @@ const verify = function (cy, $el, options, callbacks) {
}
}

// scroll-behavior: smooth delays scrolling and causes the actionability
// check to fail, so the only solution is to remove the behavior and
// make scrolling occur instantly. we do this by adding a style tag
// and then removing it after we finish scrolling
// https://github.com/cypress-io/cypress/issues/3200
const addScrollBehaviorFix = () => {
let style

try {
const doc = $el.get(0).ownerDocument

style = doc.createElement('style')
style.innerHTML = '* { scroll-behavior: inherit !important; }'
// there's guaranteed to be a <script> tag, so that's the safest thing
// to query for and add the style tag after
doc.querySelector('script').after(style)
} catch (err) {
// the above shouldn't error, but out of an abundance of caution, we
// ignore any errors since this fix isn't worth failing the test over
}

return () => {
if (style) style.remove()
}
}

return Promise.try(() => {
let retryActionability
const coordsHistory = []
Expand All @@ -329,8 +355,12 @@ const verify = function (cy, $el, options, callbacks) {
// scroll the element into view
const scrollBehavior = scrollBehaviorOptionsMap[options.scrollBehavior]

$el.get(0).scrollIntoView({ block: scrollBehavior })
const removeScrollBehaviorFix = addScrollBehaviorFix()

debug('scrollIntoView:', $el[0])
$el.get(0).scrollIntoView({ block: scrollBehavior })

removeScrollBehaviorFix()

if (onScroll) {
onScroll($el, 'element')
Expand Down
3 changes: 1 addition & 2 deletions packages/server-ct/src/project-ct.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export class ProjectCt extends ProjectBase<ServerCt> {
this.server.socket.changeToUrl(targetUrl)
}

open (options: Record<string, unknown>) {
open (options) {
this._server = new ServerCt()

return super.open(options, {
Expand Down Expand Up @@ -85,7 +85,6 @@ export class ProjectCt extends ProjectBase<ServerCt> {
return plugins.init(allowedCfg, {
projectRoot: this.projectRoot,
configFile: settings.pathToConfigFile(this.projectRoot, options),
mode: options.mode,
})
.then((modifiedCfg) => {
debug('plugin config yielded: %o', modifiedCfg)
Expand Down
4 changes: 2 additions & 2 deletions packages/server/lib/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,8 @@ module.exports = {
return this.set({
projectName: this.getNameFromRoot(projectRoot),
projectRoot,
config: settings,
envFile,
config: _.cloneDeep(settings),
envFile: _.cloneDeep(envFile),
options,
})
})
Expand Down
2 changes: 1 addition & 1 deletion packages/server/lib/open_project.js
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ const moduleFactory = () => {
debug('opening project %s', path)
debug('and options %o', options)

return openProject.open({ ...options, mode: args.testingType })
return openProject.open(options)
.return(this)
},
}
Expand Down
14 changes: 4 additions & 10 deletions packages/server/lib/plugins/child/run_plugins.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,7 @@ const getDefaultPreprocessor = function (config) {

let plugins

/**
* @param {EventEmitter} ipc
* @param {object} config
* @param {string} pluginsFile
* @param {'component' | 'e2e'} string
*/
const load = (ipc, config, pluginsFile, mode) => {
const load = (ipc, config, pluginsFile) => {
debug('run plugins function')

let eventIdCount = 0
Expand Down Expand Up @@ -93,7 +87,7 @@ const load = (ipc, config, pluginsFile, mode) => {
.try(() => {
debug('run plugins function')

return plugins(register, config, mode)
return plugins(register, config)
})
.tap(() => {
if (!registeredEventsByName['file:preprocessor']) {
Expand Down Expand Up @@ -198,10 +192,10 @@ const runPlugins = (ipc, pluginsFile, projectRoot) => {
return
}

ipc.on('load', (config, mode) => {
ipc.on('load', (config) => {
debug('plugins load file "%s"', pluginsFile)
debug('passing config %o', config)
load(ipc, config, pluginsFile, mode)
load(ipc, config, pluginsFile)
})

ipc.on('execute', (event, ids, args) => {
Expand Down
2 changes: 1 addition & 1 deletion packages/server/lib/plugins/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ const init = (config, options) => {
version: pkg.version,
})

ipc.send('load', config, options.mode)
ipc.send('load', config)

ipc.on('loaded', (newCfg, registrations) => {
_.omit(config, 'projectRoot', 'configFile')
Expand Down
3 changes: 1 addition & 2 deletions packages/server/lib/project-e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export class ProjectE2E extends ProjectBase<ServerE2E> {
return 'e2e'
}

open (options: Record<string, unknown>) {
open (options) {
this._server = new ServerE2E()

return super.open(options, {
Expand Down Expand Up @@ -59,7 +59,6 @@ export class ProjectE2E extends ProjectBase<ServerE2E> {
return plugins.init(cfg, {
projectRoot: this.projectRoot,
configFile: settings.pathToConfigFile(this.projectRoot, options),
mode: options.mode,
onError (err) {
debug('got plugins error', err.stack)

Expand Down
23 changes: 1 addition & 22 deletions packages/server/lib/util/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,6 @@ module.exports = {
}, _.cloneDeep(obj))
},

isComponentTesting (options = {}) {
return options.experimentalComponentTesting || options.componentTesting || options.testingType === 'component'
},

configFile (options = {}) {
return options.configFile === false ? false : (options.configFile || 'cypress.json')
},
Expand Down Expand Up @@ -144,27 +140,10 @@ module.exports = {

const file = this.pathToConfigFile(projectRoot, options)

const requireAsync = (file) => {
return Promise.try(() => require(file))
}

return requireAsync(file)
.catch({ code: 'MODULE_NOT_FOUND' }, () => {
return this._write(file, {})
})
return fs.readJsonAsync(file)
.catch({ code: 'ENOENT' }, () => {
return this._write(file, {})
}).then((json = {}) => {
if (this.isComponentTesting(options) && 'component' in json) {
json = { ...json, ...json.component }
delete json.component
}

if (!this.isComponentTesting(options) && 'e2e' in json) {
json = { ...json, ...json.e2e }
delete json.e2e
}

const changed = this._applyRewriteRules(json)

// if our object is unchanged
Expand Down
5 changes: 0 additions & 5 deletions packages/server/test/e2e/6_visit_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ const https = require('https')
const useragent = require('express-useragent')
const { allowDestroy } = require('@packages/network')
const e2e = require('../support/helpers/e2e').default
const { clearCypressJsonCache } = require('../specUtils')

// create an HTTPS server that forces TLSv1
const startTlsV1Server = (port) => {
Expand Down Expand Up @@ -117,10 +116,6 @@ foo\
}

describe('e2e visit', () => {
beforeEach(() => {
clearCypressJsonCache()
})

context('low response timeout', () => {
e2e.setup({
settings: {
Expand Down
5 changes: 0 additions & 5 deletions packages/server/test/e2e/6_web_security_spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
const e2e = require('../support/helpers/e2e').default
const { clearCypressJsonCache } = require('../specUtils')

const onServer = function (app) {
app.get('/link', (req, res) => {
Expand Down Expand Up @@ -52,10 +51,6 @@ const onServer = function (app) {
}

describe('e2e web security', () => {
beforeEach(() => {
clearCypressJsonCache()
})

e2e.setup({
servers: [{
port: 4466,
Expand Down
5 changes: 0 additions & 5 deletions packages/server/test/e2e/7_record_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ const {
postInstanceTestsResponse,
} = require('../support/helpers/serverStub')
const { expectRunsToHaveCorrectTimings } = require('../support/helpers/resultsUtils')
const { clearCypressJsonCache } = require('../specUtils')

const e2ePath = Fixtures.projectPath('e2e')
const outputPath = path.join(e2ePath, 'output.json')
Expand Down Expand Up @@ -689,10 +688,6 @@ describe('e2e record', () => {
})

describe('create run 500', () => {
beforeEach(() => {
clearCypressJsonCache()
})

const routes = createRoutes({
postRun: {
res (req, res) {
Expand Down
Loading

4 comments on commit 666c5f8

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 666c5f8 Mar 16, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the linux x64 version of the Test Runner.

Learn more about this pre-release platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/6.7.2/circle-develop-666c5f84eee0ee809d2e2d68ebef88e76cc4b9bd/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 666c5f8 Mar 16, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AppVeyor has built the win32 ia32 version of the Test Runner.

Learn more about this pre-release platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/6.7.2/appveyor-develop-666c5f84eee0ee809d2e2d68ebef88e76cc4b9bd/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 666c5f8 Mar 16, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AppVeyor has built the win32 x64 version of the Test Runner.

Learn more about this pre-release platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/6.7.2/appveyor-develop-666c5f84eee0ee809d2e2d68ebef88e76cc4b9bd/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 666c5f8 Mar 16, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the darwin x64 version of the Test Runner.

Learn more about this pre-release platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/6.7.2/circle-develop-666c5f84eee0ee809d2e2d68ebef88e76cc4b9bd/cypress.tgz

Please sign in to comment.