Therefore, let's add coverage scripts for integration and E2E tests:
"test:coverage": "nyc --reporter=html --reporter=text yarn run test",
"test:integration:coverage": "nyc --reporter=html --reporter=text yarn run test:integration",
"test:e2e:coverage": "nyc --reporter=html --reporter=text yarn run test:e2e",
However, when we run the test:e2e:coverage script, the coverage report shows results for compiled files in the dist/ directory, rather than the source files from src/. This is because our E2E test script (scripts/e2e.test.sh) is running the serve npm script, which transpiles our code before running it. To fix this, let's add a new test:serve script, which uses babel-node to directly run our code:
"test:serve": "dotenv -e envs/test.env -e envs/.env babel-node src/index.js",
Then, update scripts/e2e.test.sh to use this modified script instead of serve:
yarn run test:serve &
Now, when we run the test:coverage or test:e2e:coverage again, it will show coverage for files under src/ instead of dist/.