I created a plain @nrwl/express project with an empty web server server.ts:
const express = require('express')
const app = express()
app.get('/', (req, res) => {
res.json({status: 'OK'})
});
var server = app.listen(3000);
module.exports = { server }
Whenever I add one a test file such as something.test.ts:
const { server } = require('../server');
describe('TEST: /', () => {
it('Should work just fine', async () => {
// all ok
});
});
export {};
Then ng serve express starts complaining because it tries to process the test files:
TS2593: Cannot find name 'describe'. Do you need to install type definitions for a test runner?
Try `npm i @types/jest` or `npm i @types/mocha` and then add `jest` or `mocha` to the types
field in your tsconfig.
What is the correct way to solve this? I don't necessarily want to add test libraries as a runtime dependency because test files shouldn't be bundled in the build IMO.