Skip to content

Commit 782917d

Browse files
committed
feat: native node ts strip testing
1 parent dddabc0 commit 782917d

7 files changed

Lines changed: 120 additions & 22 deletions

File tree

index.cts

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

package.json

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -44,19 +44,14 @@
4444
"build:test": "npm run clean && tsc --project tsconfig.json",
4545
"build:test:watch": "npm run clean && tsc --project tsconfig.json --watch",
4646
"build:watch": "npm run clean && tsc --project tsconfig.build.json --watch",
47-
"check": "tsc --project ./tsconfig.json",
4847
"clean": "rimraf dist",
49-
"dev": "NODE_NO_WARNINGS=1 node --loader ts-node/esm/transpile-only ./src/index.ts",
50-
"dev:watch": "NODE_NO_WARNINGS=1 node --watch --loader ts-node/esm/transpile-only ./src/index.ts",
5148
"lint": "xo",
5249
"lint:fix": "xo --fix",
5350
"prepare": "husky",
5451
"release": "np",
5552
"test": "npm run build:test && c8 ava",
56-
"test:all": "npm run test && npm run test:node",
57-
"test:node": "npm run build:test && node --test --test-update-snapshots test-node/**/*.test.ts",
58-
"test:watch": "ava --watch",
59-
"update": "ncu -i"
53+
"test:node": "node --watch --test test-node/**/*.test.ts",
54+
"test:watch": "ava --watch"
6055
},
6156
"xo": {
6257
"prettier": true,
@@ -79,10 +74,11 @@
7974
]
8075
},
8176
"ava": {
77+
"extensions": {
78+
"ts": "module"
79+
},
8280
"files": [
83-
"dist/test/**",
84-
"!dist/test/fixtures/**",
85-
"!dist/test/helpers/**"
81+
"test/**/*.ts"
8682
],
8783
"snapshotDir": "test/snapshots",
8884
"verbose": true
@@ -106,7 +102,7 @@
106102
"devDependencies": {
107103
"@commitlint/cli": "^20.2.0",
108104
"@commitlint/config-conventional": "^20.2.0",
109-
"@types/node": "^24.10.1",
105+
"@types/node": "^25.0.3",
110106
"@types/pump": "^1.1.3",
111107
"ava": "^6.4.1",
112108
"c8": "^10.1.3",
@@ -120,7 +116,6 @@
120116
"prettier-plugin-packagejson": "^2.5.20",
121117
"rimraf": "^6.1.2",
122118
"strip-ansi": "^7.1.2",
123-
"ts-node": "^10.9.2",
124119
"typescript": "^5.9.3",
125120
"xo": "^1.2.3"
126121
},

test-node/cli.test.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ test('cli formats a log line', async (t: TestContext) => {
1717
time: Date.now(),
1818
}),
1919
});
20-
console.log(stdout);
2120
t.assert.ok(stdout.includes('INFO hello'));
2221
});
2322

@@ -26,7 +25,7 @@ test('cli respects --messageKey option', async (t: TestContext) => {
2625
// Test with default messageKey
2726
const {stdout: stdoutWithDefaultMessageKey} = await execa(
2827
'node',
29-
['dist/cli.js'],
28+
['dist/cli.js', '--colors=false'],
3029
{
3130
input: JSON.stringify({
3231
level: 30,
@@ -38,7 +37,7 @@ test('cli respects --messageKey option', async (t: TestContext) => {
3837

3938
const {stdout} = await execa(
4039
'node',
41-
['dist/cli.js', '--messageKey=message'],
40+
['dist/cli.js', '--messageKey=message', '--colors=false'],
4241
{
4342
input: JSON.stringify({
4443
level: 30,

test/snapshots/test/cli.test.ts.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Snapshot report for `test/cli.test.ts`
2+
3+
The actual snapshot is saved in `cli.test.ts.snap`.
4+
5+
Generated by [AVA](https://avajs.dev).
6+
7+
## cli --help runs without error
8+
9+
> Snapshot 1
10+
11+
`␊
12+
Prettiest Pino Prettifier in all the land␊
13+
14+
Usage␊
15+
$ node my-app-with-pino-logging | pino-princess␊
16+
17+
Options␊
18+
--exclude, -e excluded log fields separated by comma. Is overriden by included fields.␊
19+
--include, -i included log fields separated by comma. Overrides excluded fields.␊
20+
--messageKey key for the message field, defaults to 'msg'␊
21+
--errorKey key for the error field, defaults to 'err'␊
22+
--timeKey key for the time field, defaults to 'time'␊
23+
--timeFormat format for the time field, passed to date-fns format defaults to 'h:mm:ss.SSS aaa'␊
24+
--singleLine format the output as a single line, defaults to false␊
25+
--unicode force unicode emojis on or off, auto-detected by default␊
26+
--no-colors disable all color output, auto-detected by default␊
27+
28+
`
490 Bytes
Binary file not shown.
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
# Snapshot report for `test/prettify.test.ts`
2+
3+
The actual snapshot is saved in `prettify.test.ts.snap`.
4+
5+
Generated by [AVA](https://avajs.dev).
6+
7+
## creates basic log lines with level
8+
9+
> Snapshot 1
10+
11+
'✨ INFO'
12+
13+
## creates basic log lines with string level
14+
15+
> Snapshot 1
16+
17+
'✨ INFO hello'
18+
19+
## creates basic log lines with level, message, and time
20+
21+
> Snapshot 1
22+
23+
`✨ INFO ␊
24+
"message": "hello"`
25+
26+
## creates basic log lines with level, message, and time, and res.statusCode
27+
28+
> Snapshot 1
29+
30+
`✨ INFO 200␊
31+
"message": "hello"`
32+
33+
## creates basic log lines with level, message, and time, and req.method
34+
35+
> Snapshot 1
36+
37+
`✨ INFO [ID:123] GET 200␊
38+
"message": "hello"`
39+
40+
## full log line with all time and no extra time
41+
42+
> Snapshot 1
43+
44+
`[test] ✨ INFO [ID:123] GET 200 http://localhost:3000 hello␊
45+
"ns": "test", "id": "123", "responsedate": 100`
46+
47+
## full log line with all time and extra time
48+
49+
> Snapshot 1
50+
51+
`[test] ✨ INFO [ID:123] GET 200 http://localhost:3000 hello␊
52+
"ns": "test", "responsedate": 100, "extra": "time"`
53+
54+
## full log line with all time and extra time multiline
55+
56+
> Snapshot 1
57+
58+
`[test] ✨ INFO [ID:123] GET 200 http://localhost:3000 hello␊
59+
"ns": "test",␊
60+
"responsedate": 100,␊
61+
"extra": "time",␊
62+
"multi": "line",␊
63+
"idk": "what",␊
64+
"else": "to add",␊
65+
"for": {"extra": "time"}`
66+
67+
## custom formatters are merged in the same order as default
68+
69+
> Snapshot 1
70+
71+
`[test] ✨ INFO [ID:123] GET 200 hello␊
72+
"customField": "customValue"`
73+
74+
> Snapshot 2
75+
76+
`!!!test!!! ✨ INFO [ID:123] GET 200 !!!hello!!!␊
77+
"customField": "customValue"`
78+
79+
## creates extra log as single line
80+
81+
> Snapshot 1
82+
83+
'✨ INFO hello {"extra": {"a": "b", "c": "d"}}'
611 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)