Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: integrate nyc #69

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .babelrc
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,8 @@
"corejs": 3
}
]
],
"plugins": [
"babel-plugin-istanbul"
]
}
}
30 changes: 15 additions & 15 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
version: "3"
services:
app:
build:
context: .
args:
ENVIRONMENT_NAME: ${ENVIRONMENT_NAME}
dockerfile: Dockerfile
ports:
- "9000:9000"
env_file:
- .env.local
environment:
- REDIS_DOMAIN=redis
- MONGO_BASE_URI=mongo
depends_on:
- mongo
# app:
# build:
# context: .
# args:
# ENVIRONMENT_NAME: ${ENVIRONMENT_NAME}
# dockerfile: Dockerfile
# ports:
# - "9000:9000"
# env_file:
# - .env.local
# environment:
# - REDIS_DOMAIN=redis
# - MONGO_BASE_URI=mongo
# depends_on:
# - mongo

mongo:
container_name: mongo
Expand Down
2 changes: 1 addition & 1 deletion jest.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"!__tests__/__load__/libs/**/*.*"
],
"testRegex": "(/__tests__/.*\\.test)\\.js$",
"coverageReporters": ["json-summary", "text", "lcov"],
"coverageReporters": ["json", "text", "lcov"],
"testPathIgnorePatterns": ["<rootDir>/dist/"],
"moduleNameMapper": {
"@server(.*)$": "<rootDir>/server/$1",
Expand Down
31 changes: 27 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@
"description": "A basic starter web app with node, express and mongoose",
"main": "index.js",
"scripts": {
"test": "jest --coverage",
"e2eTest": "nyc node dist/main.js",
"covergae:total": "yarn coverage:merge && yarn coverage:report",
"coverage:report": "nyc report --reporter=lcov --reporter=text",
"coverage:merge": "mkdir -p ./coverage && nyc merge ./coverage .nyc_output/out.json",
"test": "jest --coverage --collectCoverageFrom='src/**/*.{js,jsx}'",
"start": "node dist/main.js",
"start:development": "ENVIRONMENT_NAME=development node dist/main.js",
"build:env": "webpack-cli --config webpack/production.config.js --stats-error-details",
Expand Down Expand Up @@ -75,7 +79,7 @@
"slack-notify": "^2.0.2",
"swagger-ui-express": "^4.3.0",
"uuid": "^8.3.2",
"webpack": "^5.74.0",
"webpack": "^5.91.0",
"webpack-hot-middleware": "^2.25.2"
},
"devDependencies": {
Expand All @@ -94,13 +98,32 @@
"jest-coverage-badges": "^1.1.2",
"link-module-alias": "^1.2.0",
"mockingoose": "^2.15.2",
"nyc": "^15.1.0",
"pre-commit": "^1.2.2",
"prettier": "^2.6.2",
"prettier-standard": "^16.4.1",
"regenerator-runtime": "^0.13.9",
"supertest": "^6.2.2",
"terser-webpack-plugin": "^5.3.6",
"webpack-cli": "^4.10.0"
"webpack-cli": "^5.1.4"
},
"nyc": {
"all": true,
"include": [
"server/**/**.js"
],
"exclude": [
"**/*.test.js"
],
"reporter": [
"lcov",
"text"
],
"extension": [
".js"
],
"sourceMap": true,
"instrument": true
},
"precommit": "lint:staged",
"lint-staged": {
Expand Down Expand Up @@ -129,4 +152,4 @@
"database": "./server/database",
"daos": "./server/daos"
}
}
}
20 changes: 19 additions & 1 deletion server/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,29 @@
});
list(app);

let server
if (process.env.NODE_ENV !== 'test') {

Check warning on line 57 in server/index.js

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement
const server = http.createServer(app);
server = http.createServer(app);

Check warning on line 58 in server/index.js

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🕹 Function is not covered

Warning! Not covered function
server.listen(app.get('port'), () => {

Check warning on line 59 in server/index.js

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement
log.info('Server is running at port %s', app.get('port'));

Check warning on line 60 in server/index.js

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement
});

Check warning on line 61 in server/index.js

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🌿 Branch is not covered

Warning! Not covered branch
}

function gracefulShutdown(signal) {
log.info(`${signal} received`);
if (server) {
server.close(() => {
log.info('HTTP server closed');
// Clean up other resources here
process.exit(0);
});
} else {
log.info('No server to shut down.');
process.exit(0);
}
}

process.on('SIGTERM', gracefulShutdown);
process.on('SIGINT', gracefulShutdown);

export default app;
Loading