Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
@closeio/test-console
Advanced tools
Readme
A flexible framework for managing console messages in your tests.
Test output can get clutterd with logs and warnings for many reasons:
Whatever the reason, if you find that there's a lot of noise in the output of your tests and you'd like to manage that, this library is for you!
Our approach is to give you a succinct way to identify output in your tests and deal with them in a systematic manner.
For instance, at Close we set the test output in our CI system to only show CRITICAL items. That way we have only the most important information in the output from our CI system, and if a test fails it's very easy to see why. While testing in watch mode in our development environment shows everything.
When we want to eliminate a particular warning from our test system, we set that matcher to be CRITICAL and run our tests with an CRITICAL threshold so we only see the items we need to fix. This helps us focus on the task at hand and see clearly when we've reached our goal.
yarn add -D @closeio/test-console
npm i --save-dev @closeio/test-console
In a file that you load before running your tests, you can do something like this:
import { patchConsoleMethods } from '@closeio/test-console';
// Make the threshold customizable from the command line
const threshold = process.env.TEST_CONSOLE_LEVEL || 'ERROR';
patchConsoleMethods(
['debug', 'info', 'log', 'warn', 'error'], // the console methods to patch
// A list of tests to compare against logged messages, and their associated
// log level if matched.
[
{ matcher: /warning: failed prop type:/i, level: 'WARNING' },
{
matcher: 'Each child in a list should have a unique "key" prop',
level: 'ERROR',
},
{
matcher: /warning: an update to .* inside a test was not wrapped in act/i,
level: 'CRITICAL',
},
],
{
// filenameRegex determines what lines from the stack trace will show when
// logging out the test location.
filenameRegex: /\.test\.[jt]sx?/,
// If given, getTestName will be called when logging out test location, to
// help you track down where logs are coming from.
getTestName: () => expect.getState().currentTestName,
// Log messages whose level is >= the threshold will be shown, along with
// log messages that didn't match one of the log tests.
threshold,
},
);
And then you can run your tests with the level you want like:
TEST_CONSOLE_LEVEL=INFO yarn test
FAQs
Library for handling console logs in tests in a flexible way
The npm package @closeio/test-console receives a total of 883 weekly downloads. As such, @closeio/test-console popularity was classified as not popular.
We found that @closeio/test-console demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 8 open source maintainers collaborating on the project.
Did you know?
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.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.