I'd like to execute a test where I know my argument will be one of two options.
Ideally something like so:
expect(getFormSpy).toBeCalledWith('option1' || 'option2');
However it seems the OR is not supported and jest is expecting option1 each time. Is there a way to make sure that jest allows both options?
Thanks!
CodePudding user response:
Solved! You can add an OR inside the function call itself if you use expect.stringMatching()
expect(getFormSpy).toBeCalledWith(expect.stringMatching('option1' || 'option2'));