acvetkov / sinon-chrome

Testing chrome extensions with Node.js

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

`calledWith(sinon.match(...))` matcher fails even when `calledWithMatch` passes

melink14 opened this issue · comments

dependabot recently tried upgraded my sinon from 7.5 to 11.1 and I was surprised when my tests started failing.

Because they fail when I use native or chai sinon assertions but they don't fail if I use a normal sinon.spy() spy, I thought I would file an issue here. (Especially since the sinon inside of sinon-chrome is quite a bit older than 11.1)

Details:
Assertion:

      expect(chrome.runtime.sendMessage).to.be.calledWith(
        //chrome.runtime.sendMessage.calledWith(
        sinon.match({
          type: 'xsearch',
          text: '先生test',
        })
      );

This fails with:

expected sendMessage to have been called with arguments match(type: xsearch, text: 先生test)
{ dictOption: "2", text: "先生test", type: "xsearch" } match(type: xsearch, text: 先生test)

If I swap the commented lines then it works great (and it also worked with sinon 7.5). This might be expected given sinon-chrome's support level but it seems odd that it works in some cases but not in others.