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

jest-environment: extend expect with custom expectations #83

Closed
Schniz opened this issue Aug 4, 2022 · 0 comments · Fixed by #164
Closed

jest-environment: extend expect with custom expectations #83

Schniz opened this issue Aug 4, 2022 · 0 comments · Fixed by #164
Labels
enhancement New feature or request

Comments

@Schniz
Copy link
Collaborator

Schniz commented Aug 4, 2022

We can enable users to have simpler tests by having expectations that match the standard library we provide. For instance, Response matchers:

expect(response).toHaveStatusCode(...);

// These expectations can be shared with `Request` too:
expect(response.headers).toMatchHeaders({ ... });
await expect(response).toHaveJsonBody({ ... });
await expect(response).toHaveTextBody("...");

// or in a single line
await expect(response).toMatchResponse({
  status: ...,
  headers: { ... },
  text: "{ ... }",
  json: {}
});

// streams?
await expect(response.body).toEmitChunk(new Uint8Array([...]));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants