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.
@jason0x43/jest-expect-message
Advanced tools
Readme
🃏🗯
Add custom message to Jest expects
Note: This is a fork of mattphillips/jest-expect-message with TS source and updates for Jest 27.
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.
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
With npm:
npm install --save-dev jest-expect-message
With yarn:
yarn add -D jest-expect-message
Add jest-expect-message
to your Jest setupFilesAfterEnv
configuration.
See for help
"jest": {
"setupFilesAfterEnv": ["jest-expect-message"]
}
"jest": {
"setupTestFrameworkScriptFile": "jest-expect-message"
}
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);
});
Matt Phillips 💻 📖 💡 🤔 🚇 ⚠️ 🔧 |
---|
FAQs
Add custom message to Jest expects
The npm package @jason0x43/jest-expect-message receives a total of 0 weekly downloads. As such, @jason0x43/jest-expect-message popularity was classified as not popular.
We found that @jason0x43/jest-expect-message demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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.