question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Chai Assertion error doesn't have 'operator' attribute

See original GitHub issue

Hey everyone, I’m currently working on a feature in jest repo (https://github.com/facebook/jest/pull/8454). While I came across that output is as follows. (https://github.com/facebook/jest/pull/8454/files#diff-e6f1eef106ffd32cb2e65acae35856b8R7)

assert.(received, expected)

    Expected value   "hello sunshine"
    Received:
      "hello world"

    Message:
      expected 'hello world' to equal 'hello sunshine'

    Difference:

    - Expected
    + Received

    - hello sunshine
    + hello world

      11 | describe('chai.js assertion library test', () => {
      12 |   it('expect', () => {
    > 13 |     chai.expect('hello world').to.equal('hello sunshine');
         |                                   ^
      14 |   });
      15 | 
      16 |   it('should', () => {

      at Object.equal (__tests__/chai_assertion.js:13:35)

it is because of https://github.com/facebook/jest/blob/master/packages/jest-circus/src/formatNodeAssertErrors.ts#L127, unable to extract the operator. In https://nodejs.org/api/assert.html#assert_new_assert_assertionerror_options shows a property of operator.

is it this a bug or have I taken a wrong approach? Thanks a lot.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:7 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
SimenBcommented, Jun 3, 2019

assert.(received, expected) at the top, it should say assert.equal(received, expected) or some such

1reaction
rpgeeganagecommented, Jun 25, 2019
Read more comments on GitHub >

github_iconTop Results From Across the Web

API Reference - Chai Assertion Library
Asserts that object does not have a direct or inherited property named by property with value given by value . Uses a deep...
Read more >
how to assert in my tests that a Chai assertion will fail (Error vs ...
The reason is by doing import {AssertionError} from ... it is actually looking for an exported property of the package 'assertion-error', ...
Read more >
Assert - Chai
Asserts that object does not have a property named by property , which can be a string using dot- and bracket-notation for deep...
Read more >
Chai.js cheatsheet - Devhints
expect (x).to.be.equal(y) 〉 assert.equal(x, y) 〉 .to.be.true 〉 jQuery, assertions, TDD and BDD, and other Chai examples. · One-page guide to Chai.js.
Read more >
Node.js Assert Module - W3Schools
The assert module provides a way of testing expressions. If the expression evaluates to 0, or false, an assertion failure is being caused,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found