
Security Fundamentals
Obfuscation 101: Unmasking the Tricks Behind Malicious Code
Attackers use obfuscation to hide malware in open source packages. Learn how to spot these techniques across npm, PyPI, Maven, and more.
@pacote/jest-either
Advanced tools
Additional matchers for Jest making it easier to test Either
objects.
yarn add @pacote/jest-either
import matchers from '@pacote/jest-either'
expect.extend(matchers)
.toBeRight()
import { left, right } from 'fp-ts/lib/Either'
test('passes when Either is a right', () => {
const actual = right({ test: 'ok' })
expect(actual).toBeRight()
})
test('passes when Either is a left', () => {
const actual = left(Error())
expect(actual).not.toBeRight()
})
.toBeLeft()
import { left, right } from 'fp-ts/lib/Either'
test('passes when Either is a left', () => {
const actual = left(Error())
expect(actual).toBeLeft()
})
test('passes when Either is a right', () => {
const actual = right({ test: 'ok' })
expect(actual).not.toBeLeft()
})
.toEqualRight(value)
import { right } from 'fp-ts/lib/Either'
test('passes when right of Either equals a value', () => {
const actual = right({ test: 'ok' })
expect(actual).toEqualRight({ test: 'ok' })
})
test('passes when right of Either does not equal a value', () => {
const actual = right({ test: 'unexpected' })
expect(actual).not.toEqualRight({ test: 'ok' })
})
.toEqualLeft(value)
import { left } from 'fp-ts/lib/Either'
test('passes when left of Either equals a value', () => {
const actual = left(Error('message'))
expect(actual).toEqualLeft(Error('message'))
})
test('passes when left of Either does not equal a value', () => {
const actual = left(Error('unexpected'))
expect(actual).not.toEqualLeft(Error('message'))
})
.toMatchRight(object)
import { right } from 'fp-ts/lib/Either'
test('passes when right of Either matches an object', () => {
const actual = right({ test: 'ok', foo: 'bar' })
expect(actual).toMatchRight({ test: 'ok' })
})
test('passes when right of Either does not match an object', () => {
const actual = right({ test: 'unexpected', foo: 'bar' })
expect(actual).not.toMatchRight({ test: 'ok' })
})
.toMatchLeft(object)
import { left } from 'fp-ts/lib/Either'
test('passes when left of Either matches an object', () => {
const actual = left({ test: 'ok', foo: 'bar' })
expect(actual).toMatchLeft({ test: 'ok' })
})
test('passes when left of Either does not match an object', () => {
const actual = left({ test: 'unexpected', foo: 'bar' })
expect(actual).not.toMatchLeft({ test: 'ok' })
})
MIT © Luís Rodrigues.
FAQs
Jest matcher for Either objects.
We found that @pacote/jest-either demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers 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 Fundamentals
Attackers use obfuscation to hide malware in open source packages. Learn how to spot these techniques across npm, PyPI, Maven, and more.
Security News
Join Socket for exclusive networking events, rooftop gatherings, and one-on-one meetings during BSidesSF and RSA 2025 in San Francisco.
Security News
Biome's v2.0 beta introduces custom plugins, domain-specific linting, and type-aware rules while laying groundwork for HTML support and embedded language features in 2025.