Research
Security News
Kill Switch Hidden in npm Packages Typosquatting Chalk and Chokidar
Socket researchers found several malicious npm packages typosquatting Chalk and Chokidar, targeting Node.js developers with kill switches and data theft.
purify-asserts
Advanced tools
Jest expectations for the purify-ts library
Purify is an excellent library for functional TypeScript applications, but its algebraic data types are not so obvious to test. Specifically, the following convention examples are not easy to remember in the scope of unit tests.
expect(maybe.isJust()).toBe(true);
expect(maybe.isNothing()).toBe(true);
expect(maybe.extract()).toEqual("value");
expect(either.isLeft()).toBe(false);
expect(either.isRight()).toBe(true);
expect(either.extract()).toEqual("is this success or error?");
Wouldn't it be more satisfying to assert expectations with the same domain language Purify speaks of? I think so.
expect(possiblyNullableMaybe).toBeJust();
expect(justOrNothing).toBeNothing();
expect(justOrNothing).toHaveJustValue(1);
npm install --save-dev purify-asserts
yarn add --dev purify-asserts
Using matchers requires to use the expect.extend()
method of Jest. These should be imported and used at the beginning of your test suite above the first describe()
block.
Import all of the matchers:
import * as matchers from "purify-asserts";
expect.extend(matchers);
Import only selected matchers:
import { toBeJust, toBeNothing } from "purify-asserts";
expect.extend({ toBeJust, toBeNothing });
Maybe<T>
matchersEither<L, R>
matchers (work in progress)MaybeAsync<T>
matchers (work in progress)EitherAsync<L, R>
matchers (work in progress)Tuple<F, S>
matchers (work in progress)NonEmptyList<T>
matchers (work in progress)Codec<T>
matchers (work in progress)👤 Niko Heikkilä yo@nikoheikkila.fi
Contributions, issues and feature requests are welcome!
Feel free to check issues page.
Give a ⭐️ if this project helped you!
This README was generated with ❤️ by readme-md-generator
FAQs
Jest expectations for the purify-ts library
The npm package purify-asserts receives a total of 3 weekly downloads. As such, purify-asserts popularity was classified as not popular.
We found that purify-asserts 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 researchers found several malicious npm packages typosquatting Chalk and Chokidar, targeting Node.js developers with kill switches and data theft.
Security News
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
Product
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.