mirror of
https://github.com/cypress-io/cypress.git
synced 2026-01-25 08:29:06 -06:00
95 lines
2.6 KiB
JavaScript
95 lines
2.6 KiB
JavaScript
require('../spec_helper')
|
|
|
|
const cli = require(`${lib}/cli`)
|
|
const util = require(`${lib}/util`)
|
|
const run = require(`${lib}/exec/run`)
|
|
const open = require(`${lib}/exec/open`)
|
|
const verify = require(`${lib}/tasks/verify`)
|
|
const install = require(`${lib}/tasks/install`)
|
|
|
|
describe('cli', function () {
|
|
beforeEach(function () {
|
|
this.sandbox.stub(process, 'exit')
|
|
this.sandbox.stub(util, 'exit')
|
|
this.sandbox.stub(util, 'logErrorExit1')
|
|
this.exec = (args) => cli.init().parse(`node test ${args}`.split(' '))
|
|
})
|
|
|
|
it('run calls run.start with options + exits with code', function (done) {
|
|
this.sandbox.stub(run, 'start').resolves(10)
|
|
this.exec('run --port 7878')
|
|
expect(run.start).to.be.calledWith({ port: '7878' })
|
|
|
|
util.exit.callsFake((code) => {
|
|
expect(code).to.eq(10)
|
|
done()
|
|
})
|
|
})
|
|
|
|
it('run calls run.start with options + catches errors', function (done) {
|
|
const err = new Error('foo')
|
|
this.sandbox.stub(run, 'start').rejects(err)
|
|
this.exec('run --port 7878')
|
|
expect(run.start).to.be.calledWith({ port: '7878' })
|
|
|
|
util.logErrorExit1.callsFake((e) => {
|
|
expect(e).to.eq(err)
|
|
done()
|
|
})
|
|
})
|
|
|
|
it('open calls open.start with options', function () {
|
|
this.sandbox.stub(open, 'start').resolves()
|
|
this.exec('open --port 7878')
|
|
expect(open.start).to.be.calledWith({ port: '7878' })
|
|
})
|
|
|
|
it('open calls open.start + catches errors', function (done) {
|
|
const err = new Error('foo')
|
|
|
|
this.sandbox.stub(open, 'start').rejects(err)
|
|
this.exec('open --port 7878')
|
|
|
|
util.logErrorExit1.callsFake((e) => {
|
|
expect(e).to.eq(err)
|
|
done()
|
|
})
|
|
})
|
|
|
|
it('install calls install.start with force: true', function () {
|
|
this.sandbox.stub(install, 'start').resolves()
|
|
this.exec('install')
|
|
expect(install.start).to.be.calledWith({ force: true })
|
|
})
|
|
|
|
it('install calls install.start + catches errors', function (done) {
|
|
const err = new Error('foo')
|
|
|
|
this.sandbox.stub(install, 'start').rejects(err)
|
|
this.exec('install')
|
|
|
|
util.logErrorExit1.callsFake((e) => {
|
|
expect(e).to.eq(err)
|
|
done()
|
|
})
|
|
})
|
|
|
|
it('verify calls verify.start with force: true', function () {
|
|
this.sandbox.stub(verify, 'start').resolves()
|
|
this.exec('verify')
|
|
expect(verify.start).to.be.calledWith({ force: true })
|
|
})
|
|
|
|
it('verify calls verify.start + catches errors', function (done) {
|
|
const err = new Error('foo')
|
|
|
|
this.sandbox.stub(verify, 'start').rejects(err)
|
|
this.exec('verify')
|
|
|
|
util.logErrorExit1.callsFake((e) => {
|
|
expect(e).to.eq(err)
|
|
done()
|
|
})
|
|
})
|
|
})
|