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

[CI Failing]: Github Action passing even on test failures #3001

Closed
vaibhavsingh97 opened this issue Jan 20, 2022 · 1 comment · Fixed by #3039
Closed

[CI Failing]: Github Action passing even on test failures #3001

vaibhavsingh97 opened this issue Jan 20, 2022 · 1 comment · Fixed by #3039
Assignees
Labels

Comments

@vaibhavsingh97
Copy link
Member

Describe the bug

We use 'mocha' for unit tests. Currently, we have a Github action setup and whenever a failure occurs, Mocha exits with a 0 status code, so the GitHub action passes instead of failure.

Reason for failure

Seeing mocha exit with a 0 exit code after failing a test.

Related issues

🐛 mochajs/mocha#2713

Reference

Failed Build: https://github.com/nightwatchjs/nightwatch/runs/4854125616 (PR: #2995)
PR which fixes the issue: https://github.com/cypress-io/cypress/pull/5779/files

@swrdfish
Copy link
Member

When ever there is a failure, mocha sets an eventlistener on process.on(‘exit’) event to update the process.exitCode of the global process. Which normally, works but nightwatch also attaches an eventlistner on the exit event. This eventlistner in process-listners.js#L55 file terminates the process forcefully calling process.exit() hence the listener set by mocha does not even get a chance to execute.

Possible solutions:

  1. check if there are additional listeners and execute them before calling exit.
  2. try to attach the nightwatch listener after the mocha one is attached.
  3. do not call process.exit if not necessary let the process exit gracefully after the event queue is empty

swrdfish added a commit to swrdfish/nightwatch that referenced this issue Feb 3, 2022
swrdfish added a commit to swrdfish/nightwatch that referenced this issue Feb 7, 2022
swrdfish added a commit to swrdfish/nightwatch that referenced this issue Feb 8, 2022
@swrdfish swrdfish linked a pull request Feb 9, 2022 that will close this issue
8 tasks
swrdfish added a commit to swrdfish/nightwatch that referenced this issue Mar 25, 2022
beatfactor pushed a commit that referenced this issue Mar 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants