All Projects β†’ mattphillips β†’ Jest Expect Message

mattphillips / Jest Expect Message

Licence: mit
Add custom message to Jest expects πŸƒπŸ—―

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Jest Expect Message

reducer-tester
Utilities for testing redux reducers
Stars: ✭ 19 (-92.08%)
Mutual labels:  jest, test
React Generate Props
Generate default props based on your React component's PropTypes
Stars: ✭ 23 (-90.42%)
Mutual labels:  jest, test
puppeteer-screenshot-tester
Small library that allows us to compare screenshots generated by puppeteer in our tests.
Stars: ✭ 50 (-79.17%)
Mutual labels:  jest, test
Toast
To use it in PCL or .NetStandard projects write this line of code : CrossToastPopUp.Current.ShowToastMessage("Message");
Stars: ✭ 51 (-78.75%)
Mutual labels:  custom, message
Gest
πŸ‘¨β€πŸ’» A sensible GraphQL testing tool - test your GraphQL schema locally and in the cloud
Stars: ✭ 109 (-54.58%)
Mutual labels:  jest, test
jest-launchdarkly-mock
Easily unit test LaunchDarkly feature flagged components with jest
Stars: ✭ 14 (-94.17%)
Mutual labels:  jest, test
Jest In Case
Jest utility for creating variations of the same test
Stars: ✭ 902 (+275.83%)
Mutual labels:  jest, test
Enzyme
JavaScript Testing utilities for React
Stars: ✭ 19,781 (+8142.08%)
Mutual labels:  jest, test
Esbuild Jest
A Jest transformer using esbuild
Stars: ✭ 100 (-58.33%)
Mutual labels:  jest, test
Tyu
Unit test with no initial configuration.
Stars: ✭ 89 (-62.92%)
Mutual labels:  jest, test
xv
❌ βœ”οΈ zero-config test runner for simple projects
Stars: ✭ 588 (+145%)
Mutual labels:  jest, test
Jest Html Reporter
Jest test results processor for generating a summary in HTML
Stars: ✭ 161 (-32.92%)
Mutual labels:  jest, test
Vuex Mock Store
βœ…Simple and straightforward Vuex Store mock for vue-test-utils
Stars: ✭ 246 (+2.5%)
Mutual labels:  jest, test
walrus
πŸŽ‰ Cli development framework.
Stars: ✭ 17 (-92.92%)
Mutual labels:  jest, test
Jest Html Reporters
🌈 Reporter for jest test framework. 🌈
Stars: ✭ 245 (+2.08%)
Mutual labels:  jest, test
Angular Builders
Angular build facade extensions (Jest and custom webpack configuration)
Stars: ✭ 843 (+251.25%)
Mutual labels:  jest, custom
Javascript Testing Best Practices
πŸ“—πŸŒ 🚒 Comprehensive and exhaustive JavaScript & Node.js testing best practices (August 2021)
Stars: ✭ 13,976 (+5723.33%)
Mutual labels:  jest, test
Snap Shot
Jest-like snapshot feature for the rest of us, works magically by finding the right caller function
Stars: ✭ 170 (-29.17%)
Mutual labels:  jest, test
Transition
Easy interactive interruptible custom ViewController transitions
Stars: ✭ 2,566 (+969.17%)
Mutual labels:  custom
Twitch Js
A community-centric, community-supported version of tmi.js
Stars: ✭ 225 (-6.25%)
Mutual labels:  message

jest-expect-message

πŸƒπŸ—―

Add custom message to Jest expects


Build Status Code Coverage version downloads MIT License PRs Welcome Roadmap Examples

Problem

In many testing libraries it is possible to supply a custom message for a given expectation, this is currently not possible in Jest.

For example:

test('returns 2 when adding 1 and 1', () => {
  expect(1 + 1, 'Woah this should be 2!').toBe(3);
});

This will throw the following error in Jest:

Expect takes at most one argument.

Solution

jest-expect-message allows you to call expect with a second argument of a String message.

For example the same test as above:

test('returns 2 when adding 1 and 1', () => {
  expect(1 + 1, 'Woah this should be 2!').toBe(3);
});

With jest-expect-message this will fail with your custom error message:

  ● returns 2 when adding 1 and 1

    Custom message:
      Woah this should be 2!

    expect(received).toBe(expected) // Object.is equality

    Expected: 3
    Received: 2

Installation

With npm:

npm install --save-dev jest-expect-message

With yarn:

yarn add -D jest-expect-message

Setup

Add jest-expect-message to your Jest setupFilesAfterEnv configuration. See for help

Jest v24+

"jest": {
  "setupFilesAfterEnv": ["jest-expect-message"]
}

Jest v23-

"jest": {
  "setupTestFrameworkScriptFile": "jest-expect-message"
}

Usage

  • expect(actual, message)
    • actual: The value you would normally pass into an expect to assert against with a given matcher.
    • message: String, the custom message you want to be printed should the expect fail.
test('returns 2 when adding 1 and 1', () => {
  expect(1 + 1, 'Woah this should be 2!').toBe(3);
});

Contributors


Matt Phillips

πŸ’» πŸ“– πŸ’‘ πŸ€” πŸš‡ ⚠️ πŸ”§

LICENSE

MIT

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].