0

I'm about to implement some API tests using Supertest and Typsecript. Problem is, I'm new to typescript. I've installed both superstest and @types/supertest from npm, but I'm not sure how I'm supposed to make reference to @types/supertest. In my below code, my DIE (VS Code) is not happy about "app" or "applicationJson".

import * as request from 'supertest';

getToken: async function(tokenUsername, tokenPassword) {
    return await request(app).post(
        `https://foobar/login`,
        { accept: applicationJson }, 
        {
            Email: tokenUsername,
            Password: tokenPassword,
        },
        envConfig.BaseUrl);
}

What on earth am I missing?

Huckleberry Carignan
  • 2,002
  • 4
  • 17
  • 33
  • Where _did_ you expect those things to be defined? app is supposed to be **your app**, which SuperTest can't be exporting. – jonrsharpe Oct 03 '22 at 18:30
  • hmm, so if I'm hitting an external endpoint - "app" would be not there? to request().post() ?? – Huckleberry Carignan Oct 03 '22 at 18:36
  • See https://stackoverflow.com/a/62992056/3001761 for the purpose of SuperTest, [the docs](https://www.npmjs.com/package/supertest) include how to hit an arbitrary URL. This isn't a types problem; your _values_ are undefined. – jonrsharpe Oct 03 '22 at 18:39

0 Answers0