Skip to content

Mock history #4025

Open
Open
@blephy

Description

This would solve...

When intercepting http call with MockAgent, we are not able to assert provided request configuration (body, querystring, headers etc...)

The implementation should look like...

fetch-mock can permit it this way :

beforeEach(() => {
 mockClient.resetHistory();
})

it('should ...', async () => {
 mockClient.intercept({
  path: '...',
  method: 'POST'
 })
 .reply(201, 'hello)
 .time(1)

 await fetch('...', {
  body: JSON.stringify({ value: 'hello' });
 })

 expect(mockClient.history.getCall(1).body).toMatchSnapshot()
})

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions