Files
cypress/cli/test/lib/exec/open_spec.js
Zach Bloomquist 49f5b3e80c Introduce --config-file argument (#3246)
* 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
2019-09-27 10:25:07 -04:00

127 lines
3.5 KiB
JavaScript

require('../../spec_helper')
const verify = require(`${lib}/tasks/verify`)
const spawn = require(`${lib}/exec/spawn`)
const open = require(`${lib}/exec/open`)
const util = require(`${lib}/util`)
describe('exec open', function () {
context('.start', function () {
beforeEach(function () {
sinon.stub(util, 'isInstalledGlobally').returns(true)
sinon.stub(verify, 'start').resolves()
sinon.stub(spawn, 'start').resolves()
})
it('verifies download', function () {
return open.start()
.then(() => {
expect(verify.start).to.be.called
})
})
it('calls spawn with correct options', function () {
return open.start({ dev: true })
.then(() => {
expect(spawn.start).to.be.calledWith([], {
detached: false,
stdio: 'inherit',
dev: true,
})
})
})
it('spawns with port', function () {
return open.start({ port: '1234' })
.then(() => {
expect(spawn.start).to.be.calledWith(['--port', '1234'])
})
})
it('spawns with --env', function () {
return open.start({ env: 'host=http://localhost:1337,name=brian' })
.then(() => {
expect(spawn.start).to.be.calledWith(
['--env', 'host=http://localhost:1337,name=brian']
)
})
})
it('spawns with --config', function () {
return open.start({ config: 'watchForFileChanges=false,baseUrl=localhost' })
.then(() => {
expect(spawn.start).to.be.calledWith(
['--config', 'watchForFileChanges=false,baseUrl=localhost']
)
})
})
it('spawns with --config-file false', function () {
return open.start({ configFile: false })
.then(() => {
expect(spawn.start).to.be.calledWith(
['--config-file', false]
)
})
})
it('spawns with --config-file set', function () {
return open.start({ configFile: 'special-cypress.json' })
.then(() => {
expect(spawn.start).to.be.calledWith(
['--config-file', 'special-cypress.json']
)
})
})
it('spawns with cwd as --project if not installed globally', function () {
util.isInstalledGlobally.returns(false)
return open.start()
.then(() => {
expect(spawn.start).to.be.calledWith(
['--project', process.cwd()]
)
})
})
it('spawns without --project if not installed globally and passing --global option', function () {
util.isInstalledGlobally.returns(false)
return open.start({ global: true })
.then(() => {
expect(spawn.start).not.to.be.calledWith(
['--project', process.cwd()]
)
})
})
it('spawns with --project passed in as options even when not installed globally', function () {
util.isInstalledGlobally.returns(false)
return open.start({ project: '/path/to/project' })
.then(() => {
expect(spawn.start).to.be.calledWith(
['--project', '/path/to/project']
)
})
})
it('spawns with --project if specified and installed globally', function () {
return open.start({ project: '/path/to/project' })
.then(() => {
expect(spawn.start).to.be.calledWith(
['--project', '/path/to/project']
)
})
})
it('spawns without --project if not specified and installed globally', function () {
return open.start()
.then(() => {
expect(spawn.start).to.be.calledWith([])
})
})
})
})