angular/jasminewd

expect(<primitive>).toEqual(<promise>) no longer works

juliemr opened this issue · 2 comments

We should attempt to solve this situation as well, or at least better document failures.

For the record, the following all work:

expect(<primitive>).toEqual(<primitive>)
expect(<promise>).toEqual(<promise>)
expect(<promise>).toEqual(<primitive>)

If anyone stumbles upon this issue and needs a workaround, they may try wrapping every actual value in a promise.

// protractor-config.js
exports.config = {
  onPrepare: () => {
    const originalExpect = global.expect
    global.expect = (v) => originalExpect(Promise.resolve(v))
  }
} 

This seems to be fixed. Using protractor@5, the test

expect(1).toEqual(Promise.resolve(2))

correctly results in the error

Expected 1 to equal 2