У меня есть веб -сервер, изготовленный с Express.js , и я хочу проверить покрытие некоторого запроса, сделанного с Postman , но NYC не показывайте какую -либо строку в соответствии с запросами.├── package.json
├── .nycrc.json
└── index.js
files
package.json
{
"name": "test",
"version": "1.0.0",
"main": "index.js",
"scripts": {
"cover": "nyc node index.js",
},
"author": "",
"license": "ISC",
"description": "",
"dependencies": {
"express": "^5.1.0"
},
"devDependencies": {
"nyc": "^17.1.0"
}
}
< /code>
.nycrc.json
{
"all": true,
"check-coverage": false,
"extension": [
".js"
],
"include": [
"**/*.js"
],
"reporter": [
"text",
"lcov",
"html"
]
}
< /code>
index.js
import express from 'express';
const app = express();
app.get('/', (req, res) => {
res.status(200).send('Hello World');
});
app.listen(3000, () => {
console.log('Server started on: http://localhost:3000/');
});
шаги для воспроизведения
Запустите веб -сервер:
npm run cover
> test@1.0.0 cover
> nyc node index.js
Server started on: http://localhost:3000/
Откройте http: // localhost: 3000/в браузере. Вывод: < /p>
Hello World
Закройте терминал с помощью Ctrl + C , это окончательный вывод NYC:
----------|---------|----------|---------|---------|-------------------
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
----------|---------|----------|---------|---------|-------------------
All files | 0 | 100 | 0 | 0 |
index.js | 0 | 100 | 0 | 0 | 3-10
----------|---------|----------|---------|---------|-------------------
Подробнее здесь: https://stackoverflow.com/questions/795 ... -made-test