Skip to content

Getting different results depending on how test is run #1

@JeffML

Description

@JeffML

I have this set up before my mocha tests:

import chai from 'chai';
import chaiAlmost from 'chai-almost';

// some test values are approximately equal to spreadsheet values; see NOTE on materialsCost()
const TOLERANCE = 0.0501;          // +/- cents
chai.use(chaiAlmost(TOLERANCE));

chai.should();
describe("quantity 1000, 4x1, black & blue, adh free=2", function () {...

And later I have an assertion:

    it('displayPrice', done => {
        instance.displayPrice(fakeContext)
        props.should.have.property('displayPrice');
        props.displayPrice.should.almost.equal(1953.19); 
        console.log({displayPrice: props.displayPrice})
        done();
    })

When running the test singly, the output is:

{ displayPrice: 1953.24 }
✓ displayPrice

43 passing (326ms)

However, when run the whole series of 8 test files, I see this:
2) quantity 1000, 4x1, black & blue, adh free=2

   displayPrice:

  AssertionError: expected 1953.24 to almost equal 1953.19
  + expected - actual

  -1953.24
  +1953.19

Not sure how that is possible.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions