Skip to content
This repository was archived by the owner on Jun 11, 2020. It is now read-only.

Commit 2ca1f1b

Browse files
committed
Merge remote-tracking branch 'origin/custom-reporters'
2 parents 64817ff + 7553259 commit 2ca1f1b

File tree

4 files changed

+42
-25
lines changed

4 files changed

+42
-25
lines changed

lib/cli.coffee

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,17 @@ pkg = require("../package.json")
88
updater({pkg: pkg, updateCheckInterval: human("one hour")}).notify()
99

1010
parseOpts = (opts) ->
11-
_.pick(opts, "spec", "reporter", "path", "destination", "port", "env", "cypressVersion", "config")
11+
_.pick(opts, "spec", "reporter", "reporterOptions", "path", "destination", "port", "env", "cypressVersion", "config")
1212

1313
descriptions = {
14-
destination: "destination path to extract and install Cypress to"
15-
spec: "runs a specific spec file. defaults to 'all'"
16-
reporter: "runs a specific mocha reporter. pass a path to use a custom reporter. defaults to 'spec'"
17-
port: "runs Cypress on a specific port. overrides any value in cypress.json. defaults to '2020'"
18-
env: "sets environment variables. separate multiple values with a comma. overrides any value in cypress.json or cypress.env.json"
19-
config: "sets configuration values. separate multiple values with a comma. overrides any value in cypress.json."
20-
version: "installs a specific version of Cypress"
14+
destination: "destination path to extract and install Cypress to"
15+
spec: "runs a specific spec file. defaults to 'all'"
16+
reporter: "runs a specific mocha reporter. pass a path to use a custom reporter. defaults to 'spec'"
17+
reporterOptions: "options for the mocha reporter. defaults to 'null'"
18+
port: "runs Cypress on a specific port. overrides any value in cypress.json. defaults to '2020'"
19+
env: "sets environment variables. separate multiple values with a comma. overrides any value in cypress.json or cypress.env.json"
20+
config: "sets configuration values. separate multiple values with a comma. overrides any value in cypress.json."
21+
version: "installs a specific version of Cypress"
2122
}
2223

2324
text = (d) ->
@@ -57,23 +58,25 @@ module.exports = ->
5758
.command("run [project]")
5859
.usage("[project] [options]")
5960
.description("Runs Cypress Tests Headlessly")
60-
.option("-s, --spec <spec>", text("spec"))
61-
.option("-r, --reporter <reporter>", text("reporter"))
62-
.option("-p, --port <port>", text("port"))
63-
.option("-e, --env <env>", text("env"))
64-
.option("-c, --config <config>", text("config"))
61+
.option("-s, --spec <spec>", text("spec"))
62+
.option("-r, --reporter <reporter>", text("reporter"))
63+
.option("-o, --reporter-options <reporter-options>", text("reporterOptions"))
64+
.option("-p, --port <port>", text("port"))
65+
.option("-e, --env <env>", text("env"))
66+
.option("-c, --config <config>", text("config"))
6567
.action (project, opts) ->
6668
require("./commands/run")(project, parseOpts(opts))
6769

6870
program
6971
.command("ci [key]")
7072
.usage("[key] [options]")
7173
.description("Runs Cypress in CI Mode")
72-
.option("-s, --spec <spec>", text("spec"))
73-
.option("-r, --reporter <reporter>", text("reporter"))
74-
.option("-p, --port <port>", text("port"))
75-
.option("-e, --env <env vars>", text("env"))
76-
.option("-c, --config <config>", text("config"))
74+
.option("-s, --spec <spec>", text("spec"))
75+
.option("-r, --reporter <reporter>", text("reporter"))
76+
.option("-o, --reporter-options <reporter-options>", text("reporterOptions"))
77+
.option("-p, --port <port>", text("port"))
78+
.option("-e, --env <env vars>", text("env"))
79+
.option("-c, --config <config>", text("config"))
7780
.action (key, opts) ->
7881
require("./commands/ci")(key, parseOpts(opts))
7982

@@ -130,4 +133,4 @@ module.exports = ->
130133
## then display the help
131134
program.help()
132135

133-
return program
136+
return program

lib/commands/run.coffee

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,11 @@ class Run
88
return new Run(project, options)
99

1010
_.defaults options,
11-
key: null
12-
spec: null
13-
reporter: null
14-
project: path.resolve(process.cwd(), project)
11+
key: null
12+
spec: null
13+
reporter: null
14+
reporterOptions: null
15+
project: path.resolve(process.cwd(), project)
1516

1617
@run(options)
1718

@@ -36,11 +37,15 @@ class Run
3637
if options.reporter
3738
args.push("--reporter", options.reporter)
3839

40+
## if we have a specific reporter push that into the args
41+
if options.reporterOptions
42+
args.push("--reporter-options", options.reporterOptions)
43+
3944
## if we have a key assume we're in CI mode
4045
if options.key
4146
args.push("--ci", "--key", options.key)
4247
opts.xvfb = true
4348

4449
utils.spawn(args, opts)
4550

46-
module.exports = Run
51+
module.exports = Run

readme.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,11 @@ cypress run --port 8080
9696
cypress run --reporter json
9797
```
9898

99+
```bash
100+
## specify options for the mocha reporter
101+
cypress run --reporter-options mochaFile=result.xml,toConsole=true
102+
```
103+
99104
```bash
100105
## specify a spec to run instead of running all the tests
101106
cypress run --spec cypress/integration/app_spec.js

test/commands/ci_spec.coffee

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ describe "Ci", ->
1717
@parse("ci abc123 --reporter junit")
1818
expect(@spy).to.be.calledWith("abc123", {reporter: "junit"})
1919

20+
it "calls ci with reporter options", ->
21+
@parse("ci abc123 --reporter-options mochaFile=result.xml")
22+
expect(@spy).to.be.calledWith("abc123", {reporterOptions: "mochaFile=result.xml"})
23+
2024
it "calls with no key", ->
2125
@parse("ci")
2226
expect(@spy).to.be.calledWith(undefined)
@@ -144,4 +148,4 @@ describe "Ci", ->
144148
expect(@log).to.be.calledWith("Please provide us your project's secret key and then rerun.")
145149

146150
it "logs the env key we checked for", ->
147-
expect(@log).to.be.calledWithMatch(/\w+/, "CYPRESS_CI_KEY")
151+
expect(@log).to.be.calledWithMatch(/\w+/, "CYPRESS_CI_KEY")

0 commit comments

Comments
 (0)