Testing with Mocha and Chai consuming values from previous tests
Testing with Mocha and Chai consuming values from previous tests I have some tests created with mocha and chai using TypeScript , they actually work as expected. Each function returns a Promise which runs a test . mocha chai TypeScript Promise test My question is if is there anyway to consume on each test the value returned by a previous test without using the nesting you see below. test test My concern is that if I have more test the nesting code could be very annoying going to the right test import * as request from 'supertest'; import app from '../src/app'; import { Promise } from 'bluebird'; import * as dateformat from 'dateformat'; import Commons from '../../utils/commons'; import { expect } from 'chai'; ... // all the functions used below are defined over here ... registerNonExistingUser(email, pass, role).then( (jwtToken: string) => { authenticateUserCorrectJwt(jwtToken).then( (user) => { ...