Forum Discussion

supriyabarkund's avatar
3 years ago

Error after generating an Typescript Fetch API Client with Swagger Codegen

I'm trying out swagger for the first time and I generated typescript-fetch client via swagger-codegen which produced both client files and unit test .spec.ts files. I am using "Jest" as testing framework and when I'm running test cases with "npm test", getting below error


expect(received).resolves.toBe(expected) // equality

Expected: null
Received: {"activities": [{"activity_text": "string", "time_ago": "string"}]}

Below is the code where i get errors:


describe("ActivityApi", () => {
  let instance: api.ActivityApi
  beforeEach(function() {
    instance = new api.ActivityApi(config)

  test("usersActivitiesGet", () => {
    const jwt: string = "jwt_example"
    return expect(instance.usersActivitiesGet(jwt, {})).resolves.toBe(null)


Is this the expected behaviour?


What is the preferred way of running typescript-fetch-client generated code from swagger hub? How to run the specs from this file?

No RepliesBe the first to reply