Skip to content

chai-fs destroys any existing assertion handler for .with() #44

@bluepichu

Description

@bluepichu

In my case, this is causing issues with chai-spies. For example, this passes fine:

let spies = require("chai-spies");
let fs = require("chai-fs");
let chai = require("chai");

chai.use(fs).use(spies);

let { spy, expect } = chai;

it("should still let me use chai-spies' .with() assertions", async () => {
	let fn = spy((arg) => arg + 1);

	let x = fn(2);

	expect(x).to.equal(3);
	expect(fn).to.have.been.called.once;
	expect(fn).to.have.been.called.with(2);
});

But this fails:

let spies = require("chai-spies");
let fs = require("chai-fs");
let chai = require("chai");

chai.use(spies).use(fs); // <--- the only change is the order on this line

let { spy, expect } = chai;

it("should still let me use chai-spies' .with() assertions", async () => {
	let fn = spy((arg) => arg + 1);

	let x = fn(2);

	expect(x).to.equal(3);
	expect(fn).to.have.been.called.once;
	expect(fn).to.have.been.called.with(2);
});

Output:

  1) should still let me use chai-spies' .with() assertions:
     TypeError: expect(...).to.have.been.called.with is not a function
      at Context.it (spec.js:18:37)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions