Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Address issue #1495 by adding cypress spec name to mocha suite #3960

Merged
merged 13 commits into from
Jan 15, 2020
Merged
2 changes: 2 additions & 0 deletions packages/driver/src/cypress/mocha.js
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,8 @@ const create = (specWindow, Cypress, reporter) => {

const _runner = getRunner(_mocha)

_mocha.suite.file = Cypress.spec.relative

return {
_mocha,

Expand Down
2 changes: 1 addition & 1 deletion packages/driver/src/cypress/runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const TEST_AFTER_RUN_EVENT = 'runner:test:after:run'

const ERROR_PROPS = 'message type name stack fileName lineNumber columnNumber host uncaught actual expected showDiff isPending'.split(' ')
const RUNNABLE_LOGS = 'routes agents commands'.split(' ')
const RUNNABLE_PROPS = 'id title root hookName hookId err state failedFromHookId body speed type duration wallClockStartedAt wallClockDuration timings'.split(' ')
const RUNNABLE_PROPS = 'id title root hookName hookId err state failedFromHookId body speed type duration wallClockStartedAt wallClockDuration timings file'.split(' ')

// ## initial payload
// {
Expand Down
2 changes: 0 additions & 2 deletions packages/server/lib/reporter.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@ getParentTitle = (runnable, titles) ->
createSuite = (obj, parent) ->
suite = new Mocha.Suite(obj.title, {})
suite.parent = parent if parent
if obj.file
console.log('has file:', obj.file)
suite.file = obj.file
return suite

Expand Down
12 changes: 11 additions & 1 deletion packages/server/test/e2e/8_reporters_spec.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,16 @@ describe "e2e reporters", ->
reporter: "reporters/custom.js"
})

it "sends file to reporter", ->
e2e.exec(@, {
spec: "simple_passing_spec.coffee"
expectedExitCode: 0
reporter: "reporters/uses-file.js"
})
.get("stdout")
.then (stdout) ->
expect(stdout).to.include("suite.file: cypress/integration/simple_passing_spec.coffee")

describe "mochawesome", ->
mochaAwesomes.forEach (ma) ->
it "passes with #{ma} npm custom reporter", ->
Expand Down Expand Up @@ -113,4 +123,4 @@ describe "e2e reporters", ->
snapshot: true
reporter: "teamcity"
reporterOptions: "topLevelSuite=top suite,flowId=12345,useStdError='true',useStdError='true',recordHookFailures='true',actualVsExpected='true'"
})
})
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/* eslint-disable no-console */
module.exports = function Reporter (runner) {
runner.on('suite', function (suite) {
console.log('suite.file:', suite.file)
})
}