Skip to content

Commit

Permalink
use node:test instead of tap (#302)
Browse files Browse the repository at this point in the history
* test: use node:test instead of tap

* test(coverage): provide coverage reporting with c8

* fix: drops istanbul coverage ignore if directive
  • Loading branch information
big-kahuna-burger authored Jul 15, 2024
1 parent 141b33b commit fe97a11
Show file tree
Hide file tree
Showing 10 changed files with 766 additions and 728 deletions.
14 changes: 14 additions & 0 deletions .c8rc
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"all": true,
"exclude": [
"test/",
"coverage/",
"types/"
],
"clean": true,
"check-coverage": true,
"branches": 100,
"lines": 100,
"functions": 100,
"statements": 100
}
3 changes: 0 additions & 3 deletions .taprc

This file was deleted.

10 changes: 5 additions & 5 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ const recommendedDefaultBrotliOptions = {
}

function processCompressParams (opts) {
/* istanbul ignore next */
/* c8 ignore next 3 */
if (!opts) {
return
}
Expand Down Expand Up @@ -148,7 +148,7 @@ function processCompressParams (opts) {
params.uncompressStream = {
// Currently params.uncompressStream.br() is never called as we do not have any way to autodetect brotli compression in `fastify-compress`
// Brotli documentation reference: [RFC 7932](https://www.rfc-editor.org/rfc/rfc7932)
br: /* istanbul ignore next */ () => ((opts.zlib || zlib).createBrotliDecompress || zlib.createBrotliDecompress)(params.brotliOptions),
br: /* c8 ignore next */ () => ((opts.zlib || zlib).createBrotliDecompress || zlib.createBrotliDecompress)(params.brotliOptions),
gzip: () => ((opts.zlib || zlib).createGunzip || zlib.createGunzip)(params.zlibOptions),
deflate: () => ((opts.zlib || zlib).createInflate || zlib.createInflate)(params.zlibOptions)
}
Expand All @@ -165,7 +165,7 @@ function processCompressParams (opts) {
}

function processDecompressParams (opts) {
/* istanbul ignore next */
/* c8 ignore next 3 */
if (!opts) {
return
}
Expand Down Expand Up @@ -525,8 +525,8 @@ function zipStream (deflate, encoding) {
function unzipStream (inflate, maxRecursion) {
if (!(maxRecursion >= 0)) maxRecursion = 3
return peek({ newline: false, maxBuffer: 10 }, function (data, swap) {
/* istanbul ignore if */
// This path is never taken, when `maxRecursion` < 0 it is automatically set back to 3
/* c8 ignore next */
if (maxRecursion < 0) return swap(new Error('Maximum recursion reached'))
switch (isCompressed(data)) {
case 1: return swap(null, pumpify(inflate.gzip(), unzipStream(inflate, maxRecursion - 1)))
Expand Down Expand Up @@ -555,7 +555,7 @@ function createError (code, message, statusCode) {

FastifyCompressError.prototype[Symbol.toStringTag] = 'Error'

/* istanbul ignore next */
/* c8 ignore next 3 */
FastifyCompressError.prototype.toString = function () {
return `${this.name} [${this.code}]: ${this.message}`
}
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@
"@typescript-eslint/eslint-plugin": "^7.6.0",
"@typescript-eslint/parser": "^7.6.0",
"adm-zip": "^0.5.12",
"c8": "^10.1.2",
"fastify": "^5.0.0-alpha.3",
"jsonstream": "^1.0.3",
"standard": "^17.1.0",
"tap": "^18.7.2",
"tsd": "^0.31.0",
"typescript": "^5.4.5"
},
Expand All @@ -34,8 +34,8 @@
"lint:fix:typescript": "npm run lint:fix -- --parser @typescript-eslint/parser --plugin @typescript-eslint/eslint-plugin \"**/*.d.ts\"",
"test": "npm run test:unit && npm run test:typescript",
"test:typescript": "tsd",
"test:unit": "tap",
"test:coverage": "npm run test:unit -- --coverage-report=html",
"test:unit": "node --test",
"test:coverage": "c8 node --test && c8 report --reporter=html",
"test:unit:verbose": "npm run test:unit -- -Rspec"
},
"keywords": [
Expand Down
Loading

0 comments on commit fe97a11

Please sign in to comment.