Giter Club home page Giter Club logo

chai-roughly's People

Contributors

greenkeeperio-bot avatar turbo87 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

chai-roughly's Issues

Misleading error message when .roughly() assert fails

When using .roughly(), when a test (legitimately) fails, the error message is misleading. Here is an example:

const chai = require('chai');

const { expect } = chai;
chai.use(require('chai-roughly'));

describe('example test set', () => {
  it('example test', () => {
    const expected = { num1: 12.39197,   num2: 5, num3: 19 };
    const actual =   { num1: 12.3919725, num2: 5, num3: 17 };
    expect(actual).to.roughly(0.001).deep.equal(expected); // fails (which is correct)
  });

});

The issue isn't that the test fails. The issue is that the failure message looks like this:

      AssertionError: expected { num1: 12.3919725, num2: 5, num3: 17 } to roughly deeply equal { num1: 12.39197, num2: 5, num3: 19 }
      + expected - actual

       {
      -  "num1": 12.3919725
      +  "num1": 12.39197
         "num2": 5
      -  "num3": 17
      +  "num3": 19
       }

image

This makes it look like the different values for num1 are also part of the reason why it failed, but the only reason it failed is that the num3 values are not within range. If you edit the num3 values to match, the test no longer fails.

Unfork deep-eql?

We ran into some issues with our build today that came back chai-roughly depending on a forked version of deep-eql. Is it possible to un-fork deep-eql at this point? What was the reason for the fork?

cc @wittrock

TypeScript declarations

Nice work on this! It's a feature I've always thought was missing from Chai.

In case there are other TypeScript users out there, you can get this to type-check in TS by putting this in a chai-roughly.d.ts file somewhere:

declare module '~chai/lib/Assertion' {
  export interface Assertion {
    roughly: RoughAssertion;
  }

  interface RoughAssertion extends Assertion {
    (tolerance: number): Assertion;
  }
}

support for include

I need the same functionality but i need to use it with .include"operator". Can you provide some guidance on how to do it ? thank you.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.