0
Fork 0
mirror of https://github.com/verdaccio/verdaccio.git synced 2024-12-23 22:27:34 -05:00
verdaccio/packages/logger/logger-prettify/test/index.spec.ts
Juan Picado 631abe1ac1
refactor logger module (#3592)
* refactor logger module

* Update index.ts
2023-02-05 21:00:32 +01:00

28 lines
693 B
TypeScript

import pino from 'pino';
import { Writable } from 'stream';
import { buildPretty } from '../src';
describe('prettyFactory', () => {
const prettyfierOptions = {
messageKey: 'msg',
levelFirst: true,
prettyStamp: false,
colors: false,
};
test('should return a function', (done) => {
const pretty = buildPretty(prettyfierOptions);
const log = pino(
new Writable({
objectMode: true,
write(chunk, enc, cb) {
const formatted = pretty(JSON.parse(chunk));
expect(formatted).toBe('info --- test message ');
cb();
done();
},
})
);
log.info({ test: 'test' }, '@{test} message');
});
});