mirror of
https://github.com/cypress-io/cypress.git
synced 2026-01-22 07:00:18 -06:00
Fix hastily-done decaffs. (#6045)
This commit is contained in:
committed by
Zach Bloomquist
parent
b130ffca87
commit
00a7e69ed2
@@ -1,19 +1,3 @@
|
||||
/* eslint-disable
|
||||
default-case,
|
||||
no-unused-vars,
|
||||
prefer-rest-params,
|
||||
prefer-spread,
|
||||
*/
|
||||
// TODO: This file was created by bulk-decaffeinate.
|
||||
// Fix any style issues and re-enable lint.
|
||||
/*
|
||||
* decaffeinate suggestions:
|
||||
* DS102: Remove unnecessary code created because of implicit returns
|
||||
* DS205: Consider reworking code to avoid use of IIFEs
|
||||
* DS206: Consider reworking classes to avoid initClass
|
||||
* DS207: Consider shorter variations of null checks
|
||||
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
|
||||
*/
|
||||
const _ = require('lodash')
|
||||
const $ = require('jquery')
|
||||
const blobUtil = require('blob-util')
|
||||
@@ -49,12 +33,12 @@ const proxies = {
|
||||
cy: 'detachDom getStyles'.split(' '),
|
||||
}
|
||||
|
||||
const jqueryProxyFn = function () {
|
||||
const jqueryProxyFn = function (...args) {
|
||||
if (!this.cy) {
|
||||
$utils.throwErrByPath('miscellaneous.no_cy')
|
||||
}
|
||||
|
||||
return this.cy.$$.apply(this.cy, arguments)
|
||||
return this.cy.$$.apply(this.cy, args)
|
||||
}
|
||||
|
||||
_.extend(jqueryProxyFn, $)
|
||||
@@ -65,75 +49,35 @@ $Log.command = () => {
|
||||
return $utils.throwErrByPath('miscellaneous.command_log_renamed')
|
||||
}
|
||||
|
||||
const throwDeprecatedCommandInterface = function (key, method) {
|
||||
const signature = (() => {
|
||||
switch (method) {
|
||||
case 'addParentCommand':
|
||||
return `'${key}', function(){...}`
|
||||
case 'addChildCommand':
|
||||
return `'${key}', { prevSubject: true }, function(){...}`
|
||||
case 'addDualCommand':
|
||||
return `'${key}', { prevSubject: 'optional' }, function(){...}`
|
||||
}
|
||||
})()
|
||||
const throwDeprecatedCommandInterface = (key, method) => {
|
||||
let signature = ''
|
||||
|
||||
return $utils.throwErrByPath('miscellaneous.custom_command_interface_changed', {
|
||||
switch (method) {
|
||||
case 'addParentCommand':
|
||||
signature = `'${key}', function(){...}`
|
||||
break
|
||||
case 'addChildCommand':
|
||||
signature = `'${key}', { prevSubject: true }, function(){...}`
|
||||
break
|
||||
case 'addDualCommand':
|
||||
signature = `'${key}', { prevSubject: 'optional' }, function(){...}`
|
||||
break
|
||||
default:
|
||||
break
|
||||
}
|
||||
|
||||
$utils.throwErrByPath('miscellaneous.custom_command_interface_changed', {
|
||||
args: { method, signature },
|
||||
})
|
||||
}
|
||||
|
||||
const throwPrivateCommandInterface = (method) => {
|
||||
return $utils.throwErrByPath('miscellaneous.private_custom_command_interface', {
|
||||
$utils.throwErrByPath('miscellaneous.private_custom_command_interface', {
|
||||
args: { method },
|
||||
})
|
||||
}
|
||||
|
||||
class $Cypress {
|
||||
static initClass () {
|
||||
this.prototype.$ = jqueryProxyFn
|
||||
|
||||
// attach to $Cypress to access
|
||||
// all of the constructors
|
||||
// to enable users to monkeypatch
|
||||
this.prototype.$Cypress = $Cypress
|
||||
this.prototype.Cy = $Cy
|
||||
this.prototype.Chainer = $Chainer
|
||||
this.prototype.Cookies = $Cookies
|
||||
this.prototype.Command = $Command
|
||||
this.prototype.Commands = $Commands
|
||||
this.prototype.dom = $dom
|
||||
this.prototype.errorMessages = $errorMessages
|
||||
this.prototype.Keyboard = $Keyboard
|
||||
this.prototype.Location = $Location
|
||||
this.prototype.Log = $Log
|
||||
this.prototype.LocalStorage = $LocalStorage
|
||||
this.prototype.Mocha = $Mocha
|
||||
this.prototype.Mouse = $Mouse
|
||||
this.prototype.Runner = $Runner
|
||||
this.prototype.Server = $Server
|
||||
this.prototype.Screenshot = $Screenshot
|
||||
this.prototype.SelectorPlayground = $SelectorPlayground
|
||||
this.prototype.utils = $utils
|
||||
this.prototype._ = _
|
||||
this.prototype.moment = moment
|
||||
this.prototype.Blob = blobUtil
|
||||
this.prototype.Promise = Promise
|
||||
this.prototype.minimatch = minimatch
|
||||
this.prototype.sinon = sinon
|
||||
this.prototype.lolex = lolex
|
||||
|
||||
// proxy all of the methods in proxies
|
||||
// to their corresponding objects
|
||||
_.each(proxies, (methods, key) => {
|
||||
return _.each(methods, (method) => {
|
||||
return $Cypress.prototype[method] = function () {
|
||||
const prop = this[key]
|
||||
|
||||
return prop && prop[method].apply(prop, arguments)
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
constructor (config = {}) {
|
||||
this.cy = null
|
||||
this.chai = null
|
||||
@@ -169,12 +113,10 @@ class $Cypress {
|
||||
// }
|
||||
// }
|
||||
|
||||
let d = config.remote ? config.remote.domainName : undefined
|
||||
|
||||
// set domainName but allow us to turn
|
||||
// off this feature in testing
|
||||
let d
|
||||
|
||||
d = config.remote != null ? config.remote.domainName : undefined
|
||||
|
||||
if (d) {
|
||||
document.domain = d
|
||||
}
|
||||
@@ -206,7 +148,7 @@ class $Cypress {
|
||||
longStackTraces: config.isInteractive,
|
||||
})
|
||||
|
||||
const { env, remote } = config
|
||||
const { env } = config
|
||||
|
||||
config = _.omit(config, 'env', 'remote', 'resolved', 'scaffoldedFiles', 'javascripts', 'state')
|
||||
|
||||
@@ -246,7 +188,8 @@ class $Cypress {
|
||||
}
|
||||
|
||||
// create cy and expose globally
|
||||
this.cy = (window.cy = $Cy.create(specWindow, this, this.Cookies, this.state, this.config, logFn))
|
||||
this.cy = $Cy.create(specWindow, this, this.Cookies, this.state, this.config, logFn)
|
||||
window.cy = this.cy
|
||||
this.isCy = this.cy.isCy
|
||||
this.log = $Log.create(this, this.cy, this.state, this.config)
|
||||
this.mocha = $Mocha.create(specWindow, this)
|
||||
@@ -521,15 +464,16 @@ class $Cypress {
|
||||
|
||||
case 'spec:script:error':
|
||||
return this.emit('script:error', ...args)
|
||||
|
||||
default:
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
backend (eventName, ...args) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const fn = function (reply) {
|
||||
let e
|
||||
|
||||
e = reply.error
|
||||
const e = reply.error
|
||||
|
||||
if (e) {
|
||||
// clone the error object
|
||||
@@ -557,9 +501,7 @@ class $Cypress {
|
||||
// wrap action in promise
|
||||
return new Promise((resolve, reject) => {
|
||||
const fn = function (reply) {
|
||||
let e
|
||||
|
||||
e = reply.error
|
||||
const e = reply.error
|
||||
|
||||
if (e) {
|
||||
const err = $utils.cloneErr(e)
|
||||
@@ -583,23 +525,23 @@ class $Cypress {
|
||||
return this.action('cypress:stop')
|
||||
}
|
||||
|
||||
addChildCommand (key, fn) {
|
||||
addChildCommand (key) {
|
||||
return throwDeprecatedCommandInterface(key, 'addChildCommand')
|
||||
}
|
||||
|
||||
addParentCommand (key, fn) {
|
||||
addParentCommand (key) {
|
||||
return throwDeprecatedCommandInterface(key, 'addParentCommand')
|
||||
}
|
||||
|
||||
addDualCommand (key, fn) {
|
||||
addDualCommand (key) {
|
||||
return throwDeprecatedCommandInterface(key, 'addDualCommand')
|
||||
}
|
||||
|
||||
addAssertionCommand (key, fn) {
|
||||
addAssertionCommand () {
|
||||
return throwPrivateCommandInterface('addAssertionCommand')
|
||||
}
|
||||
|
||||
addUtilityCommand (key, fn) {
|
||||
addUtilityCommand () {
|
||||
return throwPrivateCommandInterface('addUtilityCommand')
|
||||
}
|
||||
|
||||
@@ -607,7 +549,50 @@ class $Cypress {
|
||||
return new $Cypress(config)
|
||||
}
|
||||
}
|
||||
$Cypress.initClass()
|
||||
|
||||
$Cypress.prototype.$ = jqueryProxyFn
|
||||
|
||||
// attach to $Cypress to access
|
||||
// all of the constructors
|
||||
// to enable users to monkeypatch
|
||||
$Cypress.prototype.$Cypress = $Cypress
|
||||
$Cypress.prototype.Cy = $Cy
|
||||
$Cypress.prototype.Chainer = $Chainer
|
||||
$Cypress.prototype.Cookies = $Cookies
|
||||
$Cypress.prototype.Command = $Command
|
||||
$Cypress.prototype.Commands = $Commands
|
||||
$Cypress.prototype.dom = $dom
|
||||
$Cypress.prototype.errorMessages = $errorMessages
|
||||
$Cypress.prototype.Keyboard = $Keyboard
|
||||
$Cypress.prototype.Location = $Location
|
||||
$Cypress.prototype.Log = $Log
|
||||
$Cypress.prototype.LocalStorage = $LocalStorage
|
||||
$Cypress.prototype.Mocha = $Mocha
|
||||
$Cypress.prototype.Mouse = $Mouse
|
||||
$Cypress.prototype.Runner = $Runner
|
||||
$Cypress.prototype.Server = $Server
|
||||
$Cypress.prototype.Screenshot = $Screenshot
|
||||
$Cypress.prototype.SelectorPlayground = $SelectorPlayground
|
||||
$Cypress.prototype.utils = $utils
|
||||
$Cypress.prototype._ = _
|
||||
$Cypress.prototype.moment = moment
|
||||
$Cypress.prototype.Blob = blobUtil
|
||||
$Cypress.prototype.Promise = Promise
|
||||
$Cypress.prototype.minimatch = minimatch
|
||||
$Cypress.prototype.sinon = sinon
|
||||
$Cypress.prototype.lolex = lolex
|
||||
|
||||
// proxy all of the methods in proxies
|
||||
// to their corresponding objects
|
||||
_.each(proxies, (methods, key) => {
|
||||
return _.each(methods, (method) => {
|
||||
return $Cypress.prototype[method] = function (...args) {
|
||||
const prop = this[key]
|
||||
|
||||
return prop && prop[method].apply(prop, args)
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
// attaching these so they are accessible
|
||||
// via the runner + integration spec helper
|
||||
|
||||
@@ -99,8 +99,8 @@ describe('src/cy/commands/assertions', () => {
|
||||
cy.noop(obj).its('requestJSON').should('have.property', 'teamIds').should('deep.eq', [2])
|
||||
})
|
||||
|
||||
//# TODO: make cy.then retry
|
||||
//# https://github.com/cypress-io/cypress/issues/627
|
||||
// TODO: make cy.then retry
|
||||
// https://github.com/cypress-io/cypress/issues/627
|
||||
it.skip('outer assertions retry on cy.then', () => {
|
||||
const obj = { foo: 'bar' }
|
||||
|
||||
@@ -150,7 +150,7 @@ describe('src/cy/commands/assertions', () => {
|
||||
cy.wrap(obj).should((o) => {
|
||||
expect(o).to.have.property('foo').and.eq('bar')
|
||||
}).then(function () {
|
||||
//# wrap + have property + and eq
|
||||
// wrap + have property + and eq
|
||||
expect(this.logs.length).to.eq(3)
|
||||
})
|
||||
})
|
||||
@@ -176,8 +176,8 @@ describe('src/cy/commands/assertions', () => {
|
||||
|
||||
expect(this.logs.length).to.eq(3)
|
||||
|
||||
//# the messages should have been updated to reflect
|
||||
//# the current state of the <body> element
|
||||
// the messages should have been updated to reflect
|
||||
// the current state of the <body> element
|
||||
expect(this.logs[1].get('message')).to.eq('expected **<body#bar.foo>** to have class **foo**')
|
||||
|
||||
expect(this.logs[2].get('message')).to.eq('expected **<body#bar.foo>** to have id **bar**')
|
||||
@@ -436,9 +436,9 @@ describe('src/cy/commands/assertions', () => {
|
||||
cy.on('fail', (err) => {
|
||||
const names = _.invokeMap(this.logs, 'get', 'name')
|
||||
|
||||
//# the 'should' is not here because based on
|
||||
//# when we check for the element to be detached
|
||||
//# it never actually runs the assertion
|
||||
// the 'should' is not here because based on
|
||||
// when we check for the element to be detached
|
||||
// it never actually runs the assertion
|
||||
expect(names).to.deep.eq(['get', 'click'])
|
||||
expect(err.message).to.include('cy.should() failed because this element is detached')
|
||||
|
||||
@@ -462,7 +462,7 @@ describe('src/cy/commands/assertions', () => {
|
||||
cy.on('fail', (err) => {
|
||||
const names = _.invokeMap(this.logs, 'get', 'name')
|
||||
|
||||
//# should is present here due to the retry
|
||||
// should is present here due to the retry
|
||||
expect(names).to.deep.eq(['get', 'click', 'assert'])
|
||||
expect(err.message).to.include('cy.should() failed because this element is detached')
|
||||
|
||||
@@ -475,8 +475,8 @@ describe('src/cy/commands/assertions', () => {
|
||||
})
|
||||
|
||||
it('throws when should(\'have.length\') isnt a number', function (done) {
|
||||
//# we specifically turn off logging have.length validation errors
|
||||
//# because the assertion will already be logged
|
||||
// we specifically turn off logging have.length validation errors
|
||||
// because the assertion will already be logged
|
||||
cy.on('fail', (err) => {
|
||||
const { lastLog } = this
|
||||
|
||||
@@ -889,7 +889,7 @@ describe('src/cy/commands/assertions', () => {
|
||||
}
|
||||
})
|
||||
|
||||
//# prepend an empty div so it has no id or class
|
||||
// prepend an empty div so it has no id or class
|
||||
cy.$$('body').prepend($('<div />'))
|
||||
|
||||
// expect($div).to.match("div")
|
||||
@@ -909,7 +909,7 @@ describe('src/cy/commands/assertions', () => {
|
||||
}
|
||||
})
|
||||
|
||||
//# prepend an empty div so it has no id or class
|
||||
// prepend an empty div so it has no id or class
|
||||
cy.$$('body').prepend($('<input />'))
|
||||
|
||||
cy.get('input').eq(0).then(($div) => {
|
||||
@@ -1102,7 +1102,7 @@ describe('src/cy/commands/assertions', () => {
|
||||
cy.noop('foobar').should('contain', 'oob')
|
||||
})
|
||||
|
||||
//# https://github.com/cypress-io/cypress/issues/3549
|
||||
// https://github.com/cypress-io/cypress/issues/3549
|
||||
it('is true when DOM el and not jQuery el contains text', () => {
|
||||
cy.get('div').then(($el) => {
|
||||
cy.wrap($el[1]).should('contain', 'Nested Find')
|
||||
@@ -1264,11 +1264,11 @@ describe('src/cy/commands/assertions', () => {
|
||||
})
|
||||
|
||||
it('no prop, with prop, negation, and chainable', function () {
|
||||
expect(this.$div).to.have.data('foo') //# 1
|
||||
expect(this.$div).to.have.data('foo', 'bar') //# 2,3
|
||||
expect(this.$div).to.have.data('foo').and.eq('bar') //# 4,5
|
||||
expect(this.$div).to.have.data('foo').and.match(/bar/) //# 6,7
|
||||
expect(this.$div).not.to.have.data('baz') //# 8
|
||||
expect(this.$div).to.have.data('foo') // 1
|
||||
expect(this.$div).to.have.data('foo', 'bar') // 2,3
|
||||
expect(this.$div).to.have.data('foo').and.eq('bar') // 4,5
|
||||
expect(this.$div).to.have.data('foo').and.match(/bar/) // 6,7
|
||||
expect(this.$div).not.to.have.data('baz') // 8
|
||||
|
||||
expect(this.logs.length).to.eq(8)
|
||||
})
|
||||
@@ -1296,9 +1296,9 @@ describe('src/cy/commands/assertions', () => {
|
||||
})
|
||||
|
||||
it('class, not class', function () {
|
||||
expect(this.$div).to.have.class('foo') //# 1
|
||||
expect(this.$div).to.have.class('bar') //# 2
|
||||
expect(this.$div).not.to.have.class('baz') //# 3
|
||||
expect(this.$div).to.have.class('foo') // 1
|
||||
expect(this.$div).to.have.class('bar') // 2
|
||||
expect(this.$div).not.to.have.class('baz') // 3
|
||||
|
||||
expect(this.logs.length).to.eq(3)
|
||||
|
||||
@@ -1364,12 +1364,12 @@ describe('src/cy/commands/assertions', () => {
|
||||
})
|
||||
|
||||
it('id, not id', function () {
|
||||
expect(this.$div).to.have.id('foo') //# 1
|
||||
expect(this.$div).not.to.have.id('bar') //# 2
|
||||
expect(this.$div).to.have.id('foo') // 1
|
||||
expect(this.$div).not.to.have.id('bar') // 2
|
||||
|
||||
expect(this.$div2).to.have.id('foo') //# 3
|
||||
expect(this.$div2).to.have.id('foo') // 3
|
||||
|
||||
expect(this.$div3).to.have.id('foo') //# 4
|
||||
expect(this.$div3).to.have.id('foo') // 4
|
||||
|
||||
expect(this.logs.length).to.eq(4)
|
||||
|
||||
@@ -1411,8 +1411,8 @@ describe('src/cy/commands/assertions', () => {
|
||||
})
|
||||
|
||||
it('html, not html, contain html', function () {
|
||||
expect(this.$div).to.have.html('<button>button</button>') //# 1
|
||||
expect(this.$div).not.to.have.html('foo') //# 2
|
||||
expect(this.$div).to.have.html('<button>button</button>') // 1
|
||||
expect(this.$div).not.to.have.html('foo') // 2
|
||||
expect(this.logs.length).to.eq(2)
|
||||
|
||||
const l1 = this.logs[0]
|
||||
@@ -1433,7 +1433,7 @@ describe('src/cy/commands/assertions', () => {
|
||||
)
|
||||
|
||||
this.clearLogs()
|
||||
expect(this.$div).to.not.contain.html('foo') //# 4
|
||||
expect(this.$div).to.not.contain.html('foo') // 4
|
||||
expect(this.logs[0].get('message')).to.eq(
|
||||
'expected **<div>** not to contain HTML **foo**'
|
||||
)
|
||||
@@ -1491,8 +1491,8 @@ describe('src/cy/commands/assertions', () => {
|
||||
})
|
||||
|
||||
it('text, not text, contain text', function () {
|
||||
expect(this.$div).to.have.text('foo') //# 1
|
||||
expect(this.$div).not.to.have.text('bar') //# 2
|
||||
expect(this.$div).to.have.text('foo') // 1
|
||||
expect(this.$div).not.to.have.text('bar') // 2
|
||||
|
||||
expect(this.logs.length).to.eq(2)
|
||||
|
||||
@@ -1573,8 +1573,8 @@ describe('src/cy/commands/assertions', () => {
|
||||
})
|
||||
|
||||
it('value, not value, contain value', function () {
|
||||
expect(this.$input).to.have.value('foo') //# 1
|
||||
expect(this.$input).not.to.have.value('bar') //# 2
|
||||
expect(this.$input).to.have.value('foo') // 1
|
||||
expect(this.$input).not.to.have.value('bar') // 2
|
||||
|
||||
expect(this.logs.length).to.eq(2)
|
||||
|
||||
@@ -1639,7 +1639,7 @@ describe('src/cy/commands/assertions', () => {
|
||||
it('partial match', function () {
|
||||
expect(this.$input).to.contain.value('oo')
|
||||
expect(this.$input).to.not.contain.value('oof')
|
||||
//# make sure "includes" is an alias of "include"
|
||||
// make sure "includes" is an alias of "include"
|
||||
expect(this.$input).to.includes.value('oo')
|
||||
cy.get('input')
|
||||
.invoke('val', 'foobar')
|
||||
@@ -1671,8 +1671,8 @@ describe('src/cy/commands/assertions', () => {
|
||||
})
|
||||
|
||||
it('descendants, not descendants', function () {
|
||||
expect(this.$div).to.have.descendants('button') //# 1
|
||||
expect(this.$div).not.to.have.descendants('input') //# 2
|
||||
expect(this.$div).to.have.descendants('button') // 1
|
||||
expect(this.$div).not.to.have.descendants('input') // 2
|
||||
|
||||
expect(this.logs.length).to.eq(2)
|
||||
|
||||
@@ -1725,8 +1725,8 @@ describe('src/cy/commands/assertions', () => {
|
||||
})
|
||||
|
||||
it('visible, not visible, adds to error', function () {
|
||||
expect(this.$div).to.be.visible //# 1
|
||||
expect(this.$div2).not.to.be.visible //# 2
|
||||
expect(this.$div).to.be.visible // 1
|
||||
expect(this.$div2).not.to.be.visible // 2
|
||||
|
||||
expect(this.logs.length).to.eq(2)
|
||||
|
||||
@@ -1746,7 +1746,7 @@ describe('src/cy/commands/assertions', () => {
|
||||
} catch (err) {
|
||||
const l6 = this.logs[5]
|
||||
|
||||
//# the error on this log should have this message appended to it
|
||||
// the error on this log should have this message appended to it
|
||||
expect(l6.get('error').message).to.eq(
|
||||
`\
|
||||
expected '<div>' to be 'visible'
|
||||
@@ -1794,8 +1794,8 @@ This element '<div>' is not visible because it has CSS property: 'display: none'
|
||||
})
|
||||
|
||||
it('hidden, not hidden, adds to error', function () {
|
||||
expect(this.$div).to.be.hidden //# 1
|
||||
expect(this.$div2).not.to.be.hidden //# 2
|
||||
expect(this.$div).to.be.hidden // 1
|
||||
expect(this.$div2).not.to.be.hidden // 2
|
||||
|
||||
expect(this.logs.length).to.eq(2)
|
||||
|
||||
@@ -1815,7 +1815,7 @@ This element '<div>' is not visible because it has CSS property: 'display: none'
|
||||
} catch (err) {
|
||||
const l6 = this.logs[5]
|
||||
|
||||
//# the error on this log should have this message appended to it
|
||||
// the error on this log should have this message appended to it
|
||||
expect(l6.get('error').message).to.eq('expected \'<div>\' to be \'hidden\'')
|
||||
}
|
||||
})
|
||||
@@ -1851,8 +1851,8 @@ This element '<div>' is not visible because it has CSS property: 'display: none'
|
||||
})
|
||||
|
||||
it('selected, not selected', function () {
|
||||
expect(this.$option).to.be.selected //# 1
|
||||
expect(this.$option2).not.to.be.selected //# 2
|
||||
expect(this.$option).to.be.selected // 1
|
||||
expect(this.$option2).not.to.be.selected // 2
|
||||
|
||||
expect(this.logs.length).to.eq(2)
|
||||
|
||||
@@ -1899,8 +1899,8 @@ This element '<div>' is not visible because it has CSS property: 'display: none'
|
||||
})
|
||||
|
||||
it('checked, not checked', function () {
|
||||
expect(this.$input).to.be.checked //# 1
|
||||
expect(this.$input2).not.to.be.checked //# 2
|
||||
expect(this.$input).to.be.checked // 1
|
||||
expect(this.$input2).not.to.be.checked // 2
|
||||
|
||||
expect(this.logs.length).to.eq(2)
|
||||
|
||||
@@ -1947,8 +1947,8 @@ This element '<div>' is not visible because it has CSS property: 'display: none'
|
||||
})
|
||||
|
||||
it('enabled, not enabled', function () {
|
||||
expect(this.$input).to.be.enabled //# 1
|
||||
expect(this.$input2).not.to.be.enabled //# 2
|
||||
expect(this.$input).to.be.enabled // 1
|
||||
expect(this.$input2).not.to.be.enabled // 2
|
||||
|
||||
expect(this.logs.length).to.eq(2)
|
||||
|
||||
@@ -1995,8 +1995,8 @@ This element '<div>' is not visible because it has CSS property: 'display: none'
|
||||
})
|
||||
|
||||
it('disabled, not disabled', function () {
|
||||
expect(this.$input).to.be.disabled //# 1
|
||||
expect(this.$input2).not.to.be.disabled //# 2
|
||||
expect(this.$input).to.be.disabled // 1
|
||||
expect(this.$input2).not.to.be.disabled // 2
|
||||
|
||||
expect(this.logs.length).to.eq(2)
|
||||
|
||||
@@ -2093,11 +2093,11 @@ This element '<div>' is not visible because it has CSS property: 'display: none'
|
||||
})
|
||||
|
||||
it('empty, not empty, raw dom documents', function () {
|
||||
expect(this.div).to.be.empty //# 1
|
||||
expect(this.div2).not.to.be.empty //# 2
|
||||
expect(this.div).to.be.empty // 1
|
||||
expect(this.div2).not.to.be.empty // 2
|
||||
|
||||
expect(this.div.get(0)).to.be.empty //# 3
|
||||
expect(this.div2.get(0)).not.to.be.empty //# 4
|
||||
expect(this.div.get(0)).to.be.empty // 3
|
||||
expect(this.div2.get(0)).not.to.be.empty // 4
|
||||
|
||||
expect(this.logs.length).to.eq(4)
|
||||
|
||||
@@ -2248,11 +2248,11 @@ This element '<div>' is not visible because it has CSS property: 'display: none'
|
||||
})
|
||||
|
||||
it('match, not match, raw dom documents', function () {
|
||||
expect(this.div).to.match('div') //# 1
|
||||
expect(this.div).not.to.match('button') //# 2
|
||||
expect(this.div).to.match('div') // 1
|
||||
expect(this.div).not.to.match('button') // 2
|
||||
|
||||
expect(this.div.get(0)).to.match('div') //# 3
|
||||
expect(this.div.get(0)).not.to.match('button') //# 4
|
||||
expect(this.div.get(0)).to.match('div') // 3
|
||||
expect(this.div.get(0)).not.to.match('button') // 4
|
||||
|
||||
expect(this.logs.length).to.eq(4)
|
||||
|
||||
@@ -2281,9 +2281,9 @@ This element '<div>' is not visible because it has CSS property: 'display: none'
|
||||
|
||||
context('contain', () => {
|
||||
it('passes thru non DOM', function () {
|
||||
expect(['foo']).to.contain('foo') //# 1
|
||||
expect({ foo: 'bar', baz: 'quux' }).to.contain({ foo: 'bar' }) //# 2, 3
|
||||
expect('foo').to.contain('fo') //# 4
|
||||
expect(['foo']).to.contain('foo') // 1
|
||||
expect({ foo: 'bar', baz: 'quux' }).to.contain({ foo: 'bar' }) // 2, 3
|
||||
expect('foo').to.contain('fo') // 4
|
||||
|
||||
expect(this.logs.length).to.eq(4)
|
||||
|
||||
@@ -2324,19 +2324,19 @@ This element '<div>' is not visible because it has CSS property: 'display: none'
|
||||
})
|
||||
|
||||
it('attr, not attr', function () {
|
||||
expect(this.$div).to.have.attr('foo') //# 1
|
||||
expect(this.$div).to.have.attr('foo', 'bar') //# 2
|
||||
expect(this.$div).not.to.have.attr('bar') //# 3
|
||||
expect(this.$div).not.to.have.attr('bar', 'baz') //# 4
|
||||
expect(this.$div).not.to.have.attr('foo', 'baz') //# 5
|
||||
expect(this.$div).to.have.attr('foo') // 1
|
||||
expect(this.$div).to.have.attr('foo', 'bar') // 2
|
||||
expect(this.$div).not.to.have.attr('bar') // 3
|
||||
expect(this.$div).not.to.have.attr('bar', 'baz') // 4
|
||||
expect(this.$div).not.to.have.attr('foo', 'baz') // 5
|
||||
|
||||
expect(this.$a).to.have.attr('href').and.match(/google/) //# 6, 7
|
||||
expect(this.$a).to.have.attr('href').and.match(/google/) // 6, 7
|
||||
expect(this.$a)
|
||||
.to.have.attr('href', 'https://google.com') //# 8
|
||||
.and.have.text('google') //# 9
|
||||
.to.have.attr('href', 'https://google.com') // 8
|
||||
.and.have.text('google') // 9
|
||||
|
||||
try {
|
||||
expect(this.$a).not.to.have.attr('href', 'https://google.com') //# 10
|
||||
expect(this.$a).not.to.have.attr('href', 'https://google.com') // 10
|
||||
} catch (error) {} // eslint-disable-line no-empty
|
||||
|
||||
expect(this.logs.length).to.eq(10)
|
||||
@@ -2425,21 +2425,21 @@ This element '<div>' is not visible because it has CSS property: 'display: none'
|
||||
})
|
||||
|
||||
it('prop, not prop', function () {
|
||||
expect(this.$input).to.have.prop('checked') //# 1
|
||||
expect(this.$input).to.have.prop('checked', true) //# 2
|
||||
expect(this.$input).not.to.have.prop('bar') //# 3
|
||||
expect(this.$input).not.to.have.prop('bar', 'baz') //# 4
|
||||
expect(this.$input).not.to.have.prop('checked', 'baz') //# 5
|
||||
expect(this.$input).to.have.prop('checked') // 1
|
||||
expect(this.$input).to.have.prop('checked', true) // 2
|
||||
expect(this.$input).not.to.have.prop('bar') // 3
|
||||
expect(this.$input).not.to.have.prop('bar', 'baz') // 4
|
||||
expect(this.$input).not.to.have.prop('checked', 'baz') // 5
|
||||
|
||||
const href = `${window.location.origin}/foo`
|
||||
|
||||
expect(this.$a).to.have.prop('href').and.match(/foo/) //# 6, 7
|
||||
expect(this.$a).to.have.prop('href').and.match(/foo/) // 6, 7
|
||||
expect(this.$a)
|
||||
.to.have.prop('href', href) //# 8
|
||||
.and.have.text('google') //# 9
|
||||
.to.have.prop('href', href) // 8
|
||||
.and.have.text('google') // 9
|
||||
|
||||
try {
|
||||
expect(this.$a).not.to.have.prop('href', href) //# 10
|
||||
expect(this.$a).not.to.have.prop('href', href) // 10
|
||||
} catch (error) {} // eslint-disable-line no-empty
|
||||
|
||||
expect(this.logs.length).to.eq(10)
|
||||
@@ -2522,14 +2522,14 @@ This element '<div>' is not visible because it has CSS property: 'display: none'
|
||||
})
|
||||
|
||||
it('css, not css', function () {
|
||||
expect(this.$div).to.have.css('display') //# 1
|
||||
expect(this.$div).to.have.css('display', 'none') //# 2
|
||||
expect(this.$div).not.to.have.css('bar') //# 3
|
||||
expect(this.$div).not.to.have.css('bar', 'baz') //# 4
|
||||
expect(this.$div).not.to.have.css('display', 'inline') //# 5
|
||||
expect(this.$div).to.have.css('display') // 1
|
||||
expect(this.$div).to.have.css('display', 'none') // 2
|
||||
expect(this.$div).not.to.have.css('bar') // 3
|
||||
expect(this.$div).not.to.have.css('bar', 'baz') // 4
|
||||
expect(this.$div).not.to.have.css('display', 'inline') // 5
|
||||
|
||||
try {
|
||||
expect(this.$div).not.to.have.css('display', 'none') //# 6
|
||||
expect(this.$div).not.to.have.css('display', 'none') // 6
|
||||
} catch (error) {} // eslint-disable-line no-empty
|
||||
|
||||
expect(this.logs.length).to.eq(6)
|
||||
|
||||
@@ -1,10 +1,3 @@
|
||||
// TODO: This file was created by bulk-decaffeinate.
|
||||
// Sanity-check the conversion and remove this comment.
|
||||
/*
|
||||
* decaffeinate suggestions:
|
||||
* DS102: Remove unnecessary code created because of implicit returns
|
||||
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
|
||||
*/
|
||||
const os = require('os')
|
||||
const path = require('path')
|
||||
const ospath = require('ospath')
|
||||
@@ -25,7 +18,7 @@ if (!PRODUCT_NAME) {
|
||||
throw new Error('Root package is missing name')
|
||||
}
|
||||
|
||||
const getSymlinkType = function () {
|
||||
const getSymlinkType = () => {
|
||||
if (os.platform() === 'win32') {
|
||||
return 'junction'
|
||||
}
|
||||
@@ -49,7 +42,7 @@ module.exports = {
|
||||
})
|
||||
}
|
||||
|
||||
//# try twice to ensure the dir
|
||||
// try twice to ensure the dir
|
||||
return ensure()
|
||||
.catch(ensure)
|
||||
},
|
||||
@@ -74,7 +67,7 @@ module.exports = {
|
||||
la(check.unemptyString(env.CYPRESS_ENV),
|
||||
'expected CYPRESS_ENV, found', env.CYPRESS_ENV)
|
||||
|
||||
//# allow overriding the app_data folder
|
||||
// allow overriding the app_data folder
|
||||
const folder = env.CYPRESS_KONFIG_ENV || env.CYPRESS_ENV
|
||||
|
||||
const p = path.join(ELECTRON_APP_DATA_PATH, 'cy', folder, ...paths)
|
||||
|
||||
@@ -13,7 +13,7 @@ const everythingAfterFirstEqualRe = /=(.*)/
|
||||
const whitelist = 'appPath apiKey browser ci ciBuildId clearLogs config configFile cwd env execPath exit exitWithCode generateKey getKey group headed inspectBrk key logs mode outputPath parallel ping port project proxySource record reporter reporterOptions returnPkg runMode runProject smokeTest spec tag updating version'.split(' ')
|
||||
// returns true if the given string has double quote character "
|
||||
// only at the last position.
|
||||
const hasStrayEndQuote = function (s) {
|
||||
const hasStrayEndQuote = (s) => {
|
||||
const quoteAt = s.indexOf('"')
|
||||
|
||||
return quoteAt === (s.length - 1)
|
||||
@@ -23,7 +23,7 @@ const removeLastCharacter = (s) => {
|
||||
return s.substr(0, s.length - 1)
|
||||
}
|
||||
|
||||
const normalizeBackslash = function (s) {
|
||||
const normalizeBackslash = (s) => {
|
||||
if (hasStrayEndQuote(s)) {
|
||||
return removeLastCharacter(s)
|
||||
}
|
||||
@@ -31,7 +31,7 @@ const normalizeBackslash = function (s) {
|
||||
return s
|
||||
}
|
||||
|
||||
const normalizeBackslashes = function (options) {
|
||||
const normalizeBackslashes = (options) => {
|
||||
// remove stray double quote from runProject and other path properties
|
||||
// due to bug in NPM passing arguments with
|
||||
// backslash at the end
|
||||
@@ -48,7 +48,7 @@ const normalizeBackslashes = function (options) {
|
||||
return options
|
||||
}
|
||||
|
||||
const stringify = function (val) {
|
||||
const stringify = (val) => {
|
||||
if (_.isObject(val)) {
|
||||
return JSON.stringify(val)
|
||||
}
|
||||
@@ -56,7 +56,7 @@ const stringify = function (val) {
|
||||
return val
|
||||
}
|
||||
|
||||
const strToArray = function (str) {
|
||||
const strToArray = (str) => {
|
||||
const parsed = tryJSONParse(str)
|
||||
|
||||
if (parsed) {
|
||||
@@ -67,7 +67,7 @@ const strToArray = function (str) {
|
||||
}
|
||||
|
||||
// swap out comma's for bars
|
||||
const commasToPipes = (match, p1, p2, p3) => {
|
||||
const commasToPipes = (match) => {
|
||||
return match.split(',').join('|')
|
||||
}
|
||||
|
||||
@@ -77,7 +77,7 @@ const pipesToCommas = (str) => {
|
||||
return str.split('|').join(',')
|
||||
}
|
||||
|
||||
const tryJSONParse = function (str) {
|
||||
const tryJSONParse = (str) => {
|
||||
try {
|
||||
return JSON.parse(str)
|
||||
} catch (err) {
|
||||
@@ -85,7 +85,7 @@ const tryJSONParse = function (str) {
|
||||
}
|
||||
}
|
||||
|
||||
const JSONOrCoerce = function (str) {
|
||||
const JSONOrCoerce = (str) => {
|
||||
// valid JSON? horray
|
||||
const parsed = tryJSONParse(str)
|
||||
|
||||
@@ -107,7 +107,7 @@ const JSONOrCoerce = function (str) {
|
||||
return coerceUtil(str)
|
||||
}
|
||||
|
||||
const sanitizeAndConvertNestedArgs = function (str) {
|
||||
const sanitizeAndConvertNestedArgs = (str) => {
|
||||
// if this is valid JSON then just
|
||||
// parse it and call it a day
|
||||
const parsed = tryJSONParse(str)
|
||||
|
||||
@@ -99,7 +99,7 @@ const CI_PROVIDERS = {
|
||||
'wercker': isWercker,
|
||||
}
|
||||
|
||||
const _detectProviderName = function () {
|
||||
const _detectProviderName = () => {
|
||||
const { env } = process
|
||||
|
||||
// return the key of the first provider
|
||||
@@ -338,7 +338,7 @@ const _providerCiParams = () => {
|
||||
|
||||
// tries to grab commit information from CI environment variables
|
||||
// very useful to fill missing information when Git cannot grab correct values
|
||||
const _providerCommitParams = function () {
|
||||
const _providerCommitParams = () => {
|
||||
const { env } = process
|
||||
|
||||
return {
|
||||
@@ -500,11 +500,11 @@ const _providerCommitParams = function () {
|
||||
}
|
||||
}
|
||||
|
||||
const provider = function () {
|
||||
const provider = () => {
|
||||
return _detectProviderName() || null
|
||||
}
|
||||
|
||||
const omitUndefined = function (ret) {
|
||||
const omitUndefined = (ret) => {
|
||||
if (_.isObject(ret)) {
|
||||
return _.omitBy(ret, _.isUndefined)
|
||||
}
|
||||
@@ -527,7 +527,7 @@ const commitParams = () => {
|
||||
return _get(_providerCommitParams)
|
||||
}
|
||||
|
||||
const commitDefaults = function (existingInfo) {
|
||||
const commitDefaults = (existingInfo) => {
|
||||
debug('git commit existing info')
|
||||
debug(existingInfo)
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ const isValue = (value) => {
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = function (value) {
|
||||
module.exports = (value) => {
|
||||
const num = _.toNumber(value)
|
||||
const bool = toBoolean(value)
|
||||
|
||||
|
||||
@@ -93,10 +93,10 @@ class File {
|
||||
}
|
||||
|
||||
_getContents () {
|
||||
//# read from disk on first call, but resolve cache for any subsequent
|
||||
//# calls within the DEBOUNCE_LIMIT
|
||||
//# once the DEBOUNCE_LIMIT passes, read from disk again
|
||||
//# on the next call
|
||||
// read from disk on first call, but resolve cache for any subsequent
|
||||
// calls within the DEBOUNCE_LIMIT
|
||||
// once the DEBOUNCE_LIMIT passes, read from disk again
|
||||
// on the next call
|
||||
if ((Date.now() - this._lastRead) > DEBOUNCE_LIMIT) {
|
||||
this._lastRead = Date.now()
|
||||
|
||||
@@ -117,11 +117,11 @@ class File {
|
||||
return fs.readJsonAsync(this.path, 'utf8')
|
||||
})
|
||||
.catch((err) => {
|
||||
//# default to {} in certain cases, otherwise bubble up error
|
||||
// default to {} in certain cases, otherwise bubble up error
|
||||
if (
|
||||
(err.code === 'ENOENT') || //# file doesn't exist
|
||||
(err.code === 'EEXIST') || //# file contains invalid JSON
|
||||
(err.name === 'SyntaxError') //# can't get lock on file
|
||||
(err.code === 'ENOENT') || // file doesn't exist
|
||||
(err.code === 'EEXIST') || // file contains invalid JSON
|
||||
(err.name === 'SyntaxError') // can't get lock on file
|
||||
) {
|
||||
return {}
|
||||
}
|
||||
@@ -142,17 +142,15 @@ class File {
|
||||
throw new TypeError(`Expected \`key\` to be of type \`string\` or \`object\`, got \`${type}\``)
|
||||
}
|
||||
|
||||
const valueObject = (() => {
|
||||
if (_.isString(key)) {
|
||||
const tmp = {}
|
||||
let valueObject = key
|
||||
|
||||
tmp[key] = value
|
||||
if (_.isString(key)) {
|
||||
const tmp = {}
|
||||
|
||||
return tmp
|
||||
}
|
||||
tmp[key] = value
|
||||
|
||||
return key
|
||||
})()
|
||||
valueObject = tmp
|
||||
}
|
||||
|
||||
if (inTransaction) {
|
||||
return this._setContents(valueObject)
|
||||
@@ -177,7 +175,7 @@ class File {
|
||||
}
|
||||
|
||||
_addToQueue (operation) {
|
||||
//# queues operations so they occur serially as invoked
|
||||
// queues operations so they occur serially as invoked
|
||||
return Promise.try(() => {
|
||||
return this._queue.add(operation)
|
||||
})
|
||||
@@ -203,7 +201,7 @@ class File {
|
||||
return fs
|
||||
.ensureDirAsync(this._lockFileDir)
|
||||
.then(() => {
|
||||
//# polls every 100ms up to 2000ms to obtain lock, otherwise rejects
|
||||
// polls every 100ms up to 2000ms to obtain lock, otherwise rejects
|
||||
return lockFile.lockAsync(this._lockFilePath, { wait: LOCK_TIMEOUT })
|
||||
})
|
||||
.finally(() => {
|
||||
@@ -217,7 +215,7 @@ class File {
|
||||
return lockFile
|
||||
.unlockAsync(this._lockFilePath)
|
||||
.timeout(env.get('FILE_UNLOCK_TIMEOUT') || LOCK_TIMEOUT)
|
||||
.catch(Promise.TimeoutError, () => {}) //# ignore timeouts
|
||||
.catch(Promise.TimeoutError, () => {}) // ignore timeouts
|
||||
.finally(() => {
|
||||
return debug('unlock succeeded or failed for %s', this.path)
|
||||
})
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
const fs = require('fs-extra')
|
||||
const Promise = require('bluebird')
|
||||
|
||||
//# warn users if somehow synchronous file methods are invoked
|
||||
//# these methods due to "too many files" errors are a huge pain
|
||||
// warn users if somehow synchronous file methods are invoked
|
||||
// these methods due to "too many files" errors are a huge pain
|
||||
const warnOnSyncFileSystem = () => {
|
||||
console.error('WARNING: fs sync methods can fail due to EMFILE errors')
|
||||
console.error('Cypress only works reliably when ALL fs calls are async')
|
||||
|
||||
@@ -1,13 +1,9 @@
|
||||
const moment = require('moment')
|
||||
|
||||
const parse = function (ms) {
|
||||
let mins = 0
|
||||
|
||||
const parse = (ms) => {
|
||||
const duration = moment.duration(ms)
|
||||
|
||||
const hours = duration.hours()
|
||||
|
||||
mins = hours * 60
|
||||
let mins = hours * 60
|
||||
|
||||
return {
|
||||
mins,
|
||||
@@ -16,12 +12,11 @@ const parse = function (ms) {
|
||||
}
|
||||
}
|
||||
|
||||
const long = function (ms, alwaysIncludeSeconds = true) {
|
||||
const long = (ms, alwaysIncludeSeconds = true) => {
|
||||
let { mins, duration } = parse(ms)
|
||||
let word
|
||||
const msg = []
|
||||
|
||||
let { mins, duration } = parse(ms)
|
||||
|
||||
mins += duration.minutes()
|
||||
|
||||
if (mins) {
|
||||
@@ -39,10 +34,9 @@ const long = function (ms, alwaysIncludeSeconds = true) {
|
||||
return msg.join(', ')
|
||||
}
|
||||
|
||||
const short = function (ms) {
|
||||
const msg = []
|
||||
|
||||
const short = (ms) => {
|
||||
let { mins, duration } = parse(ms)
|
||||
const msg = []
|
||||
|
||||
mins += duration.minutes()
|
||||
|
||||
|
||||
@@ -1,11 +1,4 @@
|
||||
// TODO: This file was created by bulk-decaffeinate.
|
||||
// Sanity-check the conversion and remove this comment.
|
||||
/*
|
||||
* decaffeinate suggestions:
|
||||
* DS102: Remove unnecessary code created because of implicit returns
|
||||
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
|
||||
*/
|
||||
//# wrapper around opn due to issues with proxyquire + istanbul
|
||||
// wrapper around opn due to issues with proxyquire + istanbul
|
||||
const os = require('os')
|
||||
const opn = require('opn')
|
||||
|
||||
|
||||
@@ -1,19 +1,7 @@
|
||||
/* eslint-disable
|
||||
no-unused-vars,
|
||||
*/
|
||||
// TODO: This file was created by bulk-decaffeinate.
|
||||
// Fix any style issues and re-enable lint.
|
||||
/*
|
||||
* decaffeinate suggestions:
|
||||
* DS102: Remove unnecessary code created because of implicit returns
|
||||
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
|
||||
*/
|
||||
const path = require('path')
|
||||
const Promise = require('bluebird')
|
||||
const fs = require('./fs')
|
||||
|
||||
const isIntegrationTestRe = /^integration/
|
||||
const isUnitTestRe = /^unit/
|
||||
|
||||
// require.resolve walks the symlinks, which can really change
|
||||
// the results. For example
|
||||
@@ -36,7 +24,7 @@ const checkIfResolveChangedRootFolder = (resolved, initial) => {
|
||||
|
||||
// real folder path found could be different due to symlinks
|
||||
// For example, folder /tmp/foo on Mac is really /private/tmp/foo
|
||||
const getRealFolderPath = function (folder) {
|
||||
const getRealFolderPath = (folder) => {
|
||||
// TODO check if folder is a non-empty string
|
||||
if (!folder) {
|
||||
throw new Error('Expected folder')
|
||||
@@ -45,13 +33,13 @@ const getRealFolderPath = function (folder) {
|
||||
return fs.realpathAsync(folder)
|
||||
}
|
||||
|
||||
const getRelativePathToSpec = function (spec) {
|
||||
const getRelativePathToSpec = (spec) => {
|
||||
switch (false) {
|
||||
//# if our file is an integration test
|
||||
//# then figure out the absolute path
|
||||
//# to it
|
||||
// if our file is an integration test
|
||||
// then figure out the absolute path
|
||||
// to it
|
||||
case !isIntegrationTestRe.test(spec):
|
||||
//# strip off the integration part
|
||||
// strip off the integration part
|
||||
return path.relative('integration', spec)
|
||||
default:
|
||||
return spec
|
||||
@@ -67,24 +55,24 @@ module.exports = {
|
||||
|
||||
getAbsolutePathToSpec (spec, config) {
|
||||
switch (false) {
|
||||
//# if our file is an integration test
|
||||
//# then figure out the absolute path
|
||||
//# to it
|
||||
// if our file is an integration test
|
||||
// then figure out the absolute path
|
||||
// to it
|
||||
case !isIntegrationTestRe.test(spec):
|
||||
spec = getRelativePathToSpec(spec)
|
||||
|
||||
//# now simply join this with our integrationFolder
|
||||
//# which makes it an absolute path
|
||||
// now simply join this with our integrationFolder
|
||||
// which makes it an absolute path
|
||||
return path.join(config.integrationFolder, spec)
|
||||
|
||||
// ## commented out until we implement unit testing
|
||||
// // commented out until we implement unit testing
|
||||
// when isUnitTestRe.test(spec)
|
||||
|
||||
//# strip off the unit part
|
||||
// // strip off the unit part
|
||||
// spec = path.relative("unit", spec)
|
||||
|
||||
// ## now simply resolve this with our unitFolder
|
||||
// ## which makes it an absolute path
|
||||
// // now simply resolve this with our unitFolder
|
||||
// // which makes it an absolute path
|
||||
// path.join(config.unitFolder, spec)
|
||||
|
||||
default:
|
||||
|
||||
@@ -1,18 +1,7 @@
|
||||
/* eslint-disable
|
||||
brace-style,
|
||||
*/
|
||||
// TODO: This file was created by bulk-decaffeinate.
|
||||
// Fix any style issues and re-enable lint.
|
||||
/*
|
||||
* decaffeinate suggestions:
|
||||
* DS102: Remove unnecessary code created because of implicit returns
|
||||
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
|
||||
*/
|
||||
const random = require('randomstring')
|
||||
|
||||
const id = (length = 5) =>
|
||||
//# return a random id
|
||||
{
|
||||
// return a random id
|
||||
const id = (length = 5) => {
|
||||
return random.generate({
|
||||
length,
|
||||
capitalization: 'lowercase',
|
||||
|
||||
@@ -1,13 +1,3 @@
|
||||
/* eslint-disable
|
||||
default-case,
|
||||
*/
|
||||
// TODO: This file was created by bulk-decaffeinate.
|
||||
// Fix any style issues and re-enable lint.
|
||||
/*
|
||||
* decaffeinate suggestions:
|
||||
* DS102: Remove unnecessary code created because of implicit returns
|
||||
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
|
||||
*/
|
||||
const _ = require('lodash')
|
||||
const UrlParse = require('url-parse')
|
||||
const konfig = require('../konfig')
|
||||
@@ -35,12 +25,16 @@ let routes = {
|
||||
|
||||
const parseArgs = function (url, args = []) {
|
||||
_.each(args, (value) => {
|
||||
switch (false) {
|
||||
case !_.isObject(value):
|
||||
return url.set('query', _.extend(url.query, value))
|
||||
if (_.isObject(value)) {
|
||||
url.set('query', _.extend(url.query, value))
|
||||
|
||||
case !_.isString(value) && !_.isNumber(value):
|
||||
return url.set('pathname', url.pathname.replace(':id', value))
|
||||
return
|
||||
}
|
||||
|
||||
if (_.isString(value) || _.isNumber(value)) {
|
||||
url.set('pathname', url.pathname.replace(':id', value))
|
||||
|
||||
return
|
||||
}
|
||||
})
|
||||
|
||||
@@ -63,7 +57,6 @@ routes = _.reduce(routes, (memo, value, key) => {
|
||||
}
|
||||
|
||||
return memo
|
||||
}
|
||||
, {})
|
||||
}, {})
|
||||
|
||||
module.exports = routes
|
||||
|
||||
@@ -1,10 +1,3 @@
|
||||
// TODO: This file was created by bulk-decaffeinate.
|
||||
// Sanity-check the conversion and remove this comment.
|
||||
/*
|
||||
* decaffeinate suggestions:
|
||||
* DS102: Remove unnecessary code created because of implicit returns
|
||||
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
|
||||
*/
|
||||
const md5 = require('md5')
|
||||
const path = require('path')
|
||||
const debug = require('debug')('cypress:server:saved_state')
|
||||
@@ -13,7 +6,7 @@ const sanitize = require('sanitize-filename')
|
||||
const cwd = require('../cwd')
|
||||
const fs = require('../util/fs')
|
||||
|
||||
const toHashName = function (projectRoot) {
|
||||
const toHashName = (projectRoot) => {
|
||||
if (!projectRoot) {
|
||||
throw new Error('Missing project path')
|
||||
}
|
||||
|
||||
@@ -6,7 +6,6 @@ module.exports = function (server) {
|
||||
|
||||
server.destroyAsync = () => {
|
||||
return Promise.promisify(server.destroy)()
|
||||
.catch(() => {})
|
||||
.catch(() => {}) // dont catch any errors
|
||||
}
|
||||
}
|
||||
// dont catch any errors
|
||||
|
||||
@@ -1,15 +1,3 @@
|
||||
/* eslint-disable
|
||||
brace-style,
|
||||
no-cond-assign,
|
||||
no-unused-vars,
|
||||
*/
|
||||
// TODO: This file was created by bulk-decaffeinate.
|
||||
// Fix any style issues and re-enable lint.
|
||||
/*
|
||||
* decaffeinate suggestions:
|
||||
* DS102: Remove unnecessary code created because of implicit returns
|
||||
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
|
||||
*/
|
||||
const _ = require('lodash')
|
||||
const Promise = require('bluebird')
|
||||
const path = require('path')
|
||||
@@ -17,18 +5,14 @@ const errors = require('../errors')
|
||||
const log = require('../log')
|
||||
const fs = require('../util/fs')
|
||||
|
||||
//# TODO:
|
||||
//# think about adding another PSemaphore
|
||||
//# here since we can read + write the
|
||||
//# settings at the same time something else
|
||||
//# is potentially reading it
|
||||
// TODO:
|
||||
// think about adding another PSemaphore
|
||||
// here since we can read + write the
|
||||
// settings at the same time something else
|
||||
// is potentially reading it
|
||||
|
||||
const flattenCypress = function (obj) {
|
||||
let cypress
|
||||
|
||||
if (cypress = obj.cypress) {
|
||||
return cypress
|
||||
}
|
||||
const flattenCypress = (obj) => {
|
||||
return obj.cypress ? obj.cypress : undefined
|
||||
}
|
||||
|
||||
const maybeVerifyConfigFile = Promise.method((configFile) => {
|
||||
@@ -39,10 +23,10 @@ const maybeVerifyConfigFile = Promise.method((configFile) => {
|
||||
return fs.statAsync(configFile)
|
||||
})
|
||||
|
||||
const renameVisitToPageLoad = function (obj) {
|
||||
let v
|
||||
const renameVisitToPageLoad = (obj) => {
|
||||
const v = obj.visitTimeout
|
||||
|
||||
if (v = obj.visitTimeout) {
|
||||
if (v) {
|
||||
obj = _.omit(obj, 'visitTimeout')
|
||||
obj.pageLoadTimeout = v
|
||||
|
||||
@@ -50,10 +34,10 @@ const renameVisitToPageLoad = function (obj) {
|
||||
}
|
||||
}
|
||||
|
||||
const renameCommandTimeout = function (obj) {
|
||||
let c
|
||||
const renameCommandTimeout = (obj) => {
|
||||
const c = obj.commandTimeout
|
||||
|
||||
if (c = obj.commandTimeout) {
|
||||
if (c) {
|
||||
obj = _.omit(obj, 'commandTimeout')
|
||||
obj.defaultCommandTimeout = c
|
||||
|
||||
@@ -61,10 +45,10 @@ const renameCommandTimeout = function (obj) {
|
||||
}
|
||||
}
|
||||
|
||||
const renameSupportFolder = function (obj) {
|
||||
let sf
|
||||
const renameSupportFolder = (obj) => {
|
||||
const sf = obj.supportFolder
|
||||
|
||||
if (sf = obj.supportFolder) {
|
||||
if (sf) {
|
||||
obj = _.omit(obj, 'supportFolder')
|
||||
obj.supportFile = sf
|
||||
|
||||
@@ -103,15 +87,10 @@ module.exports = {
|
||||
|
||||
_applyRewriteRules (obj = {}) {
|
||||
return _.reduce([flattenCypress, renameVisitToPageLoad, renameCommandTimeout, renameSupportFolder], (memo, fn) => {
|
||||
let ret
|
||||
const ret = fn(memo)
|
||||
|
||||
if (ret = fn(memo)) {
|
||||
return ret
|
||||
}
|
||||
|
||||
return memo
|
||||
}
|
||||
, _.cloneDeep(obj))
|
||||
return ret ? ret : memo
|
||||
}, _.cloneDeep(obj))
|
||||
},
|
||||
|
||||
configFile (options = {}) {
|
||||
@@ -133,12 +112,11 @@ module.exports = {
|
||||
|
||||
// first check if cypress.json exists
|
||||
return maybeVerifyConfigFile(file)
|
||||
.then(() =>
|
||||
// if it does also check that the projectRoot
|
||||
// directory is writable
|
||||
{
|
||||
.then(() => {
|
||||
// if it does also check that the projectRoot
|
||||
// directory is writable
|
||||
return fs.accessAsync(projectRoot, fs.W_OK)
|
||||
}).catch({ code: 'ENOENT' }, (err) => {
|
||||
}).catch({ code: 'ENOENT' }, () => {
|
||||
// cypress.json does not exist, we missing project
|
||||
log('cannot find file %s', file)
|
||||
|
||||
@@ -166,13 +144,13 @@ module.exports = {
|
||||
}).then((json = {}) => {
|
||||
const changed = this._applyRewriteRules(json)
|
||||
|
||||
//# if our object is unchanged
|
||||
//# then just return it
|
||||
// if our object is unchanged
|
||||
// then just return it
|
||||
if (_.isEqual(json, changed)) {
|
||||
return json
|
||||
}
|
||||
|
||||
//# else write the new reduced obj
|
||||
// else write the new reduced obj
|
||||
return this._write(file, changed)
|
||||
}).catch((err) => {
|
||||
if (errors.isCypressErr(err)) {
|
||||
|
||||
@@ -1,14 +1,3 @@
|
||||
/* eslint-disable
|
||||
no-cond-assign,
|
||||
no-dupe-keys,
|
||||
*/
|
||||
// TODO: This file was created by bulk-decaffeinate.
|
||||
// Fix any style issues and re-enable lint.
|
||||
/*
|
||||
* decaffeinate suggestions:
|
||||
* DS102: Remove unnecessary code created because of implicit returns
|
||||
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
|
||||
*/
|
||||
const Promise = require('bluebird')
|
||||
const execa = require('execa')
|
||||
const R = require('ramda')
|
||||
@@ -20,21 +9,20 @@ const isWindows = () => {
|
||||
}
|
||||
|
||||
const profiles = {
|
||||
'~/.profile': /\/sh$/,
|
||||
'~/.profile': /\/k?sh$/,
|
||||
'~/.bash_profile': /\/bash$/,
|
||||
'~/.cshrc': /\/csh$/,
|
||||
'~/.profile': /\/ksh$/,
|
||||
'~/.zshrc': /\/zsh$/,
|
||||
'~/.config/fish/config.fish': /\/fish$/,
|
||||
}
|
||||
|
||||
let sourcedProfiles = []
|
||||
|
||||
//# returns true if Cypress application has been started from
|
||||
//# the terminal shell.
|
||||
//# returns false if Cypress application has been started
|
||||
//# from the Finder / Windows Explorer list
|
||||
//# by double clicking its icon
|
||||
// returns true if Cypress application has been started from
|
||||
// the terminal shell.
|
||||
// returns false if Cypress application has been started
|
||||
// from the Finder / Windows Explorer list
|
||||
// by double clicking its icon
|
||||
const startedNormally = () => {
|
||||
return Boolean(process.env._)
|
||||
}
|
||||
@@ -66,16 +54,16 @@ const sourceShellCommand = function (cmd, shell) {
|
||||
const haveShell = startedNormally()
|
||||
|
||||
if (haveShell) {
|
||||
//# we only need to source once
|
||||
//# IF THE APP HAS NOT BEEN STARTED BY
|
||||
//# DOUBLE CLICKING IT FROM FINDER / WINDOWS EXPLORER
|
||||
//# OTHERWISE NEED TO SOURCE EVERY COMMAND
|
||||
// we only need to source once
|
||||
// IF THE APP HAS NOT BEEN STARTED BY
|
||||
// DOUBLE CLICKING IT FROM FINDER / WINDOWS EXPLORER
|
||||
// OTHERWISE NEED TO SOURCE EVERY COMMAND
|
||||
sourcedProfiles.push(profilePath)
|
||||
}
|
||||
|
||||
//# sourcing the profile can output un-needed garbage,
|
||||
//# so suppress it by sending it to /dev/null and ignore
|
||||
//# any failures with this
|
||||
// sourcing the profile can output un-needed garbage,
|
||||
// so suppress it by sending it to /dev/null and ignore
|
||||
// any failures with this
|
||||
return `source ${profilePath} > /dev/null 2>&1; ${cmd}`
|
||||
}
|
||||
|
||||
@@ -85,15 +73,15 @@ const findBash = () => {
|
||||
}
|
||||
|
||||
const getShell = function (shell) {
|
||||
let s
|
||||
|
||||
if (shell) {
|
||||
return Promise.resolve(shell)
|
||||
}
|
||||
|
||||
//# if we didn't get a shell such
|
||||
//# as when we're in docker
|
||||
if (s = process.env.SHELL) {
|
||||
// if we didn't get a shell such
|
||||
// as when we're in docker
|
||||
let s = process.env.SHELL
|
||||
|
||||
if (s) {
|
||||
return Promise.resolve(s)
|
||||
}
|
||||
|
||||
|
||||
@@ -1,13 +1,3 @@
|
||||
/* eslint-disable
|
||||
brace-style,
|
||||
*/
|
||||
// TODO: This file was created by bulk-decaffeinate.
|
||||
// Fix any style issues and re-enable lint.
|
||||
/*
|
||||
* decaffeinate suggestions:
|
||||
* DS102: Remove unnecessary code created because of implicit returns
|
||||
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
|
||||
*/
|
||||
const _ = require('lodash')
|
||||
const la = require('lazy-ass')
|
||||
const path = require('path')
|
||||
@@ -46,10 +36,10 @@ const find = function findSpecs (config, specPattern) {
|
||||
debug('there is no spec pattern')
|
||||
}
|
||||
|
||||
//# support files are not automatically
|
||||
//# ignored because only _fixtures are hard
|
||||
//# coded. the rest is simply whatever is in
|
||||
//# the javascripts array
|
||||
// support files are not automatically
|
||||
// ignored because only _fixtures are hard
|
||||
// coded. the rest is simply whatever is in
|
||||
// the javascripts array
|
||||
|
||||
if (config.fixturesFolder) {
|
||||
fixturesFolderPath = path.join(
|
||||
@@ -61,15 +51,15 @@ const find = function findSpecs (config, specPattern) {
|
||||
|
||||
const supportFilePath = config.supportFile || []
|
||||
|
||||
//# map all of the javascripts to the project root
|
||||
//# TODO: think about moving this into config
|
||||
//# and mapping each of the javascripts into an
|
||||
//# absolute path
|
||||
// map all of the javascripts to the project root
|
||||
// TODO: think about moving this into config
|
||||
// and mapping each of the javascripts into an
|
||||
// absolute path
|
||||
const javascriptsPaths = _.map(config.javascripts, (js) => {
|
||||
return path.join(config.projectRoot, js)
|
||||
})
|
||||
|
||||
//# ignore fixtures + javascripts
|
||||
// ignore fixtures + javascripts
|
||||
const options = {
|
||||
sort: true,
|
||||
absolute: true,
|
||||
@@ -82,10 +72,10 @@ const find = function findSpecs (config, specPattern) {
|
||||
])),
|
||||
}
|
||||
|
||||
//# filePath = /Users/bmann/Dev/my-project/cypress/integration/foo.coffee
|
||||
//# integrationFolderPath = /Users/bmann/Dev/my-project/cypress/integration
|
||||
//# relativePathFromIntegrationFolder = foo.coffee
|
||||
//# relativePathFromProjectRoot = cypress/integration/foo.coffee
|
||||
// filePath = /Users/bmann/Dev/my-project/cypress/integration/foo.coffee
|
||||
// integrationFolderPath = /Users/bmann/Dev/my-project/cypress/integration
|
||||
// relativePathFromIntegrationFolder = foo.coffee
|
||||
// relativePathFromProjectRoot = cypress/integration/foo.coffee
|
||||
|
||||
const relativePathFromIntegrationFolder = (file) => {
|
||||
return path.relative(integrationFolderPath, file)
|
||||
@@ -95,7 +85,7 @@ const find = function findSpecs (config, specPattern) {
|
||||
return path.relative(config.projectRoot, file)
|
||||
}
|
||||
|
||||
const setNameParts = function (file) {
|
||||
const setNameParts = (file) => {
|
||||
debug('found spec file %s', file)
|
||||
|
||||
if (!path.isAbsolute(file)) {
|
||||
@@ -111,20 +101,19 @@ const find = function findSpecs (config, specPattern) {
|
||||
|
||||
const ignorePatterns = [].concat(config.ignoreTestFiles)
|
||||
|
||||
//# a function which returns true if the file does NOT match
|
||||
//# all of our ignored patterns
|
||||
const doesNotMatchAllIgnoredPatterns = (file) =>
|
||||
//# using {dot: true} here so that folders with a '.' in them are matched
|
||||
//# as regular characters without needing an '.' in the
|
||||
//# using {matchBase: true} here so that patterns without a globstar **
|
||||
//# match against the basename of the file
|
||||
{
|
||||
// a function which returns true if the file does NOT match
|
||||
// all of our ignored patterns
|
||||
const doesNotMatchAllIgnoredPatterns = (file) => {
|
||||
// using {dot: true} here so that folders with a '.' in them are matched
|
||||
// as regular characters without needing an '.' in the
|
||||
// using {matchBase: true} here so that patterns without a globstar **
|
||||
// match against the basename of the file
|
||||
return _.every(ignorePatterns, (pattern) => {
|
||||
return !minimatch(file, pattern, MINIMATCH_OPTIONS)
|
||||
})
|
||||
}
|
||||
|
||||
const matchesSpecPattern = function (file) {
|
||||
const matchesSpecPattern = (file) => {
|
||||
if (!specPattern) {
|
||||
return true
|
||||
}
|
||||
@@ -133,8 +122,8 @@ const find = function findSpecs (config, specPattern) {
|
||||
return minimatch(file, pattern, MINIMATCH_OPTIONS)
|
||||
}
|
||||
|
||||
//# check to see if the file matches
|
||||
//# any of the spec patterns array
|
||||
// check to see if the file matches
|
||||
// any of the spec patterns array
|
||||
return _
|
||||
.chain([])
|
||||
.concat(specPattern)
|
||||
|
||||
@@ -1,10 +1,3 @@
|
||||
// TODO: This file was created by bulk-decaffeinate.
|
||||
// Sanity-check the conversion and remove this comment.
|
||||
/*
|
||||
* decaffeinate suggestions:
|
||||
* DS102: Remove unnecessary code created because of implicit returns
|
||||
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
|
||||
*/
|
||||
const statuses = require('http-status-codes')
|
||||
|
||||
const isOkStatusCodeRe = /^[2|3]\d+$/
|
||||
@@ -14,7 +7,7 @@ module.exports = {
|
||||
return code && isOkStatusCodeRe.test(code)
|
||||
},
|
||||
|
||||
//# TODO: test this method
|
||||
// TODO: test this method
|
||||
getText (code) {
|
||||
try {
|
||||
return statuses.getStatusText(code)
|
||||
|
||||
@@ -63,7 +63,7 @@ function streamBuffer (initialSize = 2048) {
|
||||
let bytesRead = 0
|
||||
const readerId = _.uniqueId('reader')
|
||||
|
||||
const onRead = function (size) {
|
||||
const onRead = (size) => {
|
||||
if (!buffer) {
|
||||
debug('read requested after unpipeAll, ignoring %o', { size })
|
||||
|
||||
|
||||
@@ -1,13 +1,3 @@
|
||||
/* eslint-disable
|
||||
no-unused-vars,
|
||||
*/
|
||||
// TODO: This file was created by bulk-decaffeinate.
|
||||
// Fix any style issues and re-enable lint.
|
||||
/*
|
||||
* decaffeinate suggestions:
|
||||
* DS102: Remove unnecessary code created because of implicit returns
|
||||
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
|
||||
*/
|
||||
const os = require('os')
|
||||
const Promise = require('bluebird')
|
||||
const getos = Promise.promisify(require('getos'))
|
||||
@@ -18,7 +8,7 @@ const getOsVersion = () => {
|
||||
return getos()
|
||||
.then((obj) => {
|
||||
return [obj.dist, obj.release].join(' - ')
|
||||
}).catch((err) => {
|
||||
}).catch(() => {
|
||||
return os.release()
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
/* eslint-disable no-console */
|
||||
const _ = require('lodash')
|
||||
const chalk = require('chalk')
|
||||
const Table = require('cli-table3')
|
||||
@@ -33,7 +32,7 @@ const renderTables = (...tables) => {
|
||||
.value()
|
||||
}
|
||||
|
||||
const getChars = function (type) {
|
||||
const getChars = (type) => {
|
||||
switch (type) {
|
||||
case 'border':
|
||||
return {
|
||||
@@ -131,7 +130,7 @@ const wrapBordersInGray = (chars) => {
|
||||
})
|
||||
}
|
||||
|
||||
const table = function (options = {}) {
|
||||
const table = (options = {}) => {
|
||||
const { type } = options
|
||||
const defaults = utils.mergeOptions({})
|
||||
|
||||
@@ -146,9 +145,9 @@ const table = function (options = {}) {
|
||||
'padding-left': 1,
|
||||
'padding-right': 1,
|
||||
},
|
||||
});
|
||||
})
|
||||
|
||||
({ chars } = options)
|
||||
chars = options.chars
|
||||
|
||||
if (colWidths) {
|
||||
const sum = _.sum(colWidths)
|
||||
@@ -178,7 +177,7 @@ const table = function (options = {}) {
|
||||
return new Table(options)
|
||||
}
|
||||
|
||||
const header = function (message, options = {}) {
|
||||
const header = (message, options = {}) => {
|
||||
_.defaults(options, {
|
||||
color: null,
|
||||
})
|
||||
@@ -190,18 +189,17 @@ const header = function (message, options = {}) {
|
||||
|
||||
message = _.reduce(colors, (memo, color) => {
|
||||
return chalk[color](memo)
|
||||
}
|
||||
, message)
|
||||
}, message)
|
||||
}
|
||||
|
||||
console.log(message)
|
||||
console.log(message) // eslint-disable-line no-console
|
||||
}
|
||||
|
||||
const divider = function (symbol, color = 'gray') {
|
||||
const divider = (symbol, color = 'gray') => {
|
||||
const cols = getMaximumColumns()
|
||||
const str = symbol.repeat(cols)
|
||||
|
||||
console.log(chalk[color](str))
|
||||
console.log(chalk[color](str)) // eslint-disable-line no-console
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
|
||||
@@ -1,23 +1,11 @@
|
||||
/* eslint-disable
|
||||
no-unused-vars,
|
||||
*/
|
||||
// TODO: This file was created by bulk-decaffeinate.
|
||||
// Fix any style issues and re-enable lint.
|
||||
/*
|
||||
* decaffeinate suggestions:
|
||||
* DS102: Remove unnecessary code created because of implicit returns
|
||||
* DS207: Consider shorter variations of null checks
|
||||
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
|
||||
*/
|
||||
const _ = require('lodash')
|
||||
const errors = require('../errors')
|
||||
const debug = require('debug')('cypress:server:validation')
|
||||
const is = require('check-more-types')
|
||||
const { commaListsOr } = require('common-tags')
|
||||
|
||||
// # validation functions take a key and a value and should:
|
||||
// # - return true if it passes validation
|
||||
// # - return a error message if it fails validation
|
||||
// validation functions take a key and a value and should:
|
||||
// - return true if it passes validation
|
||||
// - return a error message if it fails validation
|
||||
|
||||
const str = JSON.stringify
|
||||
|
||||
|
||||
Reference in New Issue
Block a user