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

Integrate pactum E2E tests #99

Open
1 of 2 tasks
kk2491 opened this issue Jan 5, 2022 · 0 comments
Open
1 of 2 tasks

Integrate pactum E2E tests #99

kk2491 opened this issue Jan 5, 2022 · 0 comments

Comments

@kk2491
Copy link

kk2491 commented Jan 5, 2022

I'm submitting a ...

  • bug report
  • feature request

What is the current behavior?

Integrate pactum tests to generate the Swagger coverage report.
I have E2E tests written in Pactum, and want to generate coverage report for APIs using the Open API specification.
Could you please help me in in generating the coverage report for these tests.

"use strict";

const pactum = require("pactum");

describe("GET Test", () => {
    pactum.handler.addAssertHandler("isId", (ctx) => {
      return typeof ctx.data === "string";
    });
  
    pactum.handler.addAssertHandler("isTimeStamp", (ctx) => {
      var valid = new Date(ctx.data).getTime() > 0;
      return typeof ctx.data === "string" && valid == true;
    });
  
    pactum.handler.addAssertHandler("isBoolean", (ctx) => {
      var valid = new Date(ctx.data).getTime() > 0;
      return typeof ctx.data === "boolean";
    });
  
    it("test 1 ", async () => {
  
      let endpointUrl = "localhost:30303/v1/test/";
      const testdata = await pactum
        .spec()
        .post(endpointUrl)
        .withHeaders("x-api-key", xApiKey)
        .withJson({
          field1: "Field1",
          field2: "Field2"
        })
        // Response
        .expectStatus(201)
        .expectJsonLike({
            field1: "Field1",
            field2: "Field2"
        })
        .expectJsonSchema(testSchema);

    });
});

Could you please help me understanding how to save information of calls in swagger format?

If the current behavior is a bug, please provide steps to reproduce, broken swagger specification and swagger-coverage-output:

What is the expected behavior?

What is the motivation / use case for changing the behavior?

Generate coverage reports for the E2E tests written in pactum js.

Other information

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

No branches or pull requests

1 participant