Merge remote-tracking branch 'origin/10.0-release' into UNIFY-1302-slowTestThreshold-by-testing-type

This commit is contained in:
BlueWinds
2022-03-15 15:42:50 -07:00
85 changed files with 1265 additions and 776 deletions
@@ -14,7 +14,7 @@ const pkg = require('@packages/root')
const detect = require('@packages/launcher/lib/detect')
const launch = require('@packages/launcher/lib/browsers')
const extension = require('@packages/extension')
const v = require('@packages/config/lib/validation')
const { validation: v } = require('@packages/config')
const argsUtil = require(`../../lib/util/args`)
const { fs } = require(`../../lib/util/fs`)
+11 -24
View File
@@ -517,26 +517,6 @@ describe('lib/config', () => {
})
})
context('pluginsFile', () => {
it('passes if a string', function () {
this.setup({ pluginsFile: 'cypress/plugins' })
return this.expectValidationPasses()
})
it('passes if false', function () {
this.setup({ pluginsFile: false })
return this.expectValidationPasses()
})
it('fails if not a string or false', function () {
this.setup({ pluginsFile: 42 })
return this.expectValidationFails('be a string')
})
})
context('port', () => {
it('passes if a number', function () {
this.setup({ port: 10 })
@@ -1441,6 +1421,16 @@ describe('lib/config', () => {
expect(warning).to.be.calledWith('EXPERIMENTAL_RUN_EVENTS_REMOVED')
})
it('warns if experimentalStudio is passed', async function () {
const warning = sinon.spy(errors, 'warning')
await this.defaults('experimentalStudio', true, {
experimentalStudio: true,
})
expect(warning).to.be.calledWith('EXPERIMENTAL_STUDIO_REMOVED')
})
// @see https://github.com/cypress-io/cypress/pull/9185
it('warns if experimentalNetworkStubbing is passed', async function () {
const warning = sinon.spy(errors, 'warning')
@@ -1506,7 +1496,6 @@ describe('lib/config', () => {
modifyObstructiveCode: { value: true, from: 'default' },
numTestsKeptInMemory: { value: 50, from: 'default' },
pageLoadTimeout: { value: 60000, from: 'default' },
pluginsFile: { value: 'cypress/plugins', from: 'default' },
port: { value: 1234, from: 'cli' },
projectId: { value: null, from: 'default' },
redirectionLimit: { value: 20, from: 'default' },
@@ -1617,7 +1606,6 @@ describe('lib/config', () => {
modifyObstructiveCode: { value: true, from: 'default' },
numTestsKeptInMemory: { value: 50, from: 'default' },
pageLoadTimeout: { value: 60000, from: 'default' },
pluginsFile: { value: 'cypress/plugins', from: 'default' },
port: { value: 2020, from: 'config' },
projectId: { value: 'projectId123', from: 'env' },
redirectionLimit: { value: 20, from: 'default' },
@@ -1875,7 +1863,6 @@ describe('lib/config', () => {
const cfg = {
projectRoot: '/foo/bar',
pluginsFile: '/foo/bar/cypress/plugins/index.js',
browsers: [browser],
resolved: {
browsers: {
@@ -2218,7 +2205,7 @@ describe('lib/config', () => {
expect(config.setAbsolutePaths(obj)).to.deep.eq(obj)
})
return ['fileServerFolder', 'fixturesFolder', 'supportFile', 'pluginsFile'].forEach((folder) => {
return ['fileServerFolder', 'fixturesFolder', 'supportFile'].forEach((folder) => {
it(`converts relative ${folder} to absolute path`, () => {
const obj = {
projectRoot: '/_test-output/path/to/project',
@@ -216,7 +216,7 @@ describe.skip('lib/plugins/child/run_plugins', () => {
})
})
it('sends error if pluginsFile function rejects the promise', function (done) {
it('sends error if setupNodeEvents function rejects the promise', function (done) {
const err = new Error('foo')
const setupNodeEventsFn = sinon.stub().rejects(err)
+13 -13
View File
@@ -6,20 +6,20 @@ const task = require(`../../lib/task`)
describe('lib/task', () => {
beforeEach(function () {
this.pluginsFile = 'cypress/plugins'
this.configFilePath = 'cypress.config.js'
sinon.stub(plugins, 'execute').resolves('result')
return sinon.stub(plugins, 'has').returns(true)
})
it('executes the \'task\' plugin', function () {
return task.run(this.pluginsFile, { task: 'some:task', arg: 'some:arg', timeout: 1000 }).then(() => {
return task.run(this.configFilePath, { task: 'some:task', arg: 'some:arg', timeout: 1000 }).then(() => {
expect(plugins.execute).to.be.calledWith('task', 'some:task', 'some:arg')
})
})
it('resolves the result of the \'task\' plugin', function () {
return task.run(this.pluginsFile, { task: 'some:task', arg: 'some:arg', timeout: 1000 }).then((result) => {
return task.run(this.configFilePath, { task: 'some:task', arg: 'some:arg', timeout: 1000 }).then((result) => {
expect(result).to.equal('result')
})
})
@@ -27,8 +27,8 @@ describe('lib/task', () => {
it('throws if \'task\' event is not registered', function () {
plugins.has.returns(false)
return task.run(this.pluginsFile, { timeout: 1000 }).catch((err) => {
expect(err.message).to.equal(`The 'task' event has not been registered in the setupNodeEvents method. You must register it before using cy.task()\n\nFix this in your setupNodeEvents method here:\n${this.pluginsFile}`)
return task.run(this.configFilePath, { timeout: 1000 }).catch((err) => {
expect(err.message).to.equal(`The 'task' event has not been registered in the setupNodeEvents method. You must register it before using cy.task()\n\nFix this in your setupNodeEvents method here:\n${this.configFilePath}`)
})
})
@@ -36,8 +36,8 @@ describe('lib/task', () => {
plugins.execute.withArgs('task').resolves('__cypress_unhandled__')
plugins.execute.withArgs('_get:task:keys').resolves(['foo', 'bar'])
return task.run(this.pluginsFile, { task: 'some:task', arg: 'some:arg', timeout: 1000 }).catch((err) => {
expect(err.message).to.equal(`The task 'some:task' was not handled in the setupNodeEvents method. The following tasks are registered: foo, bar\n\nFix this in your setupNodeEvents method here:\n${this.pluginsFile}`)
return task.run(this.configFilePath, { task: 'some:task', arg: 'some:arg', timeout: 1000 }).catch((err) => {
expect(err.message).to.equal(`The task 'some:task' was not handled in the setupNodeEvents method. The following tasks are registered: foo, bar\n\nFix this in your setupNodeEvents method here:\n${this.configFilePath}`)
})
})
@@ -45,8 +45,8 @@ describe('lib/task', () => {
plugins.execute.withArgs('task').resolves(undefined)
plugins.execute.withArgs('_get:task:body').resolves('function () {}')
return task.run(this.pluginsFile, { task: 'some:task', arg: 'some:arg', timeout: 1000 }).catch((err) => {
expect(err.message).to.equal(`The task 'some:task' returned undefined. You must return a value, null, or a promise that resolves to a value or null to indicate that the task was handled.\n\nThe task handler was:\n\nfunction () {}\n\nFix this in your setupNodeEvents method here:\n${this.pluginsFile}`)
return task.run(this.configFilePath, { task: 'some:task', arg: 'some:arg', timeout: 1000 }).catch((err) => {
expect(err.message).to.equal(`The task 'some:task' returned undefined. You must return a value, null, or a promise that resolves to a value or null to indicate that the task was handled.\n\nThe task handler was:\n\nfunction () {}\n\nFix this in your setupNodeEvents method here:\n${this.configFilePath}`)
})
})
@@ -54,8 +54,8 @@ describe('lib/task', () => {
plugins.execute.withArgs('task').resolves(undefined)
plugins.execute.withArgs('_get:task:body').resolves('')
return task.run(this.pluginsFile, { task: 'some:task', arg: 'some:arg', timeout: 1000 }).catch((err) => {
expect(err.message).to.equal(`The task 'some:task' returned undefined. You must return a value, null, or a promise that resolves to a value or null to indicate that the task was handled.\n\nFix this in your setupNodeEvents method here:\n${this.pluginsFile}`)
return task.run(this.configFilePath, { task: 'some:task', arg: 'some:arg', timeout: 1000 }).catch((err) => {
expect(err.message).to.equal(`The task 'some:task' returned undefined. You must return a value, null, or a promise that resolves to a value or null to indicate that the task was handled.\n\nFix this in your setupNodeEvents method here:\n${this.configFilePath}`)
})
})
@@ -63,8 +63,8 @@ describe('lib/task', () => {
plugins.execute.withArgs('task').resolves(Promise.delay(250))
plugins.execute.withArgs('_get:task:body').resolves('function () {}')
return task.run(this.pluginsFile, { task: 'some:task', arg: 'some:arg', timeout: 10 }).catch((err) => {
expect(err.message).to.equal(`The task handler was:\n\nfunction () {}\n\nFix this in your setupNodeEvents method here:\n${this.pluginsFile}`)
return task.run(this.configFilePath, { task: 'some:task', arg: 'some:arg', timeout: 10 }).catch((err) => {
expect(err.message).to.equal(`The task handler was:\n\nfunction () {}\n\nFix this in your setupNodeEvents method here:\n${this.configFilePath}`)
})
})
})