diff --git a/packages/server/__snapshots__/8_reporters_spec.coffee.js b/packages/server/__snapshots__/8_reporters_spec.coffee.js index 61ea2bd0a3..706d8c13fa 100644 --- a/packages/server/__snapshots__/8_reporters_spec.coffee.js +++ b/packages/server/__snapshots__/8_reporters_spec.coffee.js @@ -10,7 +10,7 @@ The error we received was: Cannot find module '/foo/bar/.projects/e2e/node_modules/module-does-not-exist' Require stack: -- lib/reporter.coffee +- lib/reporter.js - lib/project.js - lib/modes/run.js - lib/modes/index.js diff --git a/packages/server/lib/api.js b/packages/server/lib/api.js index bd25902fa8..176274721b 100644 --- a/packages/server/lib/api.js +++ b/packages/server/lib/api.js @@ -1,15 +1,3 @@ -/* eslint-disable - no-unused-vars, -*/ -// TODO: This file was created by bulk-decaffeinate. -// Fix any style issues and re-enable lint. -/* - * decaffeinate suggestions: - * DS102: Remove unnecessary code created because of implicit returns - * DS207: Consider shorter variations of null checks - * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md - */ -let intervals const _ = require('lodash') const os = require('os') const debug = require('debug')('cypress:server:api') @@ -17,19 +5,17 @@ const request = require('@cypress/request-promise') const errors = require('@cypress/request-promise/errors') const Promise = require('bluebird') const humanInterval = require('human-interval') -const { - agent, -} = require('@packages/network') +const { agent } = require('@packages/network') const pkg = require('@packages/root') const machineId = require('./util/machine_id') const routes = require('./util/routes') -const system = require('./util/system') -const cache = require('./cache') const THIRTY_SECONDS = humanInterval('30 seconds') const SIXTY_SECONDS = humanInterval('60 seconds') const TWO_MINUTES = humanInterval('2 minutes') +let intervals + let DELAYS = [ THIRTY_SECONDS, SIXTY_SECONDS, @@ -122,8 +108,8 @@ const tagError = function (err) { // retry on timeouts, 5xx errors, or any error without a status code const isRetriableError = (err) => { return (err instanceof Promise.TimeoutError) || -(500 <= err.statusCode && err.statusCode < 600) || -(err.statusCode == null) + (500 <= err.statusCode && err.statusCode < 600) || + (err.statusCode == null) } module.exports = { diff --git a/packages/server/lib/cache.js b/packages/server/lib/cache.js index 665e23de8f..e058b2150c 100644 --- a/packages/server/lib/cache.js +++ b/packages/server/lib/cache.js @@ -1,15 +1,4 @@ -/* eslint-disable - no-unused-vars, -*/ -// TODO: This file was created by bulk-decaffeinate. -// Fix any style issues and re-enable lint. -/* - * decaffeinate suggestions: - * DS102: Remove unnecessary code created because of implicit returns - * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md - */ const _ = require('lodash') -const path = require('path') const Promise = require('bluebird') const fs = require('./util/fs') const appData = require('./util/app_data') diff --git a/packages/server/lib/capture.js b/packages/server/lib/capture.js index 53a7971757..ebffb11c56 100644 --- a/packages/server/lib/capture.js +++ b/packages/server/lib/capture.js @@ -1,13 +1,3 @@ -/* eslint-disable - prefer-rest-params, -*/ -// TODO: This file was created by bulk-decaffeinate. -// Fix any style issues and re-enable lint. -/* - * decaffeinate suggestions: - * DS102: Remove unnecessary code created because of implicit returns - * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md - */ const _write = process.stdout.write const _log = process.log @@ -18,19 +8,11 @@ const restore = function () { } const stdout = function () { - // always restore right when we start capturing - // restore() - const logs = [] - // lazily backup write to enable - // injection - const { - write, - } = process.stdout - const { - log, - } = process + // lazily backup write to enable injection + const { write } = process.stdout + const { log } = process // electron adds a new process.log // method for windows instead of process.stdout.write @@ -39,6 +21,7 @@ const stdout = function () { process.log = function (str) { logs.push(str) + // eslint-disable-next-line prefer-rest-params return log.apply(this, arguments) } } @@ -46,6 +29,7 @@ const stdout = function () { process.stdout.write = function (str) { logs.push(str) + // eslint-disable-next-line prefer-rest-params return write.apply(this, arguments) } diff --git a/packages/server/lib/config.js b/packages/server/lib/config.js index f342f471d1..a1bfbb39a2 100644 --- a/packages/server/lib/config.js +++ b/packages/server/lib/config.js @@ -1,21 +1,6 @@ -/* eslint-disable - default-case, - no-unused-vars, -*/ -// TODO: This file was created by bulk-decaffeinate. -// Fix any style issues and re-enable lint. -/* - * decaffeinate suggestions: - * DS102: Remove unnecessary code created because of implicit returns - * DS104: Avoid inline assignments - * DS207: Consider shorter variations of null checks - * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md - */ const _ = require('lodash') const R = require('ramda') -const la = require('lazy-ass') const path = require('path') -const check = require('check-more-types') const Promise = require('bluebird') const deepDiff = require('return-deep-diff') const errors = require('./errors') @@ -42,7 +27,6 @@ const CYPRESS_SPECIAL_ENV_VARS = [ const dashesOrUnderscoresRe = /^(_-)+/ const oneOrMoreSpacesRe = /\s+/ -const everythingAfterFirstEqualRe = /=(.+)/ const toWords = (str) => { return str.trim().split(oneOrMoreSpacesRe) @@ -257,6 +241,7 @@ const validateNoBreakingConfig = (cfg) => { return errors.throw('RENAMED_CONFIG_OPTION', key, 'trashAssetsBeforeRuns') case 'videoRecording': return errors.throw('RENAMED_CONFIG_OPTION', key, 'video') + default: } } }) @@ -312,7 +297,7 @@ const utils = { // null - if there is an error finding the file discoverModuleFile (options) { debug('discover module file %o', options) - const { filename, projectRoot, isDefault } = options + const { filename, isDefault } = options if (!isDefault) { // they have it explicitly set, so it should be there @@ -524,11 +509,12 @@ module.exports = { }) }, - updateWithPluginValues (cfg, overrides = {}) { - // diff the overrides with cfg - // including nested objects (env) - debug('starting config %o', cfg) - debug('overrides %o', overrides) + updateWithPluginValues (cfg, overrides) { + if (!overrides) { + overrides = {} + } + + debug('updateWithPluginValues %o', { cfg, overrides }) // make sure every option returned from the plugins file // passes our validation functions @@ -789,8 +775,6 @@ module.exports = { }) .then((result) => { if (result === null) { - const configFile = obj.configFile || CONFIG_DEFAULTS.configFile - return errors.throw('PLUGINS_FILE_ERROR', path.resolve(obj.projectRoot, pluginsFile)) } diff --git a/packages/server/lib/controllers/client.js b/packages/server/lib/controllers/client.js index f282d287c1..8a7c086011 100644 --- a/packages/server/lib/controllers/client.js +++ b/packages/server/lib/controllers/client.js @@ -1,10 +1,3 @@ -// TODO: This file was created by bulk-decaffeinate. -// Sanity-check the conversion and remove this comment. -/* - * decaffeinate suggestions: - * DS102: Remove unnecessary code created because of implicit returns - * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md - */ const debug = require('debug')('cypress:server:controllers:client') const socketIo = require('@packages/socket') diff --git a/packages/server/lib/controllers/files.js b/packages/server/lib/controllers/files.js index 6706f5a5af..6f7fe9ffa7 100644 --- a/packages/server/lib/controllers/files.js +++ b/packages/server/lib/controllers/files.js @@ -1,14 +1,3 @@ -/* eslint-disable - brace-style, - no-unused-vars, -*/ -// TODO: This file was created by bulk-decaffeinate. -// Fix any style issues and re-enable lint. -/* - * decaffeinate suggestions: - * DS102: Remove unnecessary code created because of implicit returns - * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md - */ const _ = require('lodash') const R = require('ramda') const path = require('path') @@ -17,7 +6,6 @@ const cwd = require('../cwd') const glob = require('../util/glob') const specsUtil = require('../util/specs') const pathHelpers = require('../util/path_helpers') -const CacheBuster = require('../util/cache_buster') const debug = require('debug')('cypress:server:controllers') const { escapeFilenameInUrl } = require('../util/escape_filename') @@ -87,8 +75,8 @@ module.exports = { return true }).then(R.tap((specs) => { return debug('filtered __all specs %o', specs) - })).map((spec) => // grab the name of each - { + })).map((spec) => { + // grab the name of each return spec.absolute }).map(convertSpecPath) } diff --git a/packages/server/lib/controllers/reporter.js b/packages/server/lib/controllers/reporter.js index 5d95ea51dc..f2ddef73af 100644 --- a/packages/server/lib/controllers/reporter.js +++ b/packages/server/lib/controllers/reporter.js @@ -1,14 +1,3 @@ -/* eslint-disable - no-unused-vars, -*/ -// TODO: This file was created by bulk-decaffeinate. -// Fix any style issues and re-enable lint. -/* - * decaffeinate suggestions: - * DS102: Remove unnecessary code created because of implicit returns - * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md - */ -const _ = require('lodash') const send = require('send') const reporter = require('@packages/reporter/lib/resolve-dist') diff --git a/packages/server/lib/controllers/runner.js b/packages/server/lib/controllers/runner.js index dc1032d66e..343afd3f59 100644 --- a/packages/server/lib/controllers/runner.js +++ b/packages/server/lib/controllers/runner.js @@ -1,15 +1,4 @@ -/* eslint-disable - no-unused-vars, -*/ -// TODO: This file was created by bulk-decaffeinate. -// Fix any style issues and re-enable lint. -/* - * decaffeinate suggestions: - * DS102: Remove unnecessary code created because of implicit returns - * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md - */ const _ = require('lodash') -const cache = require('../cache') const send = require('send') const os = require('os') const fs = require('../util/fs') diff --git a/packages/server/lib/controllers/static.js b/packages/server/lib/controllers/static.js index fdaeba95a1..62b3e3e771 100644 --- a/packages/server/lib/controllers/static.js +++ b/packages/server/lib/controllers/static.js @@ -1,10 +1,3 @@ -// TODO: This file was created by bulk-decaffeinate. -// Sanity-check the conversion and remove this comment. -/* - * decaffeinate suggestions: - * DS102: Remove unnecessary code created because of implicit returns - * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md - */ const send = require('send') const staticPkg = require('@packages/static') diff --git a/packages/server/lib/controllers/xhrs.js b/packages/server/lib/controllers/xhrs.js index e68dd83f2b..b6f32c6d1c 100644 --- a/packages/server/lib/controllers/xhrs.js +++ b/packages/server/lib/controllers/xhrs.js @@ -1,15 +1,3 @@ -/* eslint-disable - brace-style, -*/ -// TODO: This file was created by bulk-decaffeinate. -// Fix any style issues and re-enable lint. -/* - * decaffeinate suggestions: - * DS102: Remove unnecessary code created because of implicit returns - * DS104: Avoid inline assignments - * DS207: Consider shorter variations of null checks - * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md - */ const _ = require('lodash') const mime = require('mime') const Promise = require('bluebird') @@ -124,9 +112,8 @@ module.exports = { }, parseContentType (response) { - const ret = (type) => //+ "; charset=utf-8" - { - return mime.getType(type) + const ret = (type) => { + return mime.getType(type) //+ "; charset=utf-8" } if (isValidJSON(response)) { diff --git a/packages/server/lib/cwd.js b/packages/server/lib/cwd.js index 977873f957..2358f74e57 100644 --- a/packages/server/lib/cwd.js +++ b/packages/server/lib/cwd.js @@ -1,16 +1,8 @@ -// TODO: This file was created by bulk-decaffeinate. -// Sanity-check the conversion and remove this comment. -/* - * decaffeinate suggestions: - * DS102: Remove unnecessary code created because of implicit returns - * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md - */ const path = require('path') // helper for resolving to the current working directory // since electron does not play nice with process.cwd() // this function should always return path.dirname('package.json') - const appPath = (function () { // if lib is our basename then we haven't // been concatted or moved and we need to diff --git a/packages/server/lib/environment.js b/packages/server/lib/environment.js index 04c2e1b7a0..4ff52c1803 100644 --- a/packages/server/lib/environment.js +++ b/packages/server/lib/environment.js @@ -1,22 +1,11 @@ -/* eslint-disable - no-unused-vars, -*/ -// TODO: This file was created by bulk-decaffeinate. -// Fix any style issues and re-enable lint. -/* - * decaffeinate suggestions: - * DS207: Consider shorter variations of null checks - * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md - */ require('./util/fs') const os = require('os') -// -// NOTE -// -// by loading "./cwd" we are changing the current working directory + +// NOTE: by loading "./cwd" we are changing the current working directory // to the "packages/server" folder -const cwd = require('./cwd') +require('./cwd') + const Promise = require('bluebird') const debug = require('debug')('cypress:server') @@ -48,7 +37,7 @@ if (env === 'development') { Promise.config(config) -// note: we print error in development mode only +// NOTE: errors are printed in development mode only try { // i wish we didn't have to do this but we have to append // these command line switches immediately diff --git a/packages/server/lib/errors.js b/packages/server/lib/errors.js index ac2c4f1bdd..74c316d5cc 100644 --- a/packages/server/lib/errors.js +++ b/packages/server/lib/errors.js @@ -1,17 +1,4 @@ -/* eslint-disable - default-case, - no-case-declarations, - no-console, - no-const-assign, -*/ -// TODO: This file was created by bulk-decaffeinate. -// Fix any style issues and re-enable lint. -/* - * decaffeinate suggestions: - * DS102: Remove unnecessary code created because of implicit returns - * DS203: Remove `|| {}` from converted for-own loops - * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md - */ +/* eslint-disable no-console */ const _ = require('lodash') const strip = require('strip-ansi') const chalk = require('chalk') @@ -91,6 +78,9 @@ const isCypressErr = (err) => { } const getMsgByType = function (type, arg1 = {}, arg2, arg3) { + // NOTE: declarations in case blocks are forbidden so we declare them up front + let filePath; let err; let msg; let str + switch (type) { case 'CANNOT_TRASH_ASSETS': return `\ @@ -131,7 +121,7 @@ Your project has set the configuration option: \`chromeWebSecurity: false\` This option will not have an effect in ${_.capitalize(arg1)}. Tests that rely on web security being disabled will not run as expected.\ ` case 'BROWSER_NOT_FOUND_BY_NAME': - let str = `\ + str = `\ Can't run because you've entered an invalid browser name. Browser: '${arg1}' was not found on your system or is not supported by Cypress. @@ -159,7 +149,7 @@ See https://on.cypress.io/migration-guide for more information on breaking chang return str case 'BROWSER_NOT_FOUND_BY_PATH': - const msg = `\ + msg = `\ We could not identify a known browser at the path you provided: \`${arg1}\` The output from the command we ran was:\ @@ -531,8 +521,8 @@ Can't run project because port is currently in use: ${chalk.blue(arg1)} ${chalk.yellow('Assign a different port with the \'--port \' argument or shut down the other running process.')}\ ` case 'ERROR_READING_FILE': - const filePath = `\`${arg1}\`` - const err = `\`${arg2}\`` + filePath = `\`${arg1}\`` + err = `\`${arg2}\`` return `\ Error reading from: ${chalk.blue(filePath)} @@ -1022,6 +1012,7 @@ Enable write permissions to this directory to ensure screenshots and videos are If you don't require screenshots or videos to be stored you can safely ignore this warning.\ ` + default: } } diff --git a/packages/server/lib/exception.js b/packages/server/lib/exception.js index 31cf5a2989..9e54a7cddf 100644 --- a/packages/server/lib/exception.js +++ b/packages/server/lib/exception.js @@ -1,17 +1,6 @@ -/* eslint-disable - no-unused-vars, -*/ -// TODO: This file was created by bulk-decaffeinate. -// Fix any style issues and re-enable lint. -/* - * decaffeinate suggestions: - * DS102: Remove unnecessary code created because of implicit returns - * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md - */ const _ = require('lodash') const Promise = require('bluebird') const pkg = require('@packages/root') -const path = require('path') const api = require('./api') const user = require('./user') const system = require('./util/system') @@ -20,7 +9,6 @@ const system = require('./util/system') // data in the path const pathRe = /'?((\/|\\+|[a-z]:\\)[^\s']+)+'?/ig const pathSepRe = /[\/\\]+/ -const fileNameRe = /[^\s'/]+\.\w+:?\d*$/i const stripPath = (text) => { return (text || '').replace(pathRe, (path) => { const fileName = _.last(path.split(pathSepRe)) || '' diff --git a/packages/server/lib/exec.js b/packages/server/lib/exec.js index dbb2784047..27eef58abf 100644 --- a/packages/server/lib/exec.js +++ b/packages/server/lib/exec.js @@ -1,10 +1,3 @@ -// TODO: This file was created by bulk-decaffeinate. -// Sanity-check the conversion and remove this comment. -/* - * decaffeinate suggestions: - * DS102: Remove unnecessary code created because of implicit returns - * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md - */ const Promise = require('bluebird') const execa = require('execa') const R = require('ramda') @@ -33,8 +26,8 @@ module.exports = { log('in folder:', projectRoot) return execa.shell(cmd, { cwd, env, shell }) - // do we want to return all fields returned by execa? .then((result) => { + // do we want to return all fields returned by execa? result.shell = shell result.cmd = cmd diff --git a/packages/server/lib/file_server.js b/packages/server/lib/file_server.js index c58a018802..3eebd5cb02 100644 --- a/packages/server/lib/file_server.js +++ b/packages/server/lib/file_server.js @@ -1,13 +1,3 @@ -/* eslint-disable - no-unused-vars, -*/ -// TODO: This file was created by bulk-decaffeinate. -// Fix any style issues and re-enable lint. -/* - * decaffeinate suggestions: - * DS102: Remove unnecessary code created because of implicit returns - * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md - */ // TODO: move this to packages/core-file-server const _ = require('lodash') @@ -16,7 +6,6 @@ const url = require('url') const http = require('http') const path = require('path') const send = require('send') -const errors = require('./errors') const allowDestroy = require('./util/server_destroy') const random = require('./util/random') const networkFailures = require('./util/network_failures') diff --git a/packages/server/lib/files.js b/packages/server/lib/files.js index 1817ac4dbc..d74dc53d1c 100644 --- a/packages/server/lib/files.js +++ b/packages/server/lib/files.js @@ -1,24 +1,10 @@ -/* eslint-disable - no-unused-vars, -*/ -// TODO: This file was created by bulk-decaffeinate. -// Fix any style issues and re-enable lint. -/* - * decaffeinate suggestions: - * DS102: Remove unnecessary code created because of implicit returns - * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md - */ const path = require('path') -const Promise = require('bluebird') const fs = require('./util/fs') module.exports = { readFile (projectRoot, file, options = {}) { const filePath = path.resolve(projectRoot, file) - const readFn = path.extname(filePath) === '.json' ? - fs.readJsonAsync - : - fs.readFileAsync + const readFn = path.extname(filePath) === '.json' ? fs.readJsonAsync : fs.readFileAsync return readFn(filePath, options.encoding || 'utf8') .then((contents) => { diff --git a/packages/server/lib/fixture.js b/packages/server/lib/fixture.js index bd724c35a7..6a2216fa34 100644 --- a/packages/server/lib/fixture.js +++ b/packages/server/lib/fixture.js @@ -1,21 +1,9 @@ -/* eslint-disable - no-unused-vars, -*/ -// TODO: This file was created by bulk-decaffeinate. -// Fix any style issues and re-enable lint. -/* - * decaffeinate suggestions: - * DS102: Remove unnecessary code created because of implicit returns - * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md - */ -const _ = require('lodash') const path = require('path') const check = require('syntax-error') const debug = require('debug')('cypress:server:fixture') const coffee = require('../../../packages/coffee') const Promise = require('bluebird') const jsonlint = require('jsonlint') -const cwd = require('./cwd') const errors = require('./errors') const fs = require('./util/fs') const glob = require('./util/glob') @@ -38,10 +26,6 @@ const extensions = [ const queue = {} -const lastCharacterIsNewLine = (str) => { - return str[str.length - 1] === '\n' -} - const friendlyJsonParse = function (s) { jsonlint.parse(s) // might throw good error @@ -59,8 +43,6 @@ module.exports = { .then(function () { debug('fixture exact name exists', p) - const ext = path.extname(fixture) - return this.parseFile(p, fixture, options) }).catch(function (e) { if (e.code !== 'ENOENT') { diff --git a/packages/server/lib/gui/dialog.js b/packages/server/lib/gui/dialog.js index d15c4c2edd..dc123baaff 100644 --- a/packages/server/lib/gui/dialog.js +++ b/packages/server/lib/gui/dialog.js @@ -1,17 +1,5 @@ -/* eslint-disable - brace-style, -*/ -// TODO: This file was created by bulk-decaffeinate. -// Fix any style issues and re-enable lint. -/* - * decaffeinate suggestions: - * DS102: Remove unnecessary code created because of implicit returns - * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md - */ const _ = require('lodash') -const { - dialog, -} = require('electron') +const { dialog } = require('electron') module.exports = { show () { @@ -29,9 +17,9 @@ module.exports = { } return dialog.showOpenDialog(props) - .then((obj) => // return the first path since there can only ever - // be a single directory selection - { + .then((obj) => { + // return the first path since there can only ever + // be a single directory selection return _.get(obj, ['filePaths', 0]) }) }, diff --git a/packages/server/lib/gui/events.js b/packages/server/lib/gui/events.js index a2e62a6ee3..f58ff0ac98 100644 --- a/packages/server/lib/gui/events.js +++ b/packages/server/lib/gui/events.js @@ -1,16 +1,4 @@ -/* eslint-disable - no-case-declarations, - no-unused-vars, -*/ -// TODO: This file was created by bulk-decaffeinate. -// Fix any style issues and re-enable lint. -/* - * decaffeinate suggestions: - * DS102: Remove unnecessary code created because of implicit returns - * DS103: Rewrite code to no longer use __guard__ - * DS207: Consider shorter variations of null checks - * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md - */ +/* eslint-disable no-case-declarations */ const _ = require('lodash') const ipc = require('electron').ipcMain const { shell, clipboard } = require('electron') @@ -22,7 +10,6 @@ const pkg = require('./package') const logs = require('./logs') const auth = require('./auth') const Windows = require('./windows') -const api = require('../api') const open = require('../util/open') const user = require('../user') const errors = require('../errors') @@ -356,9 +343,9 @@ const handleEvent = function (options, bus, event, id, type, arg) { .catch((err) => { err.type = _.get(err, 'statusCode') === 403 ? 'ALREADY_MEMBER' - : (_.get(err, 'statusCode') === 422) && /existing/.test(__guard__(err.errors != null ? err.errors.userId : undefined, (x) => { + : (_.get(err, 'statusCode') === 422) && /existing/.test(err.errors && err.errors.userId, (x) => { return x.join('') - })) ? + }) ? 'ALREADY_REQUESTED' : err.type || 'UNKNOWN' @@ -426,7 +413,3 @@ module.exports = { }, } - -function __guard__ (value, transform) { - return (typeof value !== 'undefined' && value !== null) ? transform(value) : undefined -} diff --git a/packages/server/lib/gui/logs.js b/packages/server/lib/gui/logs.js index 73a43e24fa..385c5c48e5 100644 --- a/packages/server/lib/gui/logs.js +++ b/packages/server/lib/gui/logs.js @@ -1,13 +1,3 @@ -/* eslint-disable - no-console, -*/ -// TODO: This file was created by bulk-decaffeinate. -// Fix any style issues and re-enable lint. -/* - * decaffeinate suggestions: - * DS102: Remove unnecessary code created because of implicit returns - * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md - */ const chalk = require('chalk') const logger = require('../logger') @@ -40,6 +30,7 @@ module.exports = { const str = JSON.stringify(log) const color = (i % 2) === 0 ? 'cyan' : 'yellow' + // eslint-disable-next-line no-console return console.log(chalk[color](str)) }) }) diff --git a/packages/server/lib/gui/package.js b/packages/server/lib/gui/package.js index 4a37a3c499..e67ee55075 100644 --- a/packages/server/lib/gui/package.js +++ b/packages/server/lib/gui/package.js @@ -1,10 +1,3 @@ -// TODO: This file was created by bulk-decaffeinate. -// Sanity-check the conversion and remove this comment. -/* - * decaffeinate suggestions: - * DS102: Remove unnecessary code created because of implicit returns - * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md - */ const _ = require('lodash') const Promise = require('bluebird') const json = require('@packages/root') diff --git a/packages/server/lib/gui/windows.js b/packages/server/lib/gui/windows.js index 59fe567d92..db5aff55c1 100644 --- a/packages/server/lib/gui/windows.js +++ b/packages/server/lib/gui/windows.js @@ -1,29 +1,10 @@ -/* eslint-disable - brace-style, - no-unused-vars, - prefer-rest-params, -*/ -// TODO: This file was created by bulk-decaffeinate. -// Fix any style issues and re-enable lint. -/* - * decaffeinate suggestions: - * DS102: Remove unnecessary code created because of implicit returns - * DS104: Avoid inline assignments - * DS207: Consider shorter variations of null checks - * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md - */ const _ = require('lodash') -const uri = require('url') const Promise = require('bluebird') const cyDesktop = require('@packages/desktop-gui') -const extension = require('@packages/extension') const contextMenu = require('electron-context-menu') -const { - BrowserWindow, -} = require('electron') +const { BrowserWindow } = require('electron') const debug = require('debug')('cypress:server:windows') const cwd = require('../cwd') -const user = require('../user') const savedState = require('../saved_state') let windows = {} @@ -42,15 +23,6 @@ const getByType = (type) => { return windows[type] } -const getCookieUrl = (props) => { - return extension.getCookieUrl(props) -} - -const firstOrNull = (cookies) => // normalize into null when empty array -{ - return cookies[0] != null ? cookies[0] : null -} - const setWindowProxy = function (win) { if (!process.env.HTTP_PROXY) { return @@ -175,18 +147,18 @@ module.exports = { const win = this._newBrowserWindow(options) - win.on('blur', function () { - return options.onBlur.apply(win, arguments) + win.on('blur', function (...args) { + return options.onBlur.apply(win, args) }) - win.on('focus', function () { - return options.onFocus.apply(win, arguments) + win.on('focus', function (...args) { + return options.onFocus.apply(win, args) }) - win.once('closed', function () { + win.once('closed', function (...args) { win.removeAllListeners() - return options.onClose.apply(win, arguments) + return options.onClose.apply(win, args) }) // the webview loses focus on navigation, so we @@ -200,12 +172,12 @@ module.exports = { }) } - win.webContents.on('crashed', function () { - return options.onCrashed.apply(win, arguments) + win.webContents.on('crashed', function (...args) { + return options.onCrashed.apply(win, args) }) - win.webContents.on('new-window', function () { - return options.onNewWindow.apply(win, arguments) + win.webContents.on('new-window', function (...args) { + return options.onNewWindow.apply(win, args) }) ts = options.trackState @@ -267,9 +239,8 @@ module.exports = { win.webContents.id = _.uniqueId('webContents') - win.once('closed', () => // slice the window out of windows reference - { - return delete windows[options.type] + win.once('closed', () => { + delete windows[options.type] }) // enable our url to be a promise diff --git a/packages/server/lib/konfig.js b/packages/server/lib/konfig.js index 626f4c5df0..1229694816 100644 --- a/packages/server/lib/konfig.js +++ b/packages/server/lib/konfig.js @@ -1,10 +1,3 @@ -// TODO: This file was created by bulk-decaffeinate. -// Sanity-check the conversion and remove this comment. -/* - * decaffeinate suggestions: - * DS102: Remove unnecessary code created because of implicit returns - * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md - */ require('./environment') const konfig = require('konfig') diff --git a/packages/server/lib/log.js b/packages/server/lib/log.js index a634d354df..61425870d4 100644 --- a/packages/server/lib/log.js +++ b/packages/server/lib/log.js @@ -1,5 +1,3 @@ -// TODO: This file was created by bulk-decaffeinate. -// Sanity-check the conversion and remove this comment. // lightweight logging for Node // only shows log messages if running with // DEBUG=cypress:start ... diff --git a/packages/server/lib/logger.js b/packages/server/lib/logger.js index d18aedf257..4124e02e17 100644 --- a/packages/server/lib/logger.js +++ b/packages/server/lib/logger.js @@ -1,14 +1,4 @@ -/* eslint-disable - no-console, -*/ -// TODO: This file was created by bulk-decaffeinate. -// Fix any style issues and re-enable lint. -/* - * decaffeinate suggestions: - * DS102: Remove unnecessary code created because of implicit returns - * DS207: Consider shorter variations of null checks - * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md - */ +/* eslint-disable no-console */ const path = require('path') const _ = require('lodash') const Promise = require('bluebird') diff --git a/packages/server/lib/plugins/preprocessor.js b/packages/server/lib/plugins/preprocessor.js index a5bf53337e..1007830688 100644 --- a/packages/server/lib/plugins/preprocessor.js +++ b/packages/server/lib/plugins/preprocessor.js @@ -1,34 +1,22 @@ -/* eslint-disable - no-console, - no-undef, - no-unused-vars, -*/ -// TODO: This file was created by bulk-decaffeinate. -// Fix any style issues and re-enable lint. -/* - * decaffeinate suggestions: - * DS102: Remove unnecessary code created because of implicit returns - * DS104: Avoid inline assignments - * DS207: Consider shorter variations of null checks - * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md - */ +require('../cwd') + const _ = require('lodash') const EE = require('events') const path = require('path') const debug = require('debug')('cypress:server:preprocessor') const Promise = require('bluebird') const appData = require('../util/app_data') -const cwd = require('../cwd') const plugins = require('../plugins') const resolve = require('./resolve') const errorMessage = function (err = {}) { - return ((((left1 = err.stack != null ? err.stack : err.annotated) != null ? left1 : err.message) || err.toString())) + return (err.stack || err.annotated || err.message || err.toString()) .replace(/\n\s*at.*/g, '') .replace(/From previous event:\n?/g, '') } const clientSideError = function (err) { + // eslint-disable-next-line no-console console.log(err.message) err = errorMessage(err) diff --git a/packages/server/lib/plugins/util.js b/packages/server/lib/plugins/util.js index 75b768ad67..5b28e48ccf 100644 --- a/packages/server/lib/plugins/util.js +++ b/packages/server/lib/plugins/util.js @@ -1,10 +1,3 @@ -// TODO: This file was created by bulk-decaffeinate. -// Sanity-check the conversion and remove this comment. -/* - * decaffeinate suggestions: - * DS102: Remove unnecessary code created because of implicit returns - * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md - */ const _ = require('lodash') const EE = require('events') const debug = require('debug')('cypress:server:plugins') diff --git a/packages/server/lib/project.js b/packages/server/lib/project.js index 40fa9c78cb..d18a166764 100644 --- a/packages/server/lib/project.js +++ b/packages/server/lib/project.js @@ -54,7 +54,7 @@ class Project extends EE { } this.projectRoot = path.resolve(projectRoot) - this.watchers = Watchers() + this.watchers = new Watchers() this.cfg = null this.spec = null this.browser = null @@ -68,7 +68,7 @@ class Project extends EE { open (options = {}) { debug('opening project instance %s', this.projectRoot) debug('project open options %o', options) - this.server = Server() + this.server = new Server() _.defaults(options, { report: false, diff --git a/packages/server/lib/repl.js b/packages/server/lib/repl.js index 323ca77ddc..9ad0e26ea6 100644 --- a/packages/server/lib/repl.js +++ b/packages/server/lib/repl.js @@ -1,12 +1,3 @@ -// TODO: This file was created by bulk-decaffeinate. -// Sanity-check the conversion and remove this comment. -/* - * decaffeinate suggestions: - * DS102: Remove unnecessary code created because of implicit returns - * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md - */ -let setContext - require('./environment') const _ = require('lodash') @@ -20,6 +11,8 @@ const replServer = repl.start({ prompt: '> ', }) +let setContext + // preserve the repl history history(replServer, path.join(process.env.HOME, '.node_history')) diff --git a/packages/server/lib/reporter.js b/packages/server/lib/reporter.js index b59c0b2ad2..b702a39073 100644 --- a/packages/server/lib/reporter.js +++ b/packages/server/lib/reporter.js @@ -1,17 +1,3 @@ -/* eslint-disable - no-case-declarations, - no-self-assign, - no-unused-vars, -*/ -// TODO: This file was created by bulk-decaffeinate. -// Fix any style issues and re-enable lint. -/* - * decaffeinate suggestions: - * DS102: Remove unnecessary code created because of implicit returns - * DS205: Consider reworking code to avoid use of IIFEs - * DS207: Consider shorter variations of null checks - * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md - */ const _ = require('lodash') const path = require('path') // mocha-* is used to allow us to have later versions of mocha specified in devDependencies @@ -25,8 +11,6 @@ const debug = require('debug')('cypress:server:reporter') const Promise = require('bluebird') const { overrideRequire } = require('./override_require') -const STATS = 'suites tests passes pending failures start end duration'.split(' ') - // override calls to `require('mocha*')` when to always resolve with a mocha we control // otherwise mocha will be resolved from project's node_modules and might not work with our code const customReporterMochaPath = path.dirname(require.resolve('mocha-7.0.1')) @@ -135,10 +119,9 @@ const mergeRunnable = (eventName) => { } const safelyMergeRunnable = function (hookProps, runnables) { - let runnable const { hookId, title, hookName, body, type } = hookProps - if (!(runnable = runnables[hookId])) { + if (!runnables[hookId]) { runnables[hookId] = { hookId, type, @@ -158,9 +141,6 @@ const mergeErr = function (runnable, runnables, stats) { test.err = runnable.err test.state = 'failed' - if (test.duration == null) { - test.duration = test.duration - } if (runnable.type === 'hook') { test.failedFromHookId = runnable.hookId @@ -223,7 +203,11 @@ class Reporter { this.reporterOptions = reporterOptions } - setRunnables (rootRunnable = { title: '' }) { + setRunnables (rootRunnable) { + if (!rootRunnable) { + rootRunnable = { title: '' } + } + // manage stats ourselves this.stats = { suites: 0, tests: 0, passes: 0, pending: 0, skipped: 0, failures: 0 } this.runnables = {} @@ -246,6 +230,7 @@ class Reporter { const runnable = (() => { switch (type) { case 'suite': + // eslint-disable-next-line no-case-declarations const suite = createSuite(runnableProps, parent) suite.tests = _.map(runnableProps.tests, (testProps) => { diff --git a/packages/server/lib/screenshots.js b/packages/server/lib/screenshots.js index 0f1b17ae95..d5974c6991 100644 --- a/packages/server/lib/screenshots.js +++ b/packages/server/lib/screenshots.js @@ -1,14 +1,3 @@ -/* eslint-disable - brace-style, - no-unused-vars, -*/ -// TODO: This file was created by bulk-decaffeinate. -// Fix any style issues and re-enable lint. -/* - * decaffeinate suggestions: - * DS102: Remove unnecessary code created because of implicit returns - * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md - */ const _ = require('lodash') const mime = require('mime') const path = require('path') @@ -22,7 +11,6 @@ let debug = require('debug')('cypress:server:screenshot') const plugins = require('./plugins') const fs = require('./util/fs') const glob = require('./util/glob') -const pathHelpers = require('./util/path_helpers') const RUNNABLE_SEPARATOR = ' -- ' const pathSeparatorRe = /[\\\/]/g @@ -201,8 +189,8 @@ const clearMultipartState = function () { multipartImages = [] } -const imagesMatch = (img1, img2) => // using Buffer::equals here -{ +const imagesMatch = (img1, img2) => { + // using Buffer::equals here return img1.bitmap.data.equals(img2.bitmap.data) } @@ -313,9 +301,9 @@ const ensureUniquePath = function (withoutExt, extension, num = 0) { }) } -const sanitizeToString = (title) => // test titles may be values which aren't strings like -// null or undefined - so convert before trying to sanitize -{ +const sanitizeToString = (title) => { + // test titles may be values which aren't strings like + // null or undefined - so convert before trying to sanitize return sanitize(_.toString(title)) } diff --git a/packages/server/lib/server.js b/packages/server/lib/server.js index b3db28e6a8..02f7ccf206 100644 --- a/packages/server/lib/server.js +++ b/packages/server/lib/server.js @@ -1,16 +1,5 @@ -/* eslint-disable - brace-style, - no-unused-vars, - prefer-rest-params, -*/ -// TODO: This file was created by bulk-decaffeinate. -// Fix any style issues and re-enable lint. -/* - * decaffeinate suggestions: - * DS102: Remove unnecessary code created because of implicit returns - * DS207: Consider shorter variations of null checks - * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md - */ +require('./cwd') + const _ = require('lodash') const url = require('url') const http = require('http') @@ -21,7 +10,6 @@ const evilDns = require('evil-dns') const isHtml = require('is-html') const httpProxy = require('http-proxy') const la = require('lazy-ass') -const check = require('check-more-types') const httpsProxy = require('@packages/https-proxy') const compression = require('compression') const debug = require('debug')('cypress:server:server') @@ -41,7 +29,6 @@ const statusCode = require('./util/status_code') const headersUtil = require('./util/headers') const allowDestroy = require('./util/server_destroy') const { SocketWhitelist } = require('./util/socket_whitelist') -const cwd = require('./cwd') const errors = require('./errors') const logger = require('./logger') const Socket = require('./socket') @@ -58,9 +45,9 @@ const ALLOWED_PROXY_BYPASS_URLS = [ '/__cypress/static/favicon.ico', ] -const _isNonProxiedRequest = (req) => // proxied HTTP requests have a URL like: "http://example.com/foo" -// non-proxied HTTP requests have a URL like: "/foo" -{ +const _isNonProxiedRequest = (req) => { + // proxied HTTP requests have a URL like: "http://example.com/foo" + // non-proxied HTTP requests have a URL like: "/foo" return req.proxiedUrl.startsWith('/') } @@ -122,8 +109,6 @@ const notSSE = (req, res) => { return (req.headers.accept !== 'text/event-stream') && compression.filter(req, res) } -// currently not making use of event emitter -// but may do so soon class Server { constructor () { if (!(this instanceof Server)) { @@ -156,16 +141,11 @@ class Server { // handle the proxied url in case // we have not yet started our websocket server app.use((req, res, next) => { - let m - setProxiedUrl(req) - // if we've defined some middlware - // then call this. useful in tests - m = this._middleware - - if (m) { - m(req, res) + // useful for tests + if (this._middleware) { + this._middleware(req, res) } // always continue on @@ -190,8 +170,8 @@ class Server { return app } - createRoutes () { - return require('./routes').apply(null, arguments) + createRoutes (...args) { + return require('./routes').apply(null, args) } getHttpServer () { @@ -488,7 +468,7 @@ class Server { return currentPromisePhase = fn() } - this._urlResolver = (p = new Promise((resolve, reject, onCancel) => { + return this._urlResolver = (p = new Promise((resolve, reject, onCancel) => { let urlFile onCancel(() => { @@ -554,9 +534,9 @@ class Server { this._remoteVisitingUrl = false - const statusIs2xxOrAllowedFailure = () => // is our status code in the 2xx range, or have we disabled failing - // on status code? - { + const statusIs2xxOrAllowedFailure = () => { + // is our status code in the 2xx range, or have we disabled failing + // on status code? return statusCode.isOk(incomingRes.statusCode) || options.failOnStatusCode === false } diff --git a/packages/server/lib/task.js b/packages/server/lib/task.js index ab55d839f7..349ff781fc 100644 --- a/packages/server/lib/task.js +++ b/packages/server/lib/task.js @@ -1,10 +1,3 @@ -// TODO: This file was created by bulk-decaffeinate. -// Sanity-check the conversion and remove this comment. -/* - * decaffeinate suggestions: - * DS102: Remove unnecessary code created because of implicit returns - * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md - */ const _ = require('lodash') const Promise = require('bluebird') const debug = require('debug')('cypress:server:task') diff --git a/packages/server/lib/updater.js b/packages/server/lib/updater.js index e498c20163..177e3bc310 100644 --- a/packages/server/lib/updater.js +++ b/packages/server/lib/updater.js @@ -1,33 +1,14 @@ -/* eslint-disable - no-unused-vars, -*/ -// TODO: This file was created by bulk-decaffeinate. -// Fix any style issues and re-enable lint. -/* - * decaffeinate suggestions: - * DS102: Remove unnecessary code created because of implicit returns - * DS207: Consider shorter variations of null checks - * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md - */ const _ = require('lodash') const debug = require('debug')('cypress:server:updater') const semver = require('semver') const request = require('@cypress/request') const NwUpdater = require('node-webkit-updater') const pkg = require('@packages/root') -const { - agent, -} = require('@packages/network') +const { agent } = require('@packages/network') const cwd = require('./cwd') const konfig = require('./konfig') const { machineId } = require('./util/machine_id') -// backup the original cwd -const localCwd = cwd() - -const osxAppRe = /\.app$/ -const linuxAppRe = /Cypress$/i - NwUpdater.prototype.checkNewVersion = function (cb) { const gotManifest = function (err, req, data) { let e; let newVersion @@ -146,7 +127,7 @@ class Updater { } static check (options = {}) { - return Updater().check(options) + return new Updater().check(options) } } diff --git a/packages/server/lib/upload.js b/packages/server/lib/upload.js index 5f4b2b00e7..6c310e3610 100644 --- a/packages/server/lib/upload.js +++ b/packages/server/lib/upload.js @@ -1,16 +1,4 @@ -/* eslint-disable - no-unused-vars, -*/ -// TODO: This file was created by bulk-decaffeinate. -// Fix any style issues and re-enable lint. -/* - * decaffeinate suggestions: - * DS102: Remove unnecessary code created because of implicit returns - * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md - */ -const r = require('@cypress/request') const rp = require('@cypress/request-promise') -const Promise = require('bluebird') const fs = require('./util/fs') module.exports = { diff --git a/packages/server/lib/user.js b/packages/server/lib/user.js index f571203efa..8c2cef886d 100644 --- a/packages/server/lib/user.js +++ b/packages/server/lib/user.js @@ -1,10 +1,3 @@ -// TODO: This file was created by bulk-decaffeinate. -// Sanity-check the conversion and remove this comment. -/* - * decaffeinate suggestions: - * DS102: Remove unnecessary code created because of implicit returns - * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md - */ const debug = require('debug')('cypress:server:user') const api = require('./api') const cache = require('./cache') diff --git a/packages/server/lib/watchers.js b/packages/server/lib/watchers.js index 08c83306e6..ba325d70e2 100644 --- a/packages/server/lib/watchers.js +++ b/packages/server/lib/watchers.js @@ -1,18 +1,6 @@ -/* eslint-disable - no-unused-vars, -*/ -// TODO: This file was created by bulk-decaffeinate. -// Fix any style issues and re-enable lint. -/* - * decaffeinate suggestions: - * DS102: Remove unnecessary code created because of implicit returns - * DS205: Consider reworking code to avoid use of IIFEs - * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md - */ const _ = require('lodash') const chokidar = require('chokidar') const dependencyTree = require('dependency-tree') -const pathHelpers = require('./util/path_helpers') class Watchers { constructor () { diff --git a/packages/server/test/integration/http_requests_spec.coffee b/packages/server/test/integration/http_requests_spec.coffee index f6f5cd97d6..7052ba7cde 100644 --- a/packages/server/test/integration/http_requests_spec.coffee +++ b/packages/server/test/integration/http_requests_spec.coffee @@ -160,7 +160,7 @@ describe "Routes", -> httpsServer.start(8443), ## and open our cypress server - @server = Server(Watchers()) + @server = new Server(new Watchers()) @server.open(cfg, project) .spread (port) => diff --git a/packages/server/test/integration/server_spec.coffee b/packages/server/test/integration/server_spec.coffee index 6ccddff0dd..9d5e1c938a 100644 --- a/packages/server/test/integration/server_spec.coffee +++ b/packages/server/test/integration/server_spec.coffee @@ -71,7 +71,7 @@ describe "Server", -> httpsServer.start(8443), ## and open our cypress server - @server = Server() + @server = new Server() @server.open(cfg) .spread (port) => diff --git a/packages/server/test/integration/websockets_spec.coffee b/packages/server/test/integration/websockets_spec.coffee index 94945075c8..f190670ce2 100644 --- a/packages/server/test/integration/websockets_spec.coffee +++ b/packages/server/test/integration/websockets_spec.coffee @@ -30,7 +30,7 @@ describe "Web Sockets", -> .then (@cfg) => @ws = new ws.Server({port: wsPort}) - @server = Server() + @server = new Server() @server.open(@cfg) .then => diff --git a/packages/server/test/performance/proxy_performance_spec.js b/packages/server/test/performance/proxy_performance_spec.js index 5f891f9743..dd8192b714 100644 --- a/packages/server/test/performance/proxy_performance_spec.js +++ b/packages/server/test/performance/proxy_performance_spec.js @@ -348,7 +348,7 @@ describe('Proxy Performance', function () { // turn off morgan config.morgan = false - cyServer = Server() + cyServer = new Server() return cyServer.open(config) }), diff --git a/packages/server/test/unit/reporter_spec.coffee b/packages/server/test/unit/reporter_spec.coffee index ef01a579ff..8f0129aa67 100644 --- a/packages/server/test/unit/reporter_spec.coffee +++ b/packages/server/test/unit/reporter_spec.coffee @@ -5,7 +5,7 @@ snapshot = require("snap-shot-it") describe "lib/reporter", -> beforeEach -> - @reporter = Reporter() + @reporter = new Reporter() @root = { id: 'r1' diff --git a/packages/server/test/unit/server_spec.coffee b/packages/server/test/unit/server_spec.coffee index 655d81f6d4..4882bb0a03 100644 --- a/packages/server/test/unit/server_spec.coffee +++ b/packages/server/test/unit/server_spec.coffee @@ -28,7 +28,7 @@ describe "lib/server", -> config.set({projectRoot: "/foo/bar/"}) .then (cfg) => @config = cfg - @server = Server() + @server = new Server() @oldFileServer = @server._fileServer @server._fileServer = @fileServer @@ -191,9 +191,10 @@ describe "lib/server", -> it "sets _socket and calls _socket#startListening", -> @server.open(@config) .then => - @server.startWebsockets(1, 2, 3) + arg2 = {} + @server.startWebsockets(1, 2, arg2) - expect(@startListening).to.be.calledWith(@server.getHttpServer(), 1, 2, 3) + expect(@startListening).to.be.calledWith(@server.getHttpServer(), 1, 2, arg2) context "#reset", -> beforeEach -> @@ -310,7 +311,7 @@ describe "lib/server", -> context "#_onDomainSet", -> beforeEach -> - @server = Server() + @server = new Server() it "sets port to 443 when omitted and https:", -> ret = @server._onDomainSet("https://staging.google.com/foo/bar") diff --git a/packages/server/test/unit/socket_spec.coffee b/packages/server/test/unit/socket_spec.coffee index 0f319d4f69..5fb0762c7f 100644 --- a/packages/server/test/unit/socket_spec.coffee +++ b/packages/server/test/unit/socket_spec.coffee @@ -24,7 +24,7 @@ describe "lib/socket", -> Fixtures.scaffold() @todosPath = Fixtures.projectPath("todos") - @server = Server(@todosPath) + @server = new Server(@todosPath) config.get(@todosPath) .then (@cfg) => diff --git a/packages/server/test/unit/updater_spec.coffee b/packages/server/test/unit/updater_spec.coffee index af0f98c34d..6b94e13e8f 100644 --- a/packages/server/test/unit/updater_spec.coffee +++ b/packages/server/test/unit/updater_spec.coffee @@ -10,13 +10,13 @@ _ = require("lodash") describe "lib/updater", -> context "interface", -> it "returns an updater instance", -> - u = Updater({}) + u = new Updater({}) expect(u).to.be.instanceof Updater context "#getPackage", -> beforeEach -> pkg.foo = "bar" - @updater = Updater({}) + @updater = new Updater({}) afterEach -> delete pkg.foo @@ -29,12 +29,12 @@ describe "lib/updater", -> context "#getClient", -> it "sets .client to new Updater", -> - u = Updater({}) + u = new Updater({}) u.getClient() expect(u.client).to.have.property("checkNewVersion") it "returns .client if exists", -> - u = Updater({}) + u = new Updater({}) client = u.getClient() client2 = u.getClient() expect(client).to.eq(client2) @@ -43,7 +43,7 @@ describe "lib/updater", -> beforeEach -> @get = sinon.spy(request, "get") - @updater = Updater({}) + @updater = new Updater({}) it "sends x-cypress-version", (done) -> @updater.getClient().checkNewVersion => @@ -78,12 +78,12 @@ describe "lib/updater", -> }) done() - + return context "#check", -> beforeEach -> - @updater = Updater({quit: sinon.spy()}) + @updater = new Updater({quit: sinon.spy()}) @updater.getClient() sinon.stub(@updater.client, "checkNewVersion") diff --git a/packages/server/test/unit/watchers_spec.coffee b/packages/server/test/unit/watchers_spec.coffee index ee54e0bd34..ba23bd8705 100644 --- a/packages/server/test/unit/watchers_spec.coffee +++ b/packages/server/test/unit/watchers_spec.coffee @@ -13,7 +13,7 @@ describe "lib/watchers", -> }) sinon.stub(chokidar, "watch").returns(@standardWatcher) - @watchers = Watchers() + @watchers = new Watchers() it "returns instance of watcher class", -> expect(@watchers).to.be.instanceof(Watchers)