Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HTTP interceptor request match by body #12

Closed
3 tasks done
diego-aquino opened this issue Jan 8, 2024 · 0 comments · Fixed by #108
Closed
3 tasks done

HTTP interceptor request match by body #12

diego-aquino opened this issue Jan 8, 2024 · 0 comments · Fixed by #108
Assignees
Labels
feature New feature or request
Milestone

Comments

@diego-aquino
Copy link
Member

diego-aquino commented Jan 8, 2024

  • The HTTP request tracker should support:
    • Defining a body to match requests
    • Receiving a second, optional argument to whether the match should be exact or not (default: false)
      const creationTracker = authInterceptor
        .post('/users')
        .with({
          body: creationPayload,
        }, { exact: true })
        .respond({
          status: 201,
          body: user,
        });
@diego-aquino diego-aquino changed the title HTTP interceptor request match by minimum body HTTP interceptor request match by body Jan 8, 2024
@diego-aquino diego-aquino added the feature New feature or request label Jan 8, 2024
@diego-aquino diego-aquino added this to the v0.2.0 milestone Jan 8, 2024
@diego-aquino diego-aquino self-assigned this Feb 9, 2024
@diego-aquino diego-aquino removed their assignment Feb 20, 2024
@diego-aquino diego-aquino modified the milestones: v0.2.0, v0.4.0, v0.3.0 Feb 20, 2024
@diego-aquino diego-aquino self-assigned this Mar 12, 2024
diego-aquino added a commit that referenced this issue Mar 17, 2024
### Features
- [#zimic] Added support to restrict request trackers by body.

```ts
const creationTracker = authInterceptor
  .post('/users')
  .with({
    body: creationPayload,
  })
  .respond((request) => {
    const user: User = {
      id: crypto.randomUUID(),
      name: request.body.name,
      email: request.body.email,
    };

    return {
      status: 201,
      body: user,
    };
  });

const response = await createUser(creationPayload);
expect(response.status).toBe(201);
```

### Refactoring
- [#zimic] Simplified request and response body schemas.
- Unified `HttpInterceptorSchema.RequestBody` and
`HttpInterceptorSchema.ResponseBody` into `HttpInterceptorSchema.Body`,
as the previous `RequestBody` and `ResponseBody` had the same semantics.
- [#zimic] Improved HTTP interceptor test scenarios, following
real-world cases more closely for each method.
Closes #12.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

1 participant