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

RejectedWith does not work with followup assertions #131

Closed
oravecz opened this issue Nov 30, 2015 · 2 comments
Closed

RejectedWith does not work with followup assertions #131

oravecz opened this issue Nov 30, 2015 · 2 comments

Comments

@oravecz
Copy link

oravecz commented Nov 30, 2015

I have a problem with rejectedWith() assertion when I combine it with additional assertions. For example, the following works:

    it( 'rejectedWith problems', function ( done ) {
        Promise.reject({ message: 'foo', value: 'bar' })
            .should.be.rejected.and.eventually.have.property('value', 'bar')
            .and.notify( done )
    } )

as does this:

    it( 'rejectedWith problems', function ( done ) {
        Promise.reject({ message: 'foo', value: 'bar' })
            .should.be.rejectedWith('foo')
            .and.notify( done )
    } )

However, if I combine the checks, it fails with the following error message:

    it( 'rejectedWith problems', function ( done ) {
        Promise.reject({ message: 'foo', value: 'bar' })
            .should.be.rejectedWith('foo').and.eventually.have.property('value', 'bar')
            .and.notify( done )
    } )

     TypeError: Cannot read property 'value' of undefined
      at null.<anonymous> (node_modules/chai/lib/chai/core/assertions.js:865:14)
      at ctx.(anonymous function) (node_modules/chai/lib/chai/utils/addMethod.js:40:25)
      at node_modules/chai-as-promised/lib/chai-as-promised.js:304:26
      at tryCatcher (node_modules/bluebird/js/release/util.js:11:23)
      at Promise._settlePromiseFromHandler (node_modules/bluebird/js/release/promise.js:488:31)
      at Promise._settlePromise (node_modules/bluebird/js/release/promise.js:545:18)
      at Promise._settlePromise0 (node_modules/bluebird/js/release/promise.js:590:10)
      at Promise._settlePromises (node_modules/bluebird/js/release/promise.js:673:18)
      at Async._drainQueue (node_modules/bluebird/js/release/async.js:125:16)
      at Async._drainQueues (node_modules/bluebird/js/release/async.js:135:10)
      at Immediate.Async.drainQueues [as _onImmediate] (node_modules/bluebird/js/release/async.js:16:14)

@glen-nicol
Copy link

I have a similar problem. However my code:

Promise.should.eventually.be.rejectedWith('BadRequest')
.and.eventually.have.property('message')
.that.should.equal('Get requires an identifier(cid) or a query(skip,size,order).')

throws this

AssertionError: expected { Object (__flags, then) } to equal 
'Get requires an identifier(cid) or a query(skip,size,order).'

if I use your method of property('prop', 'value') I get the same error:

TypeError: Cannot read property 'message' of undefined

@domenic
Copy link
Collaborator

domenic commented Aug 5, 2016

Duping against #113.

@domenic domenic closed this as completed Aug 5, 2016
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

No branches or pull requests

3 participants