npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

tests-logger

v1.0.0

Published

Test Logger

Readme

Test Logger

Test logger tool is for easier logging your activity within the automated tests. For instance you need to log the tests steps in your test or some test logs (tracing, info or some errors without throwing), therefore this tool helps you do it more productively.

Installiation

Install Test Logger in your test project with the following command

npm install test-logger

Import logger in your file

// ./file.ts
import { Log } from 'test-logger'

Logger types

This test logger has different types. Wich have mark of the type, date (dd/M/yyyy, hh:mm:ss.ms), and message you want to log. More about them below:

  1. [STR] - Start. We can use this log to define the start of the test to easily find the beginning of the tests in your logs.
// ./file.ts
import { Log } from 'test-logger';

Log.startTest('The test starts here');

// [STR]  24/9/2022, 15:38:18.731 --------------------------------------- The test starts here
  1. [END] - End. We can use this log to define the end of the test to easily find the ending of the tests in your logs.
// ./file.ts
import { Log } from 'test-logger';

Log.endTest('The test ends here');

// [END]  24/9/2022, 15:38:18.731 --------------------------------------- The test ends here
  1. [TRC] - Trace. We can use this log to define the stack traces in your framework.
// ./file.ts
import { Log } from 'test-logger';

Log.stackTrace('Executing connection to the DB');

// [TRC]  24/9/2022, 15:38:18.731 --------------------------------------- Executing connection to the DB
  1. [INF] - Information. We can use this log to define the information about commands in your framework.
// ./file.ts
import { Log } from 'test-logger';

Log.info('Connection is successfully');

// [INF]  24/9/2022, 15:38:18.731 --------------------------------------- Connection is successfully
  1. [WRN] - Warning.
// ./file.ts
import { Log } from 'test-logger';

Log.warning(`Connection is successfully. Taken time: ${connectingTime}`);

// [WRN]  24/9/2022, 15:38:18.731 --------------------------------------- Connection is successfully. Taken time: 0:8:64
  1. [ERR] - Error.
// ./file.ts
import { Log } from 'test-logger';

Log.warning(`Connection is failed`);

// [ERR]  24/9/2022, 15:38:18.731 --------------------------------------- Connection is failed
  1. [STP] - Test steps.
// ./file.ts
import { Log } from 'test-logger';

Log.testStep(`Login to your account`);

// [STP]  24/9/2022, 15:38:18.731 --------------------------------------- Login to your accoun

Configuration

You may need to configure your logger for your approaches or goals. However you do not need to change everything. Therefore some configuration for this logger is described below

Log configuration

Basically, this test logger is able to log information in two ways. The first one is show logged information in your console while running tests, the second one is to log information into .log file. Let's get review each of them

Console log

For this way you do not need an additional configuration. This logger shows your logs in the console by default with colored rows depends on log type (see below about color configuration)

File log

If you need to log test information in file, not in console and store it somewhere you need to change some configuration for this test logger. Let's create a file loggerconfig.json in the root directory of your project. Add the following code for this config file:

{
    "report": true
}

With the above config file test logs will be logged in the file test-logs.log in the root directory of your project. If you want to store this file in another place, you have to add reportPath parameter:

{
    "report": true,
    "reportPath": "/reports/test-logger-report.log"
}

Color configuration

Basically this test logger using default colors for logging test information in different types for console

Basic color configuration

Start and End logs in the console have green color #00FF00:

image image

Trace logs in the console have cyan color #00FFFF:

image

Information logs in the console have blue color #0000FF:

image

Warning logs in the console have yelow color #FFFF00:

image

Error logs in the console have red color #FF0000:

image

Error logs in the console have magenta color #FF00FF:

image

If you want to configure your own console colors, please use the loggerconfig.json file and add the following configuration for collors:

{
    "report": true,
    "reportPath": "/reports/test-logger-report.log",
    "colors": {
        "testStep": "FgWhite"
    }
}

You can find available colors or formats right here:

Reset: "\x1b[0m",
Bright: "\x1b[1m",
Dim: "\x1b[2m",
Underscore: "\x1b[4m",
Blink: "\x1b[5m",
Reverse: "\x1b[7m",
Hidden: "\x1b[8m",

FgBlack: "\x1b[30m",
FgRed: "\x1b[31m",
FgGreen: "\x1b[32m",
FgYellow: "\x1b[33m",
FgBlue: "\x1b[34m",
FgMagenta: "\x1b[35m",
FgCyan: "\x1b[36m",
FgWhite: "\x1b[37m",

BgBlack: "\x1b[40m",
BgRed: "\x1b[41m",
BgGreen: "\x1b[42m",
BgYellow: "\x1b[43m",
BgBlue: "\x1b[44m",
BgMagenta: "\x1b[45m",
BgCyan: "\x1b[46m",
BgWhite: "\x1b[47m"