Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ce3ab55

Browse files
jennifer-shehanebrian-mann
authored andcommitted
bump dep mocha-junit-reporter from ^1.13.0 to 1.17.0 (cypress-io#2224)
- address cypress-io#2221 - fixes cypress-io#1357 - fixes cypress-io#1348 - [x] update test to test `testCaseSwitchClassnameAndName` reporter option https://github.com/cypress-io/cypress/blob/issue-2221/packages/server/test/e2e/reporters_spec.coffee#L38
1 parent 0a4740a commit ce3ab55

20 files changed

+301
-216
lines changed

cli/__snapshots__/cypress_spec.js

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,4 @@
1-
exports['cypress .run normalizes config object 1'] = {
2-
"config": "pageLoadTime=10000,watchForFileChanges=false"
3-
}
4-
5-
exports['cypress .run normalizes env option if passed an object 1'] = {
6-
"env": "foo=bar"
7-
}
8-
9-
exports['cypress .run normalizes env option if passed an object with multiple properties 1'] = {
10-
"env": "foo=bar,another=one"
11-
}
12-
131
exports['cypress .run resolves with contents of tmp file 1'] = {
142
"code": 0,
153
"failingTests": []
164
}
17-
18-
exports['cypress .open normalizes config object 1'] = {
19-
"config": "pageLoadTime=10000,watchForFileChanges=false"
20-
}

cli/__snapshots__/util_spec.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,23 @@ exports['env_as_string 1'] = {
33
}
44

55
exports['env_as_object 1'] = {
6-
"env": "foo=bar,magicNumber=1234,host=kevin.dev.local"
6+
"env": "{\"foo\":\"bar\",\"magicNumber\":1234,\"host\":\"kevin.dev.local\"}"
77
}
88

99
exports['config_as_object 1'] = {
10-
"config": "baseUrl=http://localhost:2000,watchForFileChanges=false"
10+
"config": "{\"baseUrl\":\"http://localhost:2000\",\"watchForFileChanges\":false}"
1111
}
1212

1313
exports['reporter_options_as_object 1'] = {
14-
"reporterOptions": "mochaFile=results/my-test-output.xml,toConsole=true"
14+
"reporterOptions": "{\"mochaFile\":\"results/my-test-output.xml\",\"toConsole\":true}"
1515
}
1616

1717
exports['others_unchanged 1'] = {
1818
"foo": "bar"
1919
}
2020

2121
exports['spec_as_array 1'] = {
22-
"spec": "a,b,c"
22+
"spec": "[\"a\",\"b\",\"c\"]"
2323
}
2424

2525
exports['spec_as_string 1'] = {

cli/lib/util.js

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -17,26 +17,13 @@ const logger = require('./logger')
1717
const debug = require('debug')('cypress:cli')
1818

1919
const getosAsync = Promise.promisify(getos)
20-
const joinWithEq = (x, y) => `${x}=${y}`
2120

22-
// converts an object (single level) into
23-
// key1=value1,key2=value2,...
24-
const objectToString = (obj) =>
25-
R.zipWith(joinWithEq, R.keys(obj), R.values(obj)).join(',')
26-
27-
const normalizeObject = (env) =>
28-
_.isPlainObject(env) ? objectToString(env) : env
29-
30-
const normalizeArray = (arr) =>
31-
_.isArray(arr) ? arr.join(',') : arr
21+
const stringify = (val) => {
22+
return _.isObject(val) ? JSON.stringify(val) : val
23+
}
3224

3325
function normalizeModuleOptions (options = {}) {
34-
return R.evolve({
35-
env: normalizeObject,
36-
config: normalizeObject,
37-
reporterOptions: normalizeObject,
38-
spec: normalizeArray,
39-
})(options)
26+
return _.mapValues(options, stringify)
4027
}
4128

4229
function stdoutLineMatches (expectedLine, stdout) {

cli/test/lib/cypress_spec.js

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ describe('cypress', function () {
2525
}
2626

2727
it('calls open#start, passing in options', function () {
28-
cypress.open({ foo: 'foo' })
28+
return cypress.open({ foo: 'foo' })
2929
.then(getStartArgs)
3030
.then((args) => {
3131
expect(args.foo).to.equal('foo')
@@ -37,9 +37,12 @@ describe('cypress', function () {
3737
pageLoadTime: 10000,
3838
watchForFileChanges: false,
3939
}
40-
cypress.open({ config })
40+
41+
return cypress.open({ config })
4142
.then(getStartArgs)
42-
.then(snapshot)
43+
.then((args) => {
44+
expect(args).to.deep.eq({ config: JSON.stringify(config) })
45+
})
4346
})
4447
})
4548

@@ -66,44 +69,45 @@ describe('cypress', function () {
6669
return normalizeCallArgs(getCallArgs(run.start))
6770
}
6871

69-
it('calls run#start, passing in options', () =>
70-
cypress.run({ foo: 'foo' })
72+
it('calls run#start, passing in options', () => {
73+
return cypress.run({ spec: 'foo' })
7174
.then(getStartArgs)
7275
.then((args) => {
73-
expect(args.foo).to.equal('foo')
76+
expect(args.spec).to.equal('foo')
7477
})
75-
)
78+
})
7679

7780
it('normalizes config object', () => {
7881
const config = {
7982
pageLoadTime: 10000,
8083
watchForFileChanges: false,
8184
}
85+
8286
return cypress.run({ config })
8387
.then(getStartArgs)
84-
.then(snapshot)
88+
.then((args) => {
89+
expect(args).to.deep.eq({ config: JSON.stringify(config) })
90+
})
8591
})
8692

87-
it('normalizes env option if passed an object', () =>
88-
cypress.run({ env: { foo: 'bar' } })
89-
.then(getStartArgs)
90-
.then(snapshot)
91-
)
93+
it('normalizes env option if passed an object', () => {
94+
const env = { foo: 'bar', another: 'one' }
9295

93-
it('normalizes env option if passed an object with multiple properties', () =>
94-
cypress.run({ env: { foo: 'bar', another: 'one' } })
96+
return cypress.run({ env })
9597
.then(getStartArgs)
96-
.then(snapshot)
97-
)
98+
.then((args) => {
99+
expect(args).to.deep.eq({ env: JSON.stringify(env) })
100+
})
101+
})
98102

99103
it('gets random tmp file and passes it to run#start', function () {
100104
return cypress.run().then(() => {
101105
expect(run.start.lastCall.args[0].outputPath).to.equal(outputPath)
102106
})
103107
})
104108

105-
it('resolves with contents of tmp file', () =>
106-
cypress.run().then(snapshot)
107-
)
109+
it('resolves with contents of tmp file', () => {
110+
return cypress.run().then(snapshot)
111+
})
108112
})
109113
})

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@
9898
"make-empty-github-commit": "^1.2.0",
9999
"mocha": "^3.5.0",
100100
"mocha-banner": "^1.1.1",
101-
"mocha-junit-reporter": "^1.13.0",
101+
"mocha-junit-reporter": "1.17.0",
102102
"mocha-multi-reporters": "^1.1.5",
103103
"obfuscator": "^0.5.4",
104104
"parse-github-repo-url": "^1.4.1",
@@ -140,4 +140,4 @@
140140
"spies",
141141
"stubs"
142142
]
143-
}
143+
}

packages/server/lib/config.coffee

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -145,27 +145,6 @@ validationRules = {
145145
watchForFileChanges: v.isBoolean
146146
}
147147

148-
toArrayFromPipes = (str) ->
149-
if _.isArray(str)
150-
return str
151-
152-
[].concat(str.split('|'))
153-
154-
toObjectFromPipes = (str) ->
155-
if _.isObject(str)
156-
return str
157-
158-
## convert foo=bar|version=1.2.3 to
159-
## {foo: 'bar', version: '1.2.3'}
160-
_
161-
.chain(str)
162-
.split("|")
163-
.map (pair) ->
164-
pair.split("=")
165-
.fromPairs()
166-
.mapValues(coerce)
167-
.value()
168-
169148
convertRelativeToAbsolutePaths = (projectRoot, obj, defaults = {}) ->
170149
_.reduce folders, (memo, folder) ->
171150
val = obj[folder]
@@ -262,12 +241,6 @@ module.exports = {
262241
config.cypressEnv = process.env["CYPRESS_ENV"]
263242
delete config.envFile
264243

265-
if hosts = config.hosts
266-
config.hosts = toObjectFromPipes(hosts)
267-
268-
if blacklistHosts = config.blacklistHosts
269-
config.blacklistHosts = toArrayFromPipes(blacklistHosts)
270-
271244
## when headless
272245
if config.isTextTerminal
273246
## dont ever watch for file changes

packages/server/lib/cypress.coffee

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ _ = require("lodash")
1313
cp = require("child_process")
1414
path = require("path")
1515
Promise = require("bluebird")
16-
debug = require('debug')('cypress:server:cypress')
16+
debug = require("debug")("cypress:server:cypress")
1717

1818
exit = (code = 0) ->
1919
## TODO: we shouldn't have to do this
@@ -125,48 +125,44 @@ module.exports = {
125125
## else determine the mode by
126126
## the passed in arguments / options
127127
## and normalize this mode
128-
switch
128+
mode = switch
129129
when options.version
130-
options.mode = "version"
130+
"version"
131131

132132
when options.smokeTest
133-
options.mode = "smokeTest"
133+
"smokeTest"
134134

135135
when options.returnPkg
136-
options.mode = "returnPkg"
136+
"returnPkg"
137137

138138
when options.logs
139-
options.mode = "logs"
139+
"logs"
140140

141141
when options.clearLogs
142-
options.mode = "clearLogs"
142+
"clearLogs"
143143

144144
when options.getKey
145-
options.mode = "getKey"
145+
"getKey"
146146

147147
when options.generateKey
148-
options.mode = "generateKey"
148+
"generateKey"
149149

150150
when options.exitWithCode?
151-
options.mode = "exitWithCode"
151+
"exitWithCode"
152152

153153
when options.runProject
154154
## go into headless mode when running
155155
## until completion + exit
156-
options.mode = "run"
156+
"run"
157157

158158
else
159159
## set the default mode as interactive
160-
options.mode ?= "interactive"
161-
162-
## remove mode from options
163-
mode = options.mode
164-
options = _.omit(options, "mode")
160+
options.mode or "interactive"
165161

166162
@startInMode(mode, options)
167163

168164
startInMode: (mode, options) ->
169-
debug("start in mode %s with options %j", mode, options)
165+
debug("starting in mode %s", mode)
170166

171167
switch mode
172168
when "version"

packages/server/lib/saved_state.coffee

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ normalizeAndWhitelistSet = (set, key, value) ->
3737

3838
set(_.pick(valueObject, whitelist))
3939

40-
findSavedState = (projectRoot, isTextTerminal) ->
40+
module.exports = (projectRoot, isTextTerminal) ->
4141
if isTextTerminal
4242
debug("noop saved state")
4343
return Promise.resolve(FileUtil.noopFile)
@@ -57,5 +57,3 @@ findSavedState = (projectRoot, isTextTerminal) ->
5757

5858
stateFiles[fullStatePath] = stateFile
5959
stateFile
60-
61-
module.exports = findSavedState

0 commit comments

Comments
 (0)