Skip to content

Commit

Permalink
fix: getResponseTime deprecation warning (#383)
Browse files Browse the repository at this point in the history
* fix: getResponseTime deprecation warning

* expose coverage lcov

* fix

* fix github action
  • Loading branch information
davidebianchi authored Aug 20, 2024
1 parent 616fe94 commit 351de8e
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 19 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,10 @@ jobs:
- run: npm test

- name: Coveralls
uses: coverallsapp/github-action@master
uses: coverallsapp/github-action@v2
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
file: ./.tap/report/lcov.info

publish:
runs-on: ubuntu-latest
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ coverage

# nyc test coverage
.nyc_output
.tap

# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Fixed

- use `reply.elapsedTime` instead of the deprecated `reply.getResponseTime()` to get the elapsed time of the request

## v8.0.1 - 2024-08-06

### Fixed
Expand Down
2 changes: 1 addition & 1 deletion lib/custom-logger.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ function logRequestCompleted(req, reply, next) {
forwardedHost: headers['x-forwarded-host'],
ip: headers['x-forwarded-for'],
},
responseTime: reply.getResponseTime(),
responseTime: reply.elapsedTime,
}, 'request completed')
next()
}
Expand Down
21 changes: 10 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@
},
"scripts": {
"checkonly": "! grep -R '\\.only' tests/",
"coverage": "npm run unit -- --coverage-report=text-summary",
"postcoverage": "tap --coverage-report=html --no-browser",
"coverage": "npm run unit -- --coverage-report=text-summary --coverage-report=lcov --no-browser",
"lint": "eslint . --ignore-path .gitignore",
"test": "npm run lint && npm run coverage && npm run test:types && npm run checkonly",
"unit": "tap -b -o tap.log tests/*.test.js",
Expand All @@ -44,27 +43,27 @@
"@fastify/sensible": "^5.5.0",
"@fastify/swagger": "^8.12.0",
"@fastify/swagger-ui": "^1.10.1",
"@opentelemetry/auto-instrumentations-node": "^0.48.0",
"@opentelemetry/sdk-node": "^0.49.1",
"@opentelemetry/sdk-trace-base": "^1.18.1",
"@opentelemetry/auto-instrumentations-node": "^0.49.1",
"@opentelemetry/sdk-node": "^0.52.1",
"@opentelemetry/sdk-trace-base": "^1.25.1",
"commander": "^11.1.0",
"dotenv": "^16.3.1",
"dotenv-expand": "^11.0.3",
"fastify": "^4.24.3",
"fastify": "^4.28.1",
"fastify-metrics": "^10.3.3",
"fastify-plugin": "^4.5.1",
"lodash.get": "^4.4.2",
"prom-client": "^14.2.0"
},
"devDependencies": {
"@mia-platform/eslint-config-mia": "^3.0.0",
"ajv": "^8.12.0",
"ajv": "^8.17.1",
"eslint": "^8.53.0",
"semver": "^7.5.4",
"semver": "^7.6.3",
"split2": "^4.2.0",
"swagger-parser": "^10.0.3",
"tap": "^16.3.7",
"tsd": "^0.30.4"
"tap": "^21.0.1",
"tsd": "^0.31.1"
},
"engines": {
"node": ">=14"
Expand All @@ -73,6 +72,6 @@
"extends": "@mia-platform/eslint-config-mia"
},
"tap": {
"check-coverage": false
"allow-incomplete-coverage": true
}
}
6 changes: 3 additions & 3 deletions tap-snapshots/tests/custom-logger.test.js.test.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* Make sure to inspect the output below. Do not ignore changes!
*/
'use strict'
exports[`tests/custom-logger.test.js TAP Test log serialize error both for error and err fields > must match snapshot 1`] = `
exports[`tests/custom-logger.test.js > TAP > Test log serialize error both for error and err fields > must match snapshot 1`] = `
Array [
Object {
"err": Object {
Expand All @@ -22,7 +22,7 @@ Array [
]
`

exports[`tests/custom-logger.test.js TAP Test redacted values - uppercase headers > must match snapshot 1`] = `
exports[`tests/custom-logger.test.js > TAP > Test redacted values - uppercase headers > must match snapshot 1`] = `
Array [
Object {
"headersToSend": Object {
Expand All @@ -33,7 +33,7 @@ Array [
]
`

exports[`tests/custom-logger.test.js TAP Test redacted values > must match snapshot 1`] = `
exports[`tests/custom-logger.test.js > TAP > Test redacted values > must match snapshot 1`] = `
Array [
Object {
"headers": Object {
Expand Down
6 changes: 3 additions & 3 deletions tap-snapshots/tests/documentation-routes.test.js.test.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* Make sure to inspect the output below. Do not ignore changes!
*/
'use strict'
exports[`tests/documentation-routes.test.js TAP Test Fastify creation with custom prefix > must match snapshot 1`] = `
exports[`tests/documentation-routes.test.js > TAP > Test Fastify creation with custom prefix > must match snapshot 1`] = `
Object {
"components": Object {
"schemas": Object {
Expand Down Expand Up @@ -204,7 +204,7 @@ Object {
}
`

exports[`tests/documentation-routes.test.js TAP Test Fastify creation with custom prefix without trailing slash > must match snapshot 1`] = `
exports[`tests/documentation-routes.test.js > TAP > Test Fastify creation with custom prefix without trailing slash > must match snapshot 1`] = `
Object {
"components": Object {
"schemas": Object {
Expand Down Expand Up @@ -410,7 +410,7 @@ Object {
}
`

exports[`tests/documentation-routes.test.js TAP Test Fastify creation with no prefix > must match snapshot 1`] = `
exports[`tests/documentation-routes.test.js > TAP > Test Fastify creation with no prefix > must match snapshot 1`] = `
Object {
"components": Object {
"schemas": Object {
Expand Down

0 comments on commit 351de8e

Please sign in to comment.