Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
jest-immutable-matchers
Advanced tools
Add a set of custom matchers for Immutable related checks.
Just run:
$ npm install --save-dev jest-immutable-matchers
Load these matchers in a beforeEach
block, and then use them like any other matcher:
expect(Immutable.Map()).toBeImmutable()
This package includes the necessary declarations for TypeScript. Just make sure they get loaded in your project, for example by adding the package name to the types
field in your tsconfig.json
:
{
"compilerOptions": {
"module": "commonjs",
"target": "es5",
"types": [
"jest",
"jest-immutable-matchers"
]
}
}
Then just load the matchers at runtime in your tests:
import * as matchers from 'jest-immutable-matchers';
describe('My suite', function () {
beforeEach(function () {
expect.extend(matchers);
});
it('passes if the object is immutable', function () {
expect(Immutable.Map()).toBeImmutable();
});
it('passes if the immutable objects are equal', function () {
expect(Immutable.Map({a: 1})).toEqualImmutable(Immutable.Map({a: 1}));
});
});
If you are using the new module syntax, import
all exported matchers:
import * as matchers from 'jest-immutable-matchers';
describe('My suite', function () {
beforeEach(function () {
expect.extend(matchers);
});
it('passes if the object is immutable', function () {
expect(Immutable.Map()).toBeImmutable();
});
it('passes if the immutable objects are equal', function () {
expect(Immutable.Map({a: 1})).toEqualImmutable(Immutable.Map({a: 1}));
});
});
Note that jest-immutable-matchers
does not have a default export!
If you are using AMD or CommonJS, require
normally:
var matchers = require('jest-immutable-matchers');
describe('My suite', function () {
beforeEach(function () {
expect.extend(matchers);
});
it('passes if the object is immutable', function () {
expect(Immutable.Map()).toBeImmutable();
});
it('passes if the immutable objects are equal', function () {
expect(Immutable.Map({a: 1})).toEqualImmutable(Immutable.Map({a: 1}));
});
});
Otherwise, use window['jest-immutable-matchers']
:
var matchers = window['jest-immutable-matchers'];
describe('My suite', function () {
beforeEach(function () {
expect.extend(matchers);
});
it('passes if the object is immutable', function () {
expect(Immutable.Map()).toBeImmutable();
});
it('passes if the immutable objects are equal', function () {
expect(Immutable.Map({a: 1})).toEqualImmutable(Immutable.Map({a: 1}));
});
});
FAQs
Add a set of custom matchers for Immutable related checks.
The npm package jest-immutable-matchers receives a total of 9,567 weekly downloads. As such, jest-immutable-matchers popularity was classified as popular.
We found that jest-immutable-matchers 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.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.