My project setup process was quite simple, just followed these commands: npm i -g @nestjs/cli
nest new project-name npm install --save-dev mocha chai @types/mocha @types/chai
This is the structure of my package.json:
{
"name": "project-name",
"version": "0.0.1",
"description": "",
"author": "",
"private": true,
"license": "UNLICENSED",
...
The tsconfig.json file looks like this:
{
"compilerOptions": {
"module": "commonjs",
"declaration": true,
"removeComments": true,
...
The .mocharc.json configuration includes:
{
"extension": [
"ts"
],
"spec": "test/**/*.ts",
...
Here's an example code snippet from my CalculatorService:
export class CalculatorService {
add(a: number, b: number): number {
return a + b;
}
}
And the test case for the CalculatorService in calculator.service.spec.ts:
import { expect } from 'chai';
...
Error encountered while running npm test command.
If you'd like to contact me about this issue, please email me at [email protected]