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

Fix false positive when using chai-as-promised #5

Merged
merged 1 commit into from
Oct 9, 2020

Conversation

fflorent
Copy link

@fflorent fflorent commented Oct 9, 2020

The issue

When we use both chai-as-promised and chai-xml, chai-xml inhibits the behavior of chai-as-promised with the eventually keyword.

eventually has to be used in a return statement so we can test the promise result.

Steps to reproduce

  1. Download the attached project: foo.zip
  2. Unzip and inside the foo/ folder, run npm install
  3. Run the below command:
$ ./node_modules/mocha/bin/mocha ./index-spec.js

Actual Result

  Fancy describe
    ✓ should fail
(node:9563) UnhandledPromiseRejectionWarning: AssertionError: expected 4 to equal 3
    at /tmp/foo/node_modules/chai-as-promised/lib/chai-as-promised.js:302:22
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
    ....

Expected result

(You can comment chai.use(require("chai-xml")); in index-spec.js to see the expected result)

  Fancy describe
    1) should fail


  0 passing (6ms)
  1 failing

  1) Fancy describe
       should fail:

      AssertionError: expected 4 to equal 3
      + expected - actual

      -4
      +3
      
      at /tmp/foo/node_modules/chai-as-promised/lib/chai-as-promised.js:302:22

Explanation of the patch

Simply use the return statement to make a clean by-pass to other hooks.

@krampstudio krampstudio merged commit 2c18a93 into krampstudio:master Oct 9, 2020
@krampstudio
Copy link
Owner

@fflorent I've included it in the version 0.4.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants