mattphillips / Jest Expect Message
Licence: mit
Add custom message to Jest expects ππ―
Stars: β 240
Programming Languages
javascript
184084 projects - #8 most used programming language
Projects that are alternatives of or similar to Jest Expect Message
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
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
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
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 anexpect
to assert against with a given matcher. -
message
: String, the custom message you want to be printed should theexpect
fail.
-
test('returns 2 when adding 1 and 1', () => {
expect(1 + 1, 'Woah this should be 2!').toBe(3);
});
Contributors
Matt Phillips π» π π‘ π€ π β οΈ π§ |
---|
LICENSE
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].