Skip to content

Commit 4be6468

Browse files
authored
chore: update tap@19 (fastify#5471)
* chore: update tap@18 * chore: tap@19 * chore: remove c8 * chore: remove ignore
1 parent a9a5568 commit 4be6468

10 files changed

+101
-51
lines changed

.c8rc.json

Lines changed: 0 additions & 8 deletions
This file was deleted.

.github/workflows/coverage-nix.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ jobs:
3333
if: ${{ success() }}
3434
with:
3535
name: coverage-report-nix
36-
path: ./coverage/lcov-report/
36+
path: ./.tap/report/
3737

3838
# Here, we verify the coverage thresholds so that this workflow can pass
3939
# or fail and stop further workflows if this one fails.

.github/workflows/coverage-win.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ jobs:
3333
if: ${{ success() }}
3434
with:
3535
name: coverage-report-win
36-
path: ./coverage/lcov-report/
36+
path: ./.tap/report/
3737

3838
# Here, we verify the coverage thresholds so that this workflow can pass
3939
# or fail and stop further workflows if this one fails.

.taprc

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
1-
ts: false
2-
jsx: false
3-
flow: false
4-
# the coverage is performed by c8
5-
check-coverage: false
6-
coverage: false
7-
node-arg: --allow-natives-syntax
1+
# vim: set filetype=yaml :
2+
node-arg:
3+
- '--allow-natives-syntax'
84

9-
files:
5+
include:
106
- 'test/**/*.test.js'
117
- 'test/**/*.test.mjs'

build/build-error-serializer.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,12 @@ const code = FJS({
1818
const file = path.join(__dirname, '..', 'lib', 'error-serializer.js')
1919

2020
const moduleCode = `// This file is autogenerated by build/build-error-serializer.js, do not edit
21-
/* istanbul ignore file */
21+
/* c8 ignore start */
2222
${code}
23+
/* c8 ignore stop */
2324
`
2425

26+
/* c8 ignore start */
2527
if (require.main === module) {
2628
fs.writeFileSync(file, moduleCode)
2729
console.log(`Saved ${file} file successfully`)
@@ -30,3 +32,4 @@ if (require.main === module) {
3032
code: moduleCode
3133
}
3234
}
35+
/* c8 ignore stop */

build/build-validation.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,11 @@ const factory = AjvStandaloneCompiler({
99
readMode: false,
1010
storeFunction (routeOpts, schemaValidationCode) {
1111
const moduleCode = `// This file is autogenerated by ${__filename.replace(__dirname, 'build')}, do not edit
12-
/* istanbul ignore file */
12+
/* c8 ignore start */
1313
${schemaValidationCode}
1414
1515
module.exports.defaultInitOptions = ${JSON.stringify(defaultInitOptions)}
16+
/* c8 ignore stop */
1617
`
1718

1819
const file = path.join(__dirname, '..', 'lib', 'configValidator.js')

lib/configValidator.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// This file is autogenerated by build/build-validation.js, do not edit
2-
/* istanbul ignore file */
2+
/* c8 ignore start */
33
"use strict";
44
module.exports = validate10;
55
module.exports.default = validate10;
@@ -1153,3 +1153,4 @@ return errors === 0;
11531153

11541154

11551155
module.exports.defaultInitOptions = {"connectionTimeout":0,"keepAliveTimeout":72000,"maxRequestsPerSocket":0,"requestTimeout":0,"bodyLimit":1048576,"caseSensitive":true,"allowUnsafeRegex":false,"disableRequestLogging":false,"jsonShorthand":true,"ignoreTrailingSlash":false,"ignoreDuplicateSlashes":false,"maxParamLength":100,"onProtoPoisoning":"error","onConstructorPoisoning":"error","pluginTimeout":10000,"requestIdHeader":false,"requestIdLogLabel":"reqId","http2SessionTimeout":72000,"exposeHeadRoutes":true,"useSemicolonDelimiter":false}
1156+
/* c8 ignore stop */

lib/error-serializer.js

Lines changed: 77 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
// This file is autogenerated by build/build-error-serializer.js, do not edit
2-
/* istanbul ignore file */
2+
/* c8 ignore start */
33

44
'use strict'
5-
const { dependencies } = require('fast-json-stringify/lib/standalone')
6-
7-
const { Serializer, Validator } = dependencies
85

6+
const Serializer = require('fast-json-stringify/lib/serializer')
97
const serializerState = {"mode":"standalone"}
108
const serializer = Serializer.restoreFromState(serializerState)
119

@@ -15,6 +13,18 @@
1513
module.exports = function anonymous(validator,serializer
1614
) {
1715

16+
const JSON_STR_BEGIN_OBJECT = '{'
17+
const JSON_STR_END_OBJECT = '}'
18+
const JSON_STR_BEGIN_ARRAY = '['
19+
const JSON_STR_END_ARRAY = ']'
20+
const JSON_STR_COMMA = ','
21+
const JSON_STR_COLONS = ':'
22+
const JSON_STR_QUOTE = '"'
23+
const JSON_STR_EMPTY_OBJECT = JSON_STR_BEGIN_OBJECT + JSON_STR_END_OBJECT
24+
const JSON_STR_EMPTY_ARRAY = JSON_STR_BEGIN_ARRAY + JSON_STR_END_ARRAY
25+
const JSON_STR_EMPTY_STRING = JSON_STR_QUOTE + JSON_STR_QUOTE
26+
const JSON_STR_NULL = 'null'
27+
1828

1929

2030
// #
@@ -23,40 +33,88 @@
2333
? input.toJSON()
2434
: input
2535

26-
if (obj === null) return '{}'
36+
if (obj === null) return JSON_STR_EMPTY_OBJECT
2737

28-
let json = '{'
38+
let value
39+
let json = JSON_STR_BEGIN_OBJECT
2940
let addComma = false
3041

31-
if (obj["statusCode"] !== undefined) {
32-
!addComma && (addComma = true) || (json += ',')
42+
value = obj["statusCode"]
43+
if (value !== undefined) {
44+
!addComma && (addComma = true) || (json += JSON_STR_COMMA)
3345
json += "\"statusCode\":"
34-
json += serializer.asNumber(obj["statusCode"])
46+
json += serializer.asNumber(value)
3547
}
3648

37-
if (obj["code"] !== undefined) {
38-
!addComma && (addComma = true) || (json += ',')
49+
value = obj["code"]
50+
if (value !== undefined) {
51+
!addComma && (addComma = true) || (json += JSON_STR_COMMA)
3952
json += "\"code\":"
40-
json += serializer.asString(obj["code"])
53+
54+
if (typeof value !== 'string') {
55+
if (value === null) {
56+
json += JSON_STR_EMPTY_STRING
57+
} else if (value instanceof Date) {
58+
json += JSON_STR_QUOTE + value.toISOString() + JSON_STR_QUOTE
59+
} else if (value instanceof RegExp) {
60+
json += serializer.asString(value.source)
61+
} else {
62+
json += serializer.asString(value.toString())
63+
}
64+
} else {
65+
json += serializer.asString(value)
66+
}
67+
4168
}
4269

43-
if (obj["error"] !== undefined) {
44-
!addComma && (addComma = true) || (json += ',')
70+
value = obj["error"]
71+
if (value !== undefined) {
72+
!addComma && (addComma = true) || (json += JSON_STR_COMMA)
4573
json += "\"error\":"
46-
json += serializer.asString(obj["error"])
74+
75+
if (typeof value !== 'string') {
76+
if (value === null) {
77+
json += JSON_STR_EMPTY_STRING
78+
} else if (value instanceof Date) {
79+
json += JSON_STR_QUOTE + value.toISOString() + JSON_STR_QUOTE
80+
} else if (value instanceof RegExp) {
81+
json += serializer.asString(value.source)
82+
} else {
83+
json += serializer.asString(value.toString())
84+
}
85+
} else {
86+
json += serializer.asString(value)
87+
}
88+
4789
}
4890

49-
if (obj["message"] !== undefined) {
50-
!addComma && (addComma = true) || (json += ',')
91+
value = obj["message"]
92+
if (value !== undefined) {
93+
!addComma && (addComma = true) || (json += JSON_STR_COMMA)
5194
json += "\"message\":"
52-
json += serializer.asString(obj["message"])
95+
96+
if (typeof value !== 'string') {
97+
if (value === null) {
98+
json += JSON_STR_EMPTY_STRING
99+
} else if (value instanceof Date) {
100+
json += JSON_STR_QUOTE + value.toISOString() + JSON_STR_QUOTE
101+
} else if (value instanceof RegExp) {
102+
json += serializer.asString(value.source)
103+
} else {
104+
json += serializer.asString(value.toString())
105+
}
106+
} else {
107+
json += serializer.asString(value)
108+
}
109+
53110
}
54111

55-
return json + '}'
112+
return json + JSON_STR_END_OBJECT
56113

57114
}
58115

59116
const main = anonymous0
60117
return main
61118

62119
}(validator, serializer)
120+
/* c8 ignore stop */

package.json

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,24 +11,24 @@
1111
"benchmark:parser": "concurrently -k -s first \"node ./examples/benchmark/parser.js\" \"autocannon -c 100 -d 30 -p 10 -i ./examples/benchmark/body.json -H \"content-type:application/jsoff\" -m POST localhost:3000/\"",
1212
"build:validation": "node build/build-error-serializer.js && node build/build-validation.js",
1313
"coverage": "npm run unit -- --coverage-report=html",
14-
"coverage:ci": "c8 --reporter=lcov tap --coverage-report=html --no-browser --no-check-coverage",
15-
"coverage:ci-check-coverage": "c8 check-coverage --branches 100 --functions 100 --lines 100 --statements 100",
14+
"coverage:ci": "tap --coverage-report=html --coverage-report=lcov --allow-incomplete-coverage",
15+
"coverage:ci-check-coverage": "tap replay",
1616
"lint": "npm run lint:standard && npm run lint:typescript && npm run lint:markdown",
1717
"lint:fix": "standard --fix && npm run lint:typescript:fix",
1818
"lint:markdown": "markdownlint-cli2",
1919
"lint:standard": "standard | snazzy",
2020
"lint:typescript": "eslint -c types/.eslintrc.json types/**/*.d.ts test/types/**/*.test-d.ts",
2121
"lint:typescript:fix": "npm run lint:typescript -- --fix",
22-
"prepublishOnly": "cross-env PREPUBLISH=true tap --no-check-coverage test/build/**.test.js && npm run test:validator:integrity",
22+
"prepublishOnly": "cross-env PREPUBLISH=true tap --allow-incomplete-coverage test/build/**.test.js && npm run test:validator:integrity",
2323
"test": "npm run lint && npm run unit && npm run test:typescript",
24-
"test:ci": "npm run unit -- --cov --coverage-report=lcovonly && npm run test:typescript",
24+
"test:ci": "npm run unit -- --coverage-report=lcovonly && npm run test:typescript",
2525
"test:report": "npm run lint && npm run unit:report && npm run test:typescript",
2626
"test:validator:integrity": "npm run build:validation && git diff --quiet --ignore-all-space --ignore-blank-lines --ignore-cr-at-eol lib/error-serializer.js && git diff --quiet --ignore-all-space --ignore-blank-lines --ignore-cr-at-eol lib/configValidator.js",
2727
"test:typescript": "tsc test/types/import.ts && tsd",
28-
"test:watch": "npm run unit -- --watch --cov --no-coverage-report --reporter=terse",
29-
"unit": "c8 tap",
28+
"test:watch": "npm run unit -- --watch --coverage-report=none --reporter=terse",
29+
"unit": "tap",
3030
"unit:junit": "tap-mocha-reporter xunit < out.tap > test/junit-testresults.xml",
31-
"unit:report": "tap --cov --coverage-report=html --coverage-report=cobertura | tee out.tap",
31+
"unit:report": "tap --coverage-report=html --coverage-report=cobertura | tee out.tap",
3232
"citgm": "tap --jobs=1 --timeout=120"
3333
},
3434
"repository": {
@@ -167,7 +167,6 @@
167167
"ajv-merge-patch": "^5.0.1",
168168
"autocannon": "^7.15.0",
169169
"branch-comparer": "^1.1.0",
170-
"c8": "^9.1.0",
171170
"concurrently": "^8.2.2",
172171
"cross-env": "^7.0.3",
173172
"eslint": "^8.57.0",
@@ -193,7 +192,7 @@
193192
"snazzy": "^9.0.0",
194193
"split2": "^4.2.0",
195194
"standard": "^17.1.0",
196-
"tap": "^16.3.9",
195+
"tap": "^19.0.0",
197196
"tsd": "^0.31.0",
198197
"typescript": "^5.4.5",
199198
"undici": "^6.13.0",

test/internals/reply.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1415,9 +1415,9 @@ test('.statusCode is getter and setter', t => {
14151415
const fastify = Fastify()
14161416

14171417
fastify.get('/', function (req, reply) {
1418-
t.ok(reply.statusCode, 200, 'default status value')
1418+
t.equal(reply.statusCode, 200, 'default status value')
14191419
reply.statusCode = 418
1420-
t.ok(reply.statusCode, 418)
1420+
t.equal(reply.statusCode, 418)
14211421
reply.send()
14221422
})
14231423

0 commit comments

Comments
 (0)