what I did is create a test_helper.js:
import sinon from 'sinon'
import chai from 'chai'
import sinonChai from 'sinon-chai'
var expect = chai.expect
chai.use(sinonChai)
var supertest = require("supertest");
module.exports = {
sinon: sinon,
chai: chai,
expect: expect,
supertest: supertest
}
Then in your testing file:
import {sinon, chai, expect, supertest} from '../test_helper'
thanks @foxgaocn I'll using that. I dont know if this issue can remaind open until that supertest add ES6 support without using workarounds
Any updates on this?
Any updates on this?
why this has been closed?
I was able to use it with import * as request from 'supertest'; but with the ts esModuleInterop to true import request from 'supertest'; does not work, giving TypeError: request is not a function.
For now I'm doing import * as request = require('supertest'); so I get also the type definitions
Most helpful comment
why this has been closed?
I was able to use it with
import * as request from 'supertest';but with the ts esModuleInterop to trueimport request from 'supertest';does not work, givingTypeError: request is not a function.For now I'm doing
import * as request = require('supertest');so I get also the type definitions