-
Notifications
You must be signed in to change notification settings - Fork 846
/
index.js
46 lines (39 loc) 路 1.18 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
'use strict'
const os = require('os')
const { join } = require('path')
const { readFile } = require('fs').promises
const { watchFileCreated, file } = require('../helper')
const { test } = require('tap')
const pino = require('../../pino')
const { pid } = process
const hostname = os.hostname()
/**
* This file is packaged using pkg in order to test if transport-stream.js works in that context
*/
test('pino.transport with worker destination overridden by bundler and mjs transport', async ({ same, teardown }) => {
globalThis.__bundlerPathsOverrides = {
'pino-worker': join(__dirname, '..', '..', 'lib/worker.js')
}
const destination = file()
const transport = pino.transport({
targets: [
{
target: join(__dirname, '..', 'fixtures', 'ts', 'to-file-transport.es2017.cjs'),
options: { destination }
}
]
})
teardown(transport.end.bind(transport))
const instance = pino(transport)
instance.info('hello')
await watchFileCreated(destination)
const result = JSON.parse(await readFile(destination))
delete result.time
same(result, {
pid,
hostname,
level: 30,
msg: 'hello'
})
globalThis.__bundlerPathsOverrides = undefined
})