Lusito / mockzilla-webextension

A mocking toolkit for web-extensions leveraging the power of TypeScript to enhance your jest experience.

Home Page:https://lusito.github.io/mockzilla-webextension/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Dynamic expected value

Janaka-Steph opened this issue · comments

Hello,

I would like browser.storage.local.set() to be called with a testWallet object where walletId property is not known in advance. I tried to use expect.stringMatching(regex) in place of the property but it doesn't work.

const testWallet = {
  walletId: expect.stringMatching(/^[0-9A-F]{8}-[0-9A-F]{4}-4[0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$/i),
  confidentialAddresses: ['12323223'],
  encryptedMnemonic: 'uezyuyeuzyeze',
};
mockBrowser.storage.local.set.expect(testWallet).andResolve();

Any idea how I could achieve this?
Thank you

Sorry it actually works.