idiot on ruby idiot on ruby - 2 months ago 25
Node.js Question

How to store the response body for further test case in supertest

I have an API /user/login which returns the token.

using supertest and mocha i wrote a test case where it will make a call to '/user/login' and verify that the response has a token or not

now i have to store the token for further token for further test case

How can i achieve that


I hope this example will help you.

describe("Example with token", function () {
  let token;

  before(function (done) {
    //getting token logic
    token = tokenValue;

  it("first test", function (done) {
      .set("TokenHeader", token)