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

[api] Add integration tests using Jest and Supertest #321

Merged
merged 2 commits into from Feb 19, 2022
Merged

Conversation

koistya
Copy link
Member

@koistya koistya commented Feb 19, 2022

Testing GraphQL API field (example)

import request from "supertest";
import { api, db } from "../index";

test(`fetch user(username: "test01")`, async () => {
  const res = await request(api)
    .post("/api")
    .send({
      query: `#graphql
        query {
          user(username: "test01") { id email username }
        }
      `,
    })
    .expect(200)
    .expect("Content-Type", "application/json");

  expect(res.body).toMatchInlineSnapshot(`
    Object {
      "data": Object {
        "user": Object {
          "id": "VXNlcjp0ZXN0MDE=",
          "username": "test01",
          "email": null,
        },
      },
    }
  `);
});

@koistya koistya force-pushed the api-tests branch 18 times, most recently from 40e8a3e to 431625b Compare February 19, 2022 17:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant