Security News
PyPI’s New Archival Feature Closes a Major Security Gap
PyPI now allows maintainers to archive projects, improving security and helping users make informed decisions about their dependencies.
object-invariant-test-helper
Advanced tools
A module that is useful for testing whether you've mutated an object. Use it with [redux](http://redux.js.org/ 'redux.js.org') when testing your reducers to ensure you don't ever mutate an object in a reducer but always return a new object.
A module that is useful for testing whether you've mutated an object. Use it with redux when testing your reducers to ensure you don't ever mutate an object in a reducer but always return a new object.
This module began life as a fork of redux-immutable-state-invariant by Leonardo Andres Garcia Crespo (@leoasis).
This lib is intended for use only during development, specifically testing.
Don't use this in production!
npm install --save-dev object-invariant-test-helper
import objectInvariantTestHelper from '../src/index';
const toAdd = 2;
const expectedState = {num: 3};
describe('goodReducer', () => {
it('should *not* mutate state', () => {
let initialState = {num: 1};
const tracked = objectInvariantTestHelper.trackObj(initialState);
let finalState = goodReducer(initialState, {
type: 'ADD',
payload: { toAdd }
});
expect(finalState).toEqual(expectedState);
expect(objectInvariantTestHelper.hasMutated(tracked)).toEqual(false);
});
});
If you want to provide your own isImmutable
function, you may:
import { objectInvariantTestHelperMkr } from '../src/index';
let objectInvariantTestHelper = objectInvariantTestHelperMkr(isImmutable);
FAQs
A module that is useful for testing whether you've mutated an object. Use it with [redux](http://redux.js.org/ 'redux.js.org') when testing your reducers to ensure you don't ever mutate an object in a reducer but always return a new object.
We found that object-invariant-test-helper 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
PyPI now allows maintainers to archive projects, improving security and helping users make informed decisions about their dependencies.
Research
Security News
Malicious npm package postcss-optimizer delivers BeaverTail malware, targeting developer systems; similarities to past campaigns suggest a North Korean connection.
Security News
CISA's KEV data is now on GitHub, offering easier access, API integration, commit history tracking, and automated updates for security teams and researchers.