lundi 29 juin 2020

Expecting 1, actual 0.9999999999999996 in NodeJS, Chai [duplicate]

I have a test with NodeJS / Chai:

it('#getSum', () => {
        const a = 6.77
        const b = 3.77
        const c = 1
        const d = 1
        const result = a - b - c - d
        const expected = 1
        expect(result).to.equal(expected)

    });

that fails telling me :

AssertionError: expected 0.9999999999999996 to equal 1
Expected :1
Actual   :0.9999999999999996

Why is it happening ? When I use my fingers, result is 1.

Aucun commentaire:

Enregistrer un commentaire