2.0.0 • Published 4 months ago

@bloombug/jest-money v2.0.0

Weekly downloads
-
License
MIT
Repository
-
Last release
4 months ago

@bloombug/jest-money

Jest matchers for @bloombug/money.

Installation

npm install @bloombug/jest-money --save
yarn add @bloombug/jest-money

Import @bloombug/jest-money once (for instance in your tests setup file) and you're good to go:

// In your own jest-setup.js (or any other name)
import '@bloombug/jest-money';

// In jest.config.js add (if you haven't already)
setupFilesAfterEnv: ['<rootDir>/jest-setup.js'];

TypeScript

If you're using TypeScript, make sure your setup file is a .ts and not a .js to include the necessary types.

You will also need to include your setup file in your tsconfig.json if you haven't already:

// In tsconfig.json
"include": [
  ...
  "./jest-setup.ts"
],

Custom matchers

toEqualCurrency

This allows you to check whether a currency is equal to another.

expect(Currency(USD)).toEqualCurrency(Currency(USD));
expect(Currency(USD)).not.toEqualCurrency(Currency(CAD));

toEqualMoney

This allows you to check whether a money is equal to another.

expect(Money(100, USD)).toEqualCurrency(Money(100, USD));
expect(Money(100, USD)).not.toEqualCurrency(Money(100, CAD));

Docs

See docs site for more details, API, and other docs.

2.0.0

4 months ago

1.3.0

2 years ago

1.2.0

2 years ago

1.1.6

2 years ago

1.1.5

2 years ago