Projektstart
This commit is contained in:
12
backend/node_modules/pino/test/esm/esm.mjs
generated
vendored
Normal file
12
backend/node_modules/pino/test/esm/esm.mjs
generated
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
import t from 'tap'
|
||||
import pino from '../../pino.js'
|
||||
import helper from '../helper.js'
|
||||
|
||||
const { sink, check, once } = helper
|
||||
|
||||
t.test('esm support', async ({ equal }) => {
|
||||
const stream = sink()
|
||||
const instance = pino(stream)
|
||||
instance.info('hello world')
|
||||
check(equal, await once(stream, 'data'), 30, 'hello world')
|
||||
})
|
||||
34
backend/node_modules/pino/test/esm/index.test.js
generated
vendored
Normal file
34
backend/node_modules/pino/test/esm/index.test.js
generated
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
'use strict'
|
||||
|
||||
const t = require('tap')
|
||||
const semver = require('semver')
|
||||
|
||||
const { isYarnPnp } = require('../helper')
|
||||
|
||||
if (!semver.satisfies(process.versions.node, '^13.3.0 || ^12.10.0 || >= 14.0.0') || isYarnPnp) {
|
||||
t.skip('Skip esm because not supported by Node')
|
||||
} else {
|
||||
// Node v8 throw a `SyntaxError: Unexpected token import`
|
||||
// even if this branch is never touch in the code,
|
||||
// by using `eval` we can avoid this issue.
|
||||
// eslint-disable-next-line
|
||||
new Function('module', 'return import(module)')('./esm.mjs').catch((err) => {
|
||||
process.nextTick(() => {
|
||||
throw err
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
if (!semver.satisfies(process.versions.node, '>= 14.13.0 || ^12.20.0') || isYarnPnp) {
|
||||
t.skip('Skip named exports because not supported by Node')
|
||||
} else {
|
||||
// Node v8 throw a `SyntaxError: Unexpected token import`
|
||||
// even if this branch is never touch in the code,
|
||||
// by using `eval` we can avoid this issue.
|
||||
// eslint-disable-next-line
|
||||
new Function('module', 'return import(module)')('./named-exports.mjs').catch((err) => {
|
||||
process.nextTick(() => {
|
||||
throw err
|
||||
})
|
||||
})
|
||||
}
|
||||
27
backend/node_modules/pino/test/esm/named-exports.mjs
generated
vendored
Normal file
27
backend/node_modules/pino/test/esm/named-exports.mjs
generated
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
import { hostname } from 'node:os'
|
||||
import t from 'tap'
|
||||
import { sink, check, once, watchFileCreated, file } from '../helper.js'
|
||||
import { pino, destination } from '../../pino.js'
|
||||
import { readFileSync } from 'node:fs'
|
||||
|
||||
t.test('named exports support', async ({ equal }) => {
|
||||
const stream = sink()
|
||||
const instance = pino(stream)
|
||||
instance.info('hello world')
|
||||
check(equal, await once(stream, 'data'), 30, 'hello world')
|
||||
})
|
||||
|
||||
t.test('destination', async ({ same }) => {
|
||||
const tmp = file()
|
||||
const instance = pino(destination(tmp))
|
||||
instance.info('hello')
|
||||
await watchFileCreated(tmp)
|
||||
const result = JSON.parse(readFileSync(tmp).toString())
|
||||
delete result.time
|
||||
same(result, {
|
||||
pid: process.pid,
|
||||
hostname,
|
||||
level: 30,
|
||||
msg: 'hello'
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user