ttmarek / Consolemock
Licence: mit
A tool for testing console logs
Stars: ✭ 103
Programming Languages
javascript
184084 projects - #8 most used programming language
Projects that are alternatives of or similar to Consolemock
React Equalizer
Pure React Match Height Component
Stars: ✭ 32 (-68.93%)
Mutual labels: jest, javascript-library
Javali
🐗 Create a modern JavaScript library that uses ES6 + Jest
Stars: ✭ 144 (+39.81%)
Mutual labels: jest, javascript-library
Gest
👨💻 A sensible GraphQL testing tool - test your GraphQL schema locally and in the cloud
Stars: ✭ 109 (+5.83%)
Mutual labels: jest, testing-tools
jest-dashboard
Command Line Dashboard for Jest
Stars: ✭ 61 (-40.78%)
Mutual labels: jest, testing-tools
jest-wrap
Fluent pluggable interface for easily wrapping `describe` and `it` blocks in Jest tests.
Stars: ✭ 35 (-66.02%)
Mutual labels: jest, testing-tools
Chromogen
UI-driven Jest test-generation package for Recoil selectors
Stars: ✭ 164 (+59.22%)
Mutual labels: jest, testing-tools
puppeteer-screenshot-tester
Small library that allows us to compare screenshots generated by puppeteer in our tests.
Stars: ✭ 50 (-51.46%)
Mutual labels: jest, testing-tools
Expect Playwright
Jest utility matcher functions to simplify expect statements for the usage with Playwright.
Stars: ✭ 66 (-35.92%)
Mutual labels: jest, testing-tools
Nodeppt
This is probably the best web presentation tool so far!
Stars: ✭ 9,589 (+9209.71%)
Mutual labels: javascript-library
Npm Registry Browser
Browse the npm registry with an SPA made in React, with full dev workflow.
Stars: ✭ 97 (-5.83%)
Mutual labels: jest
React Native Cross Platform Starter
One codebase to build for iOS, Android, Web and Desktop with React-Native
Stars: ✭ 101 (-1.94%)
Mutual labels: jest
Easy Scroll
A lightweight native javascript library to perform smooth scrolling with animation
Stars: ✭ 96 (-6.8%)
Mutual labels: javascript-library
Mongodb Memory Server
Spinning up mongod in memory for fast tests. If you run tests in parallel this lib helps to spin up dedicated mongodb servers for every test file in MacOS, *nix, Windows or CI environments (in most cases with zero-config).
Stars: ✭ 1,376 (+1235.92%)
Mutual labels: testing-tools
Date Picker
Duet Date Picker is an open source version of Duet Design System’s accessible date picker. Try live example at https://duetds.github.io/date-picker/
Stars: ✭ 1,325 (+1186.41%)
Mutual labels: javascript-library
Gdrivesync.js
Javascript wrapper library for Google Drive API v3
Stars: ✭ 94 (-8.74%)
Mutual labels: javascript-library
Beanmother
A library for setting up Java objects as test data.
Stars: ✭ 102 (-0.97%)
Mutual labels: testing-tools
A tool for testing console logs
Installation
with yarn
yarn add --dev consolemock
or with npm
npm install --save-dev consolemock
API
import makeConsoleMock from 'consolemock';
console = makeConsoleMock();
console.log('a message');
console.group('a group');
console.info('maybe an object?', { a: 'str', b: false, c: [1, 2, 3], d: { a: 'b' } });
console.warn('something useful');
console.error('something unexpected');
console.group('%c a nested group with styling', 'color: #1da1f2; font-weight: bold;');
console.log('%c a nested log with styling', 'color: #D63230;');
console.groupEnd();
console.log('almost done');
console.groupEnd();
console.info('%c fin', 'font-weight: bold;');
console.debug('some debug statement');
console.history();
↳ [
{ LOG: ['a message'] },
{ GROUP: ['a group'] },
{ _INFO: ['maybe an object?', { a: 'str', b: false, c: [1, 2, 3], d: { a: 'b' } }] },
{ _WARN: ['something useful'] },
{ _ERROR: ['something unexpected'] },
{ _GROUP: ['%c a nested group with styling', 'color: #1da1f2; font-weight: bold;'] },
{ __LOG: ['%c a nested log with styling', 'color: #D63230;'] },
{ _LOG: ['almost done'] },
{ INFO: ['%c fin', 'font-weight: bold;'] },
{ DEBUG: ['some debug statement'] }
]
console.printHistory();
↳ "LOG a message
GROUP a group
INFO maybe an object?, {a: 'str', b: false, c: [1, 2, 3], d: {a: 'b'}}
WARN something useful
ERROR something unexpected
GROUP %c a nested group with styling, color: #1da1f2; font-weight: bold;
LOG %c a nested log with styling, color: #D63230;
LOG almost done
INFO %c fin, font-weight: bold;
DEBUG some debug statement"
console.clearHistory()
↳ console.log('hello');
console.log('world');
console.clearHistory();
console.log('apple');
console.history() // returns [{ LOG: ['apple'] }]
console.print(message, [message1, ..., messageN])
↳ Logs messages to the console when debugging. Provide makeConsoleMock
with the
native console
object when creating the mock:
import makeConsoleMock from 'consolemock';
console = makeConsoleMock(console);
Uses
consolemock
With Snapshot Testing
⚡ Use The output of printHistory
works great with
Jest's snapshot testing.
Create the mock console, log a few messages, then save the output of
printHistory
as a snapshot.
Note that the project description data, including the texts, logos, images, and/or trademarks,
for each open source project belongs to its rightful owner.
If you wish to add or remove any projects, please contact us at [email protected].