Skip to content

πŸƒπŸ˜‚ Make jest expect more convenient.

Notifications You must be signed in to change notification settings

hustcc/jest-expect

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

7 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

jest-expect

Make jest expect more convenient.

Build Status Coverage Status npm npm

Install

This should only be installed as a development dependency (devDependencies) as it is only designed for testing.

npm i --save-dev jest-expect

Setup

Add jest-extended to your Jest setupTestFrameworkScriptFile configuration. See for help

{
  "jest": {
    "setupTestFrameworkScriptFile": "jest-expect"
  }
}

API


Number

toBeApproximate

Use toBeApproximate to checkout if a value is approximately equal to a Number.

test('toBeApproximate', () => {
  expect(Math.PI).toBeApproximate(3);
  expect(Math.PI).toBeApproximate(3.14);
  expect(Math.PI).toBeApproximate(3.1416);
  
  expect(Math.PI).not.toBeApproximate(4);
  expect(Math.PI).not.toBeApproximate(3.15);
  expect(Math.PI).not.toBeApproximate(3.1415);
});

License

MIT@hustcc.

Releases

No releases published

Packages

No packages published