testing-react icon indicating copy to clipboard operation
testing-react copied to clipboard

How to capture arguments to an action

Open sw-tracker opened this issue 2 years ago • 0 comments

Hi there,

We are currently using storybook 7. And we would like to validate the arguments with which some actions are called. However, the other of the items needs to match exactly if we use the code below and this is making testing very difficult.

    expect(args.onError).toHaveBeenCalledWith(
      'ERROR_CODE',
      ['someError', 'someOtherError']
    );

We would like to capture the arguments so we can test them easier. How can we do this?

Thanks!

sw-tracker avatar Aug 08 '23 12:08 sw-tracker