mirror of
https://github.com/cypress-io/cypress.git
synced 2025-12-30 11:09:49 -06:00
* migrate cli scripts to TypeScript * convert all javascript source files in the CLI to TypeScript rebase into first * chore: refactor all tests to TypeScript rebase into second * add npmignore for cli for typescript files * update build process * fix publically available exports * Fix cy-in-cy tests * add ts-expect-error to failing files * fix projectConfigIpc failures as there are now multiple installs of tsx * fix after-pack hook * fix binary script * chore: update publish binary to account for CLI being an ESModule compiled down to CommonJS * does this work? * fix the verify spec by making the listr2 renderer silent as it behaves differently since the refactor and is printing non deterministic outputs into our tests that do not have a large impact on the area we are testing and mostly served to actually test the renders of the listr2 framework itself * empty commit * additional refactor to code to remove strange any typing and exporting * bump cache and build binaries * fix CLI exports to keep backwards compatibility * fix unit-tests * turn on mac jobs * fix group name rename in CLI * remove babel deps from cli and explicitly install typescript * address feedback from code review * dont just falsy check results and instead explicitly check for null or undefined * add ts-expect-error * additional pass on cleaning up dynamic require / import from global lib references * annotate ts-expect-errors with reason for why error is expected * add rest of ts-expect-error comments * removing hardcoded branch to publish binary chore/migrate_cli_to_typescript
112 lines
2.8 KiB
TypeScript
112 lines
2.8 KiB
TypeScript
import '../../spec_helper'
|
|
import os from 'os'
|
|
|
|
import xvfb from '../../../lib/exec/xvfb'
|
|
|
|
describe('lib/exec/xvfb', function () {
|
|
beforeEach(function (): void {
|
|
(os.platform as any).returns('win32')
|
|
})
|
|
|
|
context('debugXvfb', function () {
|
|
const { Debug } = xvfb._debugXvfb
|
|
const { namespaces } = Debug
|
|
|
|
beforeEach(() => {
|
|
Debug.enable(namespaces)
|
|
})
|
|
|
|
afterEach(() => {
|
|
Debug.enable(namespaces)
|
|
})
|
|
|
|
it('outputs when enabled', function () {
|
|
sinon.stub(process.stderr, 'write').returns(undefined)
|
|
Debug.enable(xvfb._debugXvfb.namespace)
|
|
|
|
xvfb._xvfb._onStderrData('asdf')
|
|
|
|
expect(process.stderr.write).to.be.calledWithMatch('cypress:xvfb')
|
|
expect(process.stderr.write).to.be.calledWithMatch('asdf')
|
|
})
|
|
|
|
it('does not output when disabled', function () {
|
|
sinon.stub(process.stderr, 'write')
|
|
Debug.disable()
|
|
|
|
xvfb._xvfb._onStderrData('asdf')
|
|
|
|
expect(process.stderr.write).not.to.be.calledWithMatch('cypress:xvfb')
|
|
expect(process.stderr.write).not.to.be.calledWithMatch('asdf')
|
|
})
|
|
})
|
|
|
|
context('xvfbOptions', function () {
|
|
it('sets explicit screen', () => {
|
|
expect(xvfb._xvfbOptions).to.have.property('xvfb_args').that.includes('-screen')
|
|
})
|
|
})
|
|
|
|
context('#start', function () {
|
|
it('passes', function () {
|
|
sinon.stub(xvfb._xvfb, 'startAsync').resolves()
|
|
|
|
return xvfb.start()
|
|
})
|
|
|
|
it('fails with error message', function () {
|
|
const message = 'nope'
|
|
|
|
sinon.stub(xvfb._xvfb, 'startAsync').rejects(new Error(message))
|
|
|
|
return xvfb.start()
|
|
.then(() => {
|
|
throw new Error('Should have thrown an error')
|
|
})
|
|
.catch((err: Error) => {
|
|
expect(err.message).to.include(message)
|
|
})
|
|
})
|
|
|
|
it('fails when xvfb exited with non zero exit code', function () {
|
|
const e: any = new Error('something bad happened')
|
|
|
|
e.nonZeroExitCode = true
|
|
|
|
sinon.stub(xvfb._xvfb, 'startAsync').rejects(e)
|
|
|
|
return xvfb.start()
|
|
.then(() => {
|
|
throw new Error('Should have thrown an error')
|
|
})
|
|
.catch((err: any) => {
|
|
expect(err.known).to.be.true
|
|
expect(err.message).to.include('something bad happened')
|
|
expect(err.message).to.include('Xvfb exited with a non zero exit code.')
|
|
})
|
|
})
|
|
})
|
|
|
|
context('#isNeeded', function () {
|
|
it('does not need xvfb on osx', function () {
|
|
(os.platform as any).returns('darwin')
|
|
|
|
expect(xvfb.isNeeded()).to.be.false
|
|
})
|
|
|
|
it('does not need xvfb on linux when DISPLAY is set', function () {
|
|
(os.platform as any).returns('linux')
|
|
|
|
process.env.DISPLAY = ':99'
|
|
|
|
expect(xvfb.isNeeded()).to.be.false
|
|
})
|
|
|
|
it('does need xvfb on linux when no DISPLAY is set', function () {
|
|
(os.platform as any).returns('linux')
|
|
|
|
expect(xvfb.isNeeded()).to.be.true
|
|
})
|
|
})
|
|
})
|