Cannot read property 'suites' of undefined
you1anna opened this issue · comments
Robin Miklinski commented
Hi @YOU54F
I'm getting an error using this config:
gocd-test:
source .env && rm -rf ./cypress/reports/ && yarn cy:run:pr && npx cypress-slack-reporter --ci-provider custom --custom-url "https://gocd.com" --vcs-provider bitbucket --report-dir '.' --verbose true
Output
✨ Done in 152.92s.
ciProvider:- custom
customUrl:- https://gocd.com
vcsProvider:- bitbucket
reportDirectory:- .
videoDirectory:- cypress/videos
screenshotDirectory:- cypress/screenshots
{"level":40,"time":1614963391577,"pid":12750,"hostname":"UK04128","msg":"Multiple html reports found & cannot determine filename, omitting html report from message"}
{"level":40,"time":1614963391683,"pid":12750,"hostname":"UK04128","msg":"Multiple json reports found, please run mochawesome-merge to provide a single report, using first report for test status"}
/Users/robin/rg/cypress-web-tests/node_modules/cypress-slack-reporter/bin/slack/slack-alert.js:161
throw new Error(e);
^
Error: TypeError: Cannot read property 'suites' of undefined
at Object.exports.slackRunner (/Users/robin/rg/cypress-web-tests/node_modules/cypress-slack-reporter/bin/slack/slack-alert.js:161:15)
at runMicrotasks (<anonymous>)
at processTicksAndRejections (node:internal/process/task_queues:94:5)
npm ERR! code 1
npm ERR! path /Users/robin/rg/cypress-web-tests
npm ERR! command failed
npm ERR! command sh -c cypress-slack-reporter "--ci-provider" "custom" "--custom-url" "https://gocd.com" "--vcs-provider" "bitbucket" "--report-dir" "." "--verbose" "true"
Using the || operator, the tests run but cypress-slack-reporter does not get executed
source .env && rm -rf ./cypress/reports/ && yarn cy:run:pr || npx cypress-slack-reporter --ci-provider custom --custom-url "https://gocd.com" --vcs-provider bitbucket --report-dir '.' --verbose true
The .env file contains
export SLACK_WEBHOOK_FAILED_URL=https://hooks.slack.com/services/xxx
export SLACK_WEBHOOK_PASSED_URL=https://hooks.slack.com/services/xxx
export BUILD_DISPLAY_NAME=#2991
export BUILD_ID=2991
export BUILD_NUMBER=2991
export BUILD_TAG=DEPLOY-staging-api-2991
export BUILD_URL=https://gocd.com
... etc
So it would be good to get some help on why the first command (using &&) is failing. Thanks.
Yousaf Nabi commented
Hey dude,
I think you need to run mochawesome-merge to consolidate your report into a
single file before the slack reporter can pick it up.
Regarding && || read
https://www.networkworld.com/article/3205148/unix-s-mysterious-andand-and.amp.html
&& will run if any of the commands before pass and || will run if any of
the commands fail.
In circleci I set my test reporting to run always in the run command
If that doesn’t help, if you can setup an example in the repo
cypress-slack-reporter-issues I can take a look!
Cheers
…On Fri, 5 Mar 2021 at 17:47, Robin Miklinski ***@***.***> wrote:
Hi @YOU54F <https://github.com/YOU54F>
I'm getting an error using this config:
gocd-test:
source .env && rm -rf ./cypress/reports/ && yarn cy:run:pr && npx cypress-slack-reporter --ci-provider custom --custom-url "https://gocd.com" --vcs-provider bitbucket --report-dir '.' --verbose true
Output
✨ Done in 152.92s.
ciProvider:- custom
customUrl:- https://gocd.com
vcsProvider:- bitbucket
reportDirectory:- .
videoDirectory:- cypress/videos
screenshotDirectory:- cypress/screenshots
{"level":40,"time":1614963391577,"pid":12750,"hostname":"UK04128","msg":"Multiple html reports found & cannot determine filename, omitting html report from message"}
{"level":40,"time":1614963391683,"pid":12750,"hostname":"UK04128","msg":"Multiple json reports found, please run mochawesome-merge to provide a single report, using first report for test status"}
/Users/robin/rg/cypress-web-tests/node_modules/cypress-slack-reporter/bin/slack/slack-alert.js:161
throw new Error(e);
^
Error: TypeError: Cannot read property 'suites' of undefined
at Object.exports.slackRunner (/Users/robin/rg/cypress-web-tests/node_modules/cypress-slack-reporter/bin/slack/slack-alert.js:161:15)
at runMicrotasks (<anonymous>)
at processTicksAndRejections (node:internal/process/task_queues:94:5)
npm ERR! code 1
npm ERR! path /Users/robin/rg/cypress-web-tests
npm ERR! command failed
npm ERR! command sh -c cypress-slack-reporter "--ci-provider" "custom" "--custom-url" "https://gocd.com" "--vcs-provider" "bitbucket" "--report-dir" "." "--verbose" "true"
Using the || operator, the tests run but cypress-slack-reporter does not
get executed
source .env && rm -rf ./cypress/reports/ && yarn cy:run:pr || npx cypress-slack-reporter --ci-provider custom --custom-url "https://gocd.com" --vcs-provider bitbucket --report-dir '.' --verbose true
The .env file contains
export SLACK_WEBHOOK_FAILED_URL=https://hooks.slack.com/services/xxx
export SLACK_WEBHOOK_PASSED_URL=https://hooks.slack.com/services/xxx
export BUILD_DISPLAY_NAME=#2991
export BUILD_ID=2991
export BUILD_NUMBER=2991
export BUILD_TAG=DEPLOY-staging-api-2991
export BUILD_URL=https://gocd.com
... etc
So it would be good to get some help on why the first command (using &&)
is failing. Thanks.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#973>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AEYCJ4J6VIBTSWNOKJQ7RKLTCEKL5ANCNFSM4YVT7QRA>
.
Robin Miklinski commented
Finally got it working in CI, thanks man!
SLACK_WEBHOOK_URL was not set properly as an env variable.