Last active
December 10, 2015 18:58
-
-
Save RubenVerborgh/4478480 to your computer and use it in GitHub Desktop.
Chai as Promised and Chai Things didn't work nicely together.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env mocha --compilers coffee:coffee-script --reporter spec | |
(require "mocha-as-promised")() | |
chai = require "chai" | |
Q = require "q" | |
chai.should() | |
chai.use require "chai-as-promised" | |
chai.use require "chai-things" | |
array = [{ a: 1 }, { b: 2 }] | |
arrayPromise = Q.resolve(array) | |
# include these tests to see the expected error messages | |
includeFailingTests = off | |
describe "The array", -> | |
it "should be an array", -> | |
array.should.be.an("array") # (1) | |
it "should contain something deep equal to { a: 1 }", -> | |
array.should.contain.something.that.deep.equals({ a: 1 }) # (2) | |
if includeFailingTests | |
it "should contain something deep equal to { a: 2 }", -> | |
array.should.contain.something.that.deep.equals({ a: 2 }) # (3) | |
describe "The array promise", -> | |
it "should eventually be an array", -> | |
arrayPromise.should.eventually.be.an("array") # (4) | |
it "should eventually contain something deep equal to { a: 1 }", -> | |
arrayPromise.should.eventually.contain.something.that.deep.equals({ a: 1 }) # (5) | |
if includeFailingTests | |
it "should eventually contain something deep equal to { a: 2 }", -> | |
arrayPromise.should.eventually.contain.something.that.deep.equals({ a: 2 }) # (6) |
The old version in which this problem occurred, has been updated to use a flag instead of a customized Assertion object, resolving the problem.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In this example, we'd expect assertion (5) to pass, but it fails with
This shows that Chai as Promised bypasses the
something
, since the message in case of failure should bewhich can be seen by setting
includeFailingTests
toon
.