TypeScript-Node-Starter
TypeScript-Node-Starter copied to clipboard
async/await Jest tests
Hey everyone! This project has been a great help so far. I have been experimenting with tests a little bit and I couldn't get async tests to pass the compilation. I have something along the lines of:
describe("Model Test", () => {
beforeAll(async (done) => {
// Do stuff
});
And I get the following error:
TS2705: An async function or method in ES5/ES3 requires the Promise constructor. Make sure you have a declaration for the Promise constructor or include ES2015 in your --lib option.
And for completeness, my tsconfig looks something like this:
{
"compilerOptions": {
"module": "commonjs",
"esModuleInterop": true,
"target": "es6",
"noImplicitAny": true,
"moduleResolution": "node",
"resolveJsonModule": true,
"sourceMap": true,
"outDir": "dist",
"baseUrl": ".",
"lib": ["es2017"],
"paths": {
"*": [
"node_modules/*",
"src/types/*"
]
}
},
"include": [
"src/**/*",
"config/**/*.ts",
"index.ts"
]
}
So I guess the "es2017" setting in the "lib" parameter does not really have any effect.