Security News
The Dark Side of Open Source
At Node Congress, Socket CEO Feross Aboukhadijeh uncovers the darker aspects of open source, where applications that rely heavily on third-party dependencies can be exploited in supply chain attacks.
jest-expect-json
Advanced tools
Readme
Do you need to test objects against json strings? Does jest expect not have all the json matchers you deserve? Are your fetch tests looking real fragile with that block of json?
Import jest-expect-json
into your tests now!
Built on Jest expect matchers, `jest-expect-json add useful json testing to jest!
Add jest-expect-json
to your test file like so:
import 'jest-expect-json';
jsonMatching
parses a json string for use with expect
.
fetch('url', {
method: 'POST',
body: '{"some": "DATA", "more": "DATA!"}',
})
expect(fetch).toBeCalledWith('url', {
method: 'POST',
body: expect.jsonMatching({
some: 'DATA',
more: expect.stringContaining('!'),
}),
});
jsonContaining
parses a json string and tests the data with the appropriate -containing
method;
fetch('url', {
method: 'POST',
body: '{"some": "DATA", "more": "unchecked data"}',
})
expect(fetch).toBeCalledWith('url', {
method: 'POST',
body: expect.jsonContaining({ some: 'DATA' }),
});
Having trouble with type definitions? Append to your package.json
like jest-extended:
"jest": {
"setupFilesAfterEnv": [
"jest-expect-json"
]
}
FAQs
Jest testing with JSON
The npm package jest-expect-json receives a total of 145 weekly downloads. As such, jest-expect-json popularity was classified as not popular.
We found that jest-expect-json 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
At Node Congress, Socket CEO Feross Aboukhadijeh uncovers the darker aspects of open source, where applications that rely heavily on third-party dependencies can be exploited in supply chain attacks.
Research
Security News
The Socket Research team found this npm package includes code for collecting sensitive developer information, including your operating system username, Git username, and Git email.
Security News
OpenJS is warning of social engineering takeovers targeting open source projects after receiving a credible attempt on the foundation.