
Security News
High Salaries No Longer Enough to Attract Top Cybersecurity Talent
A survey of 500 cybersecurity pros reveals high pay isn't enough—lack of growth and flexibility is driving attrition and risking organizational security.
jest-to-be-typed
Advanced tools
Jest matcher that allows you to test the expected type of value.
npm i jest-to-be-typed
yarn add jest-to-be-typed
Add jest-to-be-typed
to your Jest setupFilesAfterEnv
configuration. See for help
"jest": {
"setupFilesAfterEnv": ["jest-to-be-typed"]
}
"jest": {
"setupTestFrameworkScriptFile": "jest-to-be-typed"
}
OR
Simply import toBeTyped
// *.test.js
import toBeTyped from 'jest-to-be-typed'
expect.extend(toBeTyped);
There are two kinds of modes.
Default mode checks typeof expected value.
expect('').toBeTyped('string');
expect({}).toBeTyped('object');
expect(1).toBeTyped('number');
expect(false).toBeTyped('boolean');
expect(Symbol('foobar')).toBeTyped('symbol');
expect(() => {}).toBeTyped('function');
expect([]).toBeTyped('array');
expect(/foobar/).toBeTyped('regexp');
expect(new RegExp('foobar')).toBeTyped('regexp');
expect(null).toBeTyped('null');
expect(undefined).toBeTyped('undefined');
expect(new Map()).toBeTyped('map');
expect(new Set()).toBeTyped('set');
expect(new Date()).toBeTyped('date');
expect(Promise.resolve([])).resolves.toBeTyped('array');
Advanced mode is somelike typescript interface.
const data = {
name: 'eddie',
age: 13,
address: [],
isMarried: false
};
const types = {
name: 'string',
age: 'number',
address: 'array',
isMarried: 'boolean'
};
expect(data).toBeTyped(types);
Inspired by jest-tobetype
FAQs
type checking using jest
The npm package jest-to-be-typed receives a total of 10 weekly downloads. As such, jest-to-be-typed popularity was classified as not popular.
We found that jest-to-be-typed 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
A survey of 500 cybersecurity pros reveals high pay isn't enough—lack of growth and flexibility is driving attrition and risking organizational security.
Product
Socket, the leader in open source security, is now available on Google Cloud Marketplace for simplified procurement and enhanced protection against supply chain attacks.
Security News
Corepack will be phased out from future Node.js releases following a TSC vote.