Skip to content

Commit

Permalink
chore(server): align test folder structure to src folder structure (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
emilyrohrbough authored Oct 25, 2021
1 parent dcefd77 commit 252be9e
Show file tree
Hide file tree
Showing 27 changed files with 118 additions and 97 deletions.
14 changes: 1 addition & 13 deletions packages/server/lib/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import findSystemNode from './util/find_system_node'
const debug = Debug('cypress:server:config')

import { options, breakingOptions } from './config_options'
import { getProcessEnvVars } from './util/config'
import { getProcessEnvVars, CYPRESS_SPECIAL_ENV_VARS } from './util/config'

export const RESOLVED_FROM = ['plugin', 'env', 'default', 'runtime', 'config'] as const

Expand All @@ -32,18 +32,6 @@ export type ResolvedConfigurationOptions = Partial<{
[x in keyof Cypress.ResolvedConfigOptions]: ResolvedFromConfig
}>

export const CYPRESS_ENV_PREFIX = 'CYPRESS_'

export const CYPRESS_ENV_PREFIX_LENGTH = 'CYPRESS_'.length

export const CYPRESS_RESERVED_ENV_VARS = [
'CYPRESS_INTERNAL_ENV',
]

export const CYPRESS_SPECIAL_ENV_VARS = [
'RECORD_KEY',
]

const dashesOrUnderscoresRe = /^(_-)+/

// takes an array and creates an index object of [keyKey]: [valueKey]
Expand Down
17 changes: 12 additions & 5 deletions packages/server/lib/util/config.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
import _ from 'lodash'
import {
CYPRESS_ENV_PREFIX,
CYPRESS_ENV_PREFIX_LENGTH,
CYPRESS_RESERVED_ENV_VARS,
} from '../config'
import { coerce } from './coerce'

export const CYPRESS_ENV_PREFIX = 'CYPRESS_'

export const CYPRESS_ENV_PREFIX_LENGTH = 'CYPRESS_'.length

export const CYPRESS_RESERVED_ENV_VARS = [
'CYPRESS_INTERNAL_ENV',
]

export const CYPRESS_SPECIAL_ENV_VARS = [
'RECORD_KEY',
]

export const isDefault = (config: Record<string, any>, prop: string) => {
return config.resolved[prop].from === 'default'
}
Expand Down
2 changes: 1 addition & 1 deletion packages/server/test/unit/browsers/browsers_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const utils = require(`${root}../lib/browsers/utils`)
const snapshot = require('snap-shot-it')

const normalizeBrowsers = (message) => {
return message.replace(/(found are: ).*/, '$1chrome, firefox, electron')
return message.replace(/(found on your system are:)((\n.*)*)/, '$1\n- chrome\n- firefox\n- electron')
}

// When we added component testing mode, we added the option for electron to be omitted
Expand Down
22 changes: 0 additions & 22 deletions packages/server/test/unit/config_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2412,25 +2412,3 @@ describe('lib/config', () => {
})
})
})

describe('lib/util/config', () => {
context('.isDefault', () => {
it('returns true if value is default value', () => {
settings = { baseUrl: null }
const defaults = { baseUrl: null }
const resolved = {}
const merged = config.setResolvedConfigValues(settings, defaults, resolved)

expect(configUtil.isDefault(merged, 'baseUrl')).to.be.true
})

it('returns false if value is not default value', () => {
settings = { baseUrl: null }
const defaults = { baseUrl: 'http://localhost:8080' }
const resolved = {}
const merged = config.setResolvedConfigValues(settings, defaults, resolved)

expect(configUtil.isDefault(merged, 'baseUrl')).to.be.false
})
})
})
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
require('../spec_helper')
require('../../spec_helper')

const path = require('path')
const os = require('os')
const snapshot = require('snap-shot-it')
const stripAnsi = require('strip-ansi')
const minimist = require('minimist')
const argsUtil = require(`${root}lib/util/args`)
const getWindowsProxyUtil = require(`${root}lib/util/get-windows-proxy`)
const argsUtil = require(`${root}../lib/util/args`)
const getWindowsProxyUtil = require(`${root}../lib/util/get-windows-proxy`)

const cwd = process.cwd()

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require('../spec_helper')
require('../../spec_helper')

const CacheBuster = require(`${root}lib/util/cache_buster`)
const CacheBuster = require(`${root}../lib/util/cache_buster`)

describe('lib/cache_buster', () => {
context('#get', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
require('../spec_helper')
require('../../spec_helper')

const _ = require('lodash')
const { stripIndent } = require('common-tags')
const chromePolicyCheck = require(`${root}lib/util/chrome_policy_check`)
const chromePolicyCheck = require(`${root}../lib/util/chrome_policy_check`)

describe('lib/util/chrome_policy_check', () => {
context('.getRunner returns a function', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
const mockedEnv = require('mocked-env')

require('../spec_helper')
require('../../spec_helper')

const ciProvider = require(`${root}lib/util/ci_provider`)
const ciProvider = require(`${root}../lib/util/ci_provider`)

const expectsName = (name) => {
expect(ciProvider.provider(), 'CI providers detected name').to.eq(name)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require('../spec_helper')
require('../../spec_helper')

const { coerce } = require(`${root}lib/util/coerce`)
const { getProcessEnvVars } = require(`${root}lib/util/config`)
const { coerce } = require(`${root}../lib/util/coerce`)
const { getProcessEnvVars } = require(`${root}../lib/util/config`)

describe('lib/util/coerce', () => {
beforeEach(function () {
Expand Down
48 changes: 48 additions & 0 deletions packages/server/test/unit/util/config_spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
require('../../spec_helper')

const configUtil = require(`${root}../lib/util/config`)

describe('lib/util/config', () => {
context('.isDefault', () => {
it('returns true if value is default value', () => {
const options = {
resolved: {
baseUrl: { from: 'default' },
},
}

expect(configUtil.isDefault(options, 'baseUrl')).to.be.true
})

it('returns false if value is not default value', () => {
const options = {
resolved: {
baseUrl: { from: 'cli' },
},
}

expect(configUtil.isDefault(options, 'baseUrl')).to.be.false
})
})

context('.getProcessEnvVars', () => {
it('returns process envs prefixed with cypress', () => {
const envs = {
CYPRESS_BASE_URL: 'value',
RANDOM_ENV: 'ignored',
}

expect(configUtil.getProcessEnvVars(envs)).to.deep.eq({
BASE_URL: 'value',
})
})

it('does not return CYPRESS_RESERVED_ENV_VARS', () => {
const envs = {
CYPRESS_INTERNAL_ENV: 'value',
}

expect(configUtil.getProcessEnvVars(envs)).to.deep.eq({})
})
})
})
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require('../spec_helper')
require('../../spec_helper')

const duration = require(`${root}lib/util/duration`)
const duration = require(`${root}../lib/util/duration`)

describe('lib/util/duration', () => {
context('.format', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import '../spec_helper'
import '../../spec_helper'

import { connect, agent } from '@packages/network'
import { isListening } from '../../lib/util/ensure-url'
import { isListening } from '../../../lib/util/ensure-url'
import sinon from 'sinon'
import nock from 'nock'

Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
require('../spec_helper')
require('../../spec_helper')

const os = require('os')
const path = require('path')
const Promise = require('bluebird')
const lockFile = Promise.promisifyAll(require('lockfile'))
const { fs } = require(`${root}lib/util/fs`)
const env = require(`${root}lib/util/env`)
const exit = require(`${root}lib/util/exit`)
const FileUtil = require(`${root}lib/util/file`)
const { fs } = require(`${root}../lib/util/fs`)
const env = require(`${root}../lib/util/env`)
const exit = require(`${root}../lib/util/exit`)
const FileUtil = require(`${root}../lib/util/file`)

describe('lib/util/file', () => {
beforeEach(function () {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require('../spec_helper')
require('../../spec_helper')

const humanInterval = require('human-interval')
const humanTime = require(`${root}lib/util/human_time`)
const humanTime = require(`${root}../lib/util/human_time`)

describe('lib/util/human_time', () => {
context('.long', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import '../spec_helper'
import '../../spec_helper'

import newlines from '../../lib/util/newlines'
import newlines from '../../../lib/util/newlines'

describe('lib/util/newlines', function () {
it('inserts newline at each n char', function () {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require('../spec_helper')
require('../../spec_helper')

const cp = require('child_process')
const open = require(`${root}lib/util/open`)
const open = require(`${root}../lib/util/open`)

const platform = (p) => {
return Object.defineProperty(process, 'platform', {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require('../spec_helper')
require('../../spec_helper')

const origin = require(`${root}lib/util/origin`)
const origin = require(`${root}../lib/util/origin`)

describe('lib/util/origin', () => {
beforeEach(function () {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require('../spec_helper')
require('../../spec_helper')

const path_helpers = require(`${root}lib/util/path_helpers`)
const path_helpers = require(`${root}../lib/util/path_helpers`)

describe('lib/util/path_helpers', () => {
context('checkIfResolveChangedRootFolder', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
require('../spec_helper')
require('../../spec_helper')

const os = require('os')
const path = require('path')
const { fs } = require(`${root}/lib/util/fs`)
const findProcess = require(`${root}lib/util/find_process`)
const profileCleaner = require(`${root}lib/util/profile_cleaner`)
const { fs } = require(`${root}../lib/util/fs`)
const findProcess = require(`${root}../lib/util/find_process`)
const profileCleaner = require(`${root}../lib/util/profile_cleaner`)

const tmpDir = os.tmpdir()
const pidProfilesFolder = path.join(tmpDir, 'pid-profiles')
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require('../spec_helper')
require('../../spec_helper')

const randomstring = require('randomstring')
const random = require(`${root}lib/util/random`)
const random = require(`${root}../lib/util/random`)

context('.id', () => {
it('returns random.generate string with length 5 by default', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require('../spec_helper')
require('../../spec_helper')

const { apiRoutes, onRoutes } = require(`${root}/lib/util/routes`)
const { apiRoutes, onRoutes } = require(`${root}../lib/util/routes`)

describe('lib/util/routes', () => {
describe('api routes', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
require('../spec_helper')
require('../../spec_helper')

const R = require('ramda')
const path = require('path')
const config = require(`${root}lib/config`)
const specsUtil = require(`${root}lib/util/specs`).default
const config = require(`${root}../lib/config`)
const specsUtil = require(`${root}../lib/util/specs`).default
const FixturesHelper = require('@tooling/system-tests/lib/fixtures')
const debug = require('debug')('test')

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
require('../spec_helper')
require('../../spec_helper')

const _ = require('lodash')
const fs = require('fs')
const stream = require('stream')
const Promise = require('bluebird')
const { concatStream } = require('@packages/network')
const { streamBuffer } = require('../../lib/util/stream_buffer')
const { streamBuffer } = require('../../../lib/util/stream_buffer')

function drain (stream) {
return new Promise((resolve) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import '../spec_helper'
import '../../spec_helper'
import { expect } from 'chai'
import execa from 'execa'
import proxyquire from 'proxyquire'

const ERROR_MESSAGE = 'Setting the NODE_TLS_REJECT_UNAUTHORIZED'

const TLS_CONNECT = `require('tls').connect().on('error', ()=>{});`
const SUPPRESS_WARNING = `require('${__dirname}/../../lib/util/suppress_warnings').suppress();`
const SUPPRESS_WARNING = `require('${__dirname}/../../../lib/util/suppress_warnings').suppress();`

describe('lib/util/suppress_warnings', function () {
it('tls.connect emits warning if NODE_TLS_REJECT_UNAUTHORIZED=0 and not suppressed', function () {
Expand Down Expand Up @@ -36,7 +36,7 @@ describe('lib/util/suppress_warnings', function () {
const emitWarning = sinon.spy(process, 'emitWarning')

// force typescript to always be non-requireable
const { suppress } = proxyquire('../../lib/util/suppress_warnings', {})
const { suppress } = proxyquire('../../../lib/util/suppress_warnings', {})

suppress()

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
require('../spec_helper')
require('../../spec_helper')

const snapshot = require('snap-shot-it')
const stripAnsi = require('strip-ansi')
const widestLine = require('widest-line')
const env = require(`${root}lib/util/env`)
const terminal = require(`${root}lib/util/terminal`)
const terminalSize = require(`${root}lib/util/terminal-size`)
const env = require(`${root}../lib/util/env`)
const terminal = require(`${root}../lib/util/terminal`)
const terminalSize = require(`${root}../lib/util/terminal-size`)

const sanitizeSnapshot = (str) => {
return snapshot(stripAnsi(str))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
require('../spec_helper')
require('../../spec_helper')

const fs = require('fs')
const os = require('os')
const path = require('path')
const trash = require(`${root}lib/util/trash`)
const trash = require(`${root}../lib/util/trash`)

const populateDirectories = function (basePath) {
fs.mkdirSync(basePath)
Expand Down
Loading

4 comments on commit 252be9e

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 252be9e Oct 25, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the linux x64 version of the Test Runner.

Learn more about this pre-release platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/8.7.0/circle-develop-252be9e26e6a9d46b9269ea88efeffa5b0cd30db/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 252be9e Oct 25, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AppVeyor has built the win32 ia32 version of the Test Runner.

Learn more about this pre-release platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/8.7.0/appveyor-develop-252be9e26e6a9d46b9269ea88efeffa5b0cd30db/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 252be9e Oct 25, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AppVeyor has built the win32 x64 version of the Test Runner.

Learn more about this pre-release platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/8.7.0/appveyor-develop-252be9e26e6a9d46b9269ea88efeffa5b0cd30db/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 252be9e Oct 25, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the darwin x64 version of the Test Runner.

Learn more about this pre-release platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/8.7.0/circle-develop-252be9e26e6a9d46b9269ea88efeffa5b0cd30db/cypress.tgz

Please sign in to comment.