-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Expand file tree
/
Copy pathenvironment_spec.ts
More file actions
119 lines (86 loc) · 2.99 KB
/
environment_spec.ts
File metadata and controls
119 lines (86 loc) · 2.99 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
import Promise from 'bluebird'
import pkg from '@packages/root'
import { fs } from '../../lib/util/fs'
import { calculateCypressInternalEnv, configureLongStackTraces } from '../../lib/environment'
const env = process.env['CYPRESS_INTERNAL_ENV']
describe('lib/environment', () => {
describe('calculateCypressInternalEnv', () => {
beforeEach(() => {
delete process.env['CYPRESS_INTERNAL_ENV']
})
afterEach(() => {
delete pkg.env
delete process.env['CYPRESS_INTERNAL_ENV']
})
after(() => {
process.env['CYPRESS_INTERNAL_ENV'] = env
})
context('#existing process.env.CYPRESS_INTERNAL_ENV', () => {
it('is production', () => {
process.env['CYPRESS_INTERNAL_ENV'] = 'production'
const calculatedEnv = calculateCypressInternalEnv()
expect(calculatedEnv).to.eq('production')
})
it('is development', () => {
process.env['CYPRESS_INTERNAL_ENV'] = 'development'
const calculatedEnv = calculateCypressInternalEnv()
expect(calculatedEnv).to.eq('development')
})
it('is staging', () => {
process.env['CYPRESS_INTERNAL_ENV'] = 'staging'
const calculatedEnv = calculateCypressInternalEnv()
expect(calculatedEnv).to.eq('staging')
})
})
context('uses package.json env', () => {
it('is production', () => {
pkg.env = 'production'
const calculatedEnv = calculateCypressInternalEnv()
expect(calculatedEnv).to.eq('production')
})
it('is staging', () => {
pkg.env = 'staging'
const calculatedEnv = calculateCypressInternalEnv()
expect(calculatedEnv).to.eq('staging')
})
it('is test', () => {
pkg.env = 'test'
const calculatedEnv = calculateCypressInternalEnv()
expect(calculatedEnv).to.eq('test')
})
})
context('it uses development by default', () => {
beforeEach(() => {
return sinon.stub(fs, 'readJsonSync').returns({})
})
it('is development', () => {
const calculatedEnv = calculateCypressInternalEnv()
expect(calculatedEnv).to.eq('development')
})
})
})
describe('configureLongStackTraces', () => {
beforeEach(() => {
sinon.stub(Promise, 'config')
})
afterEach(() => {
Promise.config.restore()
})
it('configures long stack traces if "development" is passed in as the environment', () => {
configureLongStackTraces('development')
expect(Error.stackTraceLimit).to.eq(Infinity)
expect(Promise.config).to.have.been.calledWith({
cancellation: true,
longStackTraces: true,
})
})
it('disables long stack traces in bluebird if value other than "development" is passed in as the environment', () => {
configureLongStackTraces('production')
expect(Error.stackTraceLimit).to.eq(Infinity)
expect(Promise.config).to.have.been.calledWith({
cancellation: true,
longStackTraces: false,
})
})
})
})