YOU54F / cypress-plugins

A home for various Cypress Plugins

Home Page:https://cypress-plugins.saf.dev/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Cannot read property 'suites' of undefined

you1anna opened this issue · comments

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.

Finally got it working in CI, thanks man!

SLACK_WEBHOOK_URL was not set properly as an env variable.