How to use the pino.mockImplementation function in pino

To help you get started, we’ve selected a few pino examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github moleculerjs / moleculer / test / unit / loggers / pino.spec.js View on Github external
"use strict";

jest.mock("pino");

const Pino = require("pino");

const childFakeLogger = { warn: jest.fn() };
const fakeLogger = {
	child: jest.fn(() => childFakeLogger)
};
Pino.mockImplementation(() => fakeLogger);

const PinoLogger = require("../../../src/loggers/pino");
const ServiceBroker = require("../../../src/service-broker");
const LoggerFactory = require("../../../src/logger-factory");

const broker = new ServiceBroker({ logger: false });

describe("Test Pino logger class", () => {

	describe("Test Constructor", () => {

		it("should create with default options", () => {
			const logger = new PinoLogger();

			expect(logger.opts).toEqual({
				pino: {