mirror of
https://github.com/cypress-io/cypress.git
synced 2026-05-03 21:40:28 -05:00
49f5b3e80c
* cli, server: introduce --config-file argument * server: remove unused import * server: wip * server: consider --config-file in settings * server: pass options to settings.read from config * server: store options in Project class, pass to all settings calls * server: _initPlugins needs to accept options, for being called from server * server: accept optional external options in open * cli: update help snapshots * server: realizing now that these were written like this so they could be stubbed - removing some unnecessary usages of @options * cli: pass configFile when it's false * server: --config-file false and --config-file blah.json work * server: add unit tests for --config-file * server: pass configFile to desktop-gui * desktop-gui: display 'cypress.json' according to --config-file arg * desktop-gui: add integration tests for --config-file * cli: add tests for --config-file * PR changes * PR changes * cli: update snapshots * server: updating error messages * runner: update cypress.json mention * fixing name overlap * server: integration tests for --config-file * runner: update Header component tests * cli: fix snapshot * desktop-gui: fix test * driver: fixing error messages - not really any visibility to cli args from here so just static strings * server: update snapshots * server: update snapshots * cli: updating snapshot * driver: how did i miss this? * add skipped blank line to the snapshot * fix missing proxy require statement (was lost in merge of develop)...weird * add module API defs to types * module API tests * send better error when config file can't be found * fix dtslint test * update cli help to use 'configuration file' * update snapshot using 7.7.1 in place * fix failing config_spec * be.visible * show custom config file name in driver errors * add tests for non-default config file in driver error messages * single-quote config file name * 🙅 IIFEs 🙅 * 🤦 * fix failing test * fix failing test, cleanup * lint * delete duplicate coffee spec * Update run.js * Delete app_spec.js.mp4 * in open mode, only store projects to recents list if 'cypress.json' is the configFile discussion: https://git.io/JeGyF * feedback
152 lines
3.6 KiB
JavaScript
152 lines
3.6 KiB
JavaScript
require('../spec_helper')
|
|
|
|
const os = require('os')
|
|
const path = require('path')
|
|
const R = require('ramda')
|
|
const snapshot = require('../support/snapshot')
|
|
const Promise = require('bluebird')
|
|
const tmp = Promise.promisifyAll(require('tmp'))
|
|
const mockfs = require('mock-fs')
|
|
|
|
const fs = require(`${lib}/fs`)
|
|
const open = require(`${lib}/exec/open`)
|
|
const run = require(`${lib}/exec/run`)
|
|
const cypress = require(`${lib}/cypress`)
|
|
|
|
describe('cypress', function () {
|
|
beforeEach(function () {
|
|
mockfs({})
|
|
})
|
|
|
|
afterEach(() => {
|
|
mockfs.restore()
|
|
})
|
|
|
|
context('.open', function () {
|
|
beforeEach(function () {
|
|
sinon.stub(open, 'start').resolves()
|
|
})
|
|
|
|
const getCallArgs = R.path(['lastCall', 'args', 0])
|
|
const getStartArgs = () => {
|
|
expect(open.start).to.be.called
|
|
|
|
return getCallArgs(open.start)
|
|
}
|
|
|
|
it('calls open#start, passing in options', function () {
|
|
return cypress.open({ foo: 'foo' })
|
|
.then(getStartArgs)
|
|
.then((args) => {
|
|
expect(args.foo).to.equal('foo')
|
|
})
|
|
})
|
|
|
|
it('normalizes config object', () => {
|
|
const config = {
|
|
pageLoadTime: 10000,
|
|
watchForFileChanges: false,
|
|
}
|
|
|
|
return cypress.open({ config })
|
|
.then(getStartArgs)
|
|
.then((args) => {
|
|
expect(args).to.deep.eq({ config: JSON.stringify(config) })
|
|
})
|
|
})
|
|
|
|
it('passes configFile: false', () => {
|
|
const opts = {
|
|
configFile: false,
|
|
}
|
|
|
|
return cypress.open(opts)
|
|
.then(getStartArgs)
|
|
.then((args) => {
|
|
expect(args).to.deep.eq(opts)
|
|
})
|
|
})
|
|
})
|
|
|
|
context('.run', function () {
|
|
let outputPath
|
|
|
|
beforeEach(function () {
|
|
outputPath = path.join(os.tmpdir(), 'cypress/monorepo/cypress_spec/output.json')
|
|
sinon.stub(tmp, 'fileAsync').resolves(outputPath)
|
|
sinon.stub(run, 'start').resolves()
|
|
|
|
return fs.outputJsonAsync(outputPath, {
|
|
code: 0,
|
|
failingTests: [],
|
|
})
|
|
})
|
|
|
|
const getCallArgs = R.path(['lastCall', 'args', 0])
|
|
const normalizeCallArgs = (args) => {
|
|
expect(args.outputPath).to.equal(outputPath)
|
|
delete args.outputPath
|
|
|
|
return args
|
|
}
|
|
const getStartArgs = () => {
|
|
expect(run.start).to.be.called
|
|
|
|
return normalizeCallArgs(getCallArgs(run.start))
|
|
}
|
|
|
|
it('calls run#start, passing in options', () => {
|
|
return cypress.run({ spec: 'foo' })
|
|
.then(getStartArgs)
|
|
.then((args) => {
|
|
expect(args.spec).to.equal('foo')
|
|
})
|
|
})
|
|
|
|
it('normalizes config object', () => {
|
|
const config = {
|
|
pageLoadTime: 10000,
|
|
watchForFileChanges: false,
|
|
}
|
|
|
|
return cypress.run({ config })
|
|
.then(getStartArgs)
|
|
.then((args) => {
|
|
expect(args).to.deep.eq({ config: JSON.stringify(config) })
|
|
})
|
|
})
|
|
|
|
it('normalizes env option if passed an object', () => {
|
|
const env = { foo: 'bar', another: 'one' }
|
|
|
|
return cypress.run({ env })
|
|
.then(getStartArgs)
|
|
.then((args) => {
|
|
expect(args).to.deep.eq({ env: JSON.stringify(env) })
|
|
})
|
|
})
|
|
|
|
it('gets random tmp file and passes it to run#start', function () {
|
|
return cypress.run().then(() => {
|
|
expect(run.start.lastCall.args[0].outputPath).to.equal(outputPath)
|
|
})
|
|
})
|
|
|
|
it('resolves with contents of tmp file', () => {
|
|
return cypress.run().then(snapshot)
|
|
})
|
|
|
|
it('passes configFile: false', () => {
|
|
const opts = {
|
|
configFile: false,
|
|
}
|
|
|
|
return cypress.run(opts)
|
|
.then(getStartArgs)
|
|
.then((args) => {
|
|
expect(args).to.deep.eq(opts)
|
|
})
|
|
})
|
|
})
|
|
})
|