You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

@universal-packages/logger-jest

Package Overview
Dependencies
Maintainers
0
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@universal-packages/logger-jest

Jest matchers for Universal Logger

1.1.2
latest
Source
npmnpm
Version published
Weekly downloads
123
-62.27%
Maintainers
0
Weekly downloads
 
Created
Source

Logger Jest

npm version Testing codecov

Jest matchers for Logger testing.

Install

npm install @universal-packages/logger-jest

npm install @universal-packages/logger

Setup

Add the following to your jest.config.js or where you configure Jest:

module.exports = {
  setupFilesAfterEnv: ['@universal-packages/logger-jest']
}

Matchers

toHaveLogged

import { Logger } from '@universal-packages/logger'

it('should logged log', async () => {
  const logger = new Logger()

  logger.log({ level: 'INFO', message: 'Hello World' })

  expect(Logger).toHaveLogged({ level: 'INFO', message: 'Hello World' })
})

toHaveLoggedTotal

import { Logger } from '@universal-packages/logger'

it('should logged a total number of logs', async () => {
  const logger = new Logger()

  logger.log({ level: 'INFO', message: 'Hello World' })

  expect(Logger).toHaveLoggedTotal(1)
})

Typescript

In order for typescript to see the global types you need to reference the types somewhere in your project, normally ./src/globals.d.ts.

/// <reference types="@universal-packages/logger-jest" />

This library is developed in TypeScript and shipped fully typed.

Contributing

The development of this library happens in the open on GitHub, and we are grateful to the community for contributing bugfixes and improvements. Read below to learn how you can take part in improving this library.

License

MIT licensed.

FAQs

Package last updated on 30 Nov 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts