Installations
npm install expect-more-jest
Developer Guide
Typescript
No
Module System
CommonJS
Node Version
16.16.0
NPM Version
lerna/6.4.1/node@v16.16.0+x64 (darwin)
Score
97.2
Supply Chain
99
Quality
75.8
Maintenance
100
Vulnerability
99.6
License
Releases
expect-more-jest@5.4.1
Published on 04 Jun 2022
expect-more-jest@5.4.0
Published on 04 Jun 2022
expect-more-jasmine@0.3.0
Published on 08 Aug 2021
expect-more-jest@5.3.0
Published on 08 Aug 2021
expect-more@1.1.0
Published on 08 Aug 2021
1.0.1
Published on 29 Jan 2021
Contributors
Unable to fetch Contributors
Languages
TypeScript (98.66%)
JavaScript (1.31%)
Shell (0.03%)
Developer
JamieMason
Download Statistics
Total Downloads
4,123,483
Last Day
2,104
Last Week
10,933
Last Month
98,951
Last Year
1,346,666
GitHub Statistics
171 Stars
209 Commits
10 Forks
5 Watching
3 Branches
3 Contributors
Bundle Size
123.39 kB
Minified
30.36 kB
Minified + Gzipped
Package Meta Information
Latest Version
5.5.0
Package Id
expect-more-jest@5.5.0
Unpacked Size
129.04 kB
Size
17.04 kB
File Count
125
NPM Version
lerna/6.4.1/node@v16.16.0+x64 (darwin)
Node Version
16.16.0
Publised On
31 Jan 2023
Total Downloads
Cumulative downloads
Total Downloads
4,123,483
Last day
22.5%
2,104
Compared to previous day
Last week
-42.9%
10,933
Compared to previous week
Last month
-29.7%
98,951
Compared to previous month
Last year
24.4%
1,346,666
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Dependencies
3
expect-more-jest
Write Beautiful Specs with Custom Matchers for Jest
Table of Contents
Overview
expect-more-jest is a huge library of test matchers for a range of common use-cases, to make tests easier to read and produce relevant and useful messages when they fail.
Avoid vague messages such as "expected false to be true" in favour of useful cues like "expected
3 to be even number", and avoid implementation noise such as
expect(paws.length % 2 === 0).toEqual(true)
in favour of simply stating that you
expect(paws.length).toBeEvenNumber()
.
🌩 Installation
npm install expect-more-jest --save-dev
🕹 Configuration
Include one of the following at the top of your test file.
1import 'expect-more-jest'; 2// or 3require('expect-more-jest');
🔬 Matchers
1describe('expect-more-jest', () => { 2 it('makes your tests and output easier to read', () => { 3 expect(new Date('2020-01-01')).toBeAfter(new Date('2019-12-31')); 4 expect([12, 0, 14, 'Ivo']).toBeArrayIncludingAllOf(['Ivo', 14]); 5 expect([12, 0, 14, 'Ginola']).toBeArrayIncludingAnyOf(['Ginola', 3]); 6 expect([5, 10, 1]).toBeArrayIncludingOnly([1, 5, 10]); 7 expect([true, false, new Boolean(true)]).toBeArrayOfBooleans(); 8 expect([12, 0, 14]).toBeArrayOfNumbers(); 9 expect([{}, new Object()]).toBeArrayOfObjects(); 10 expect(['i', 'contain', 4, 'items']).toBeArrayOfSize(4); 11 expect(['we', 'are', 'all', 'strings']).toBeArrayOfStrings(); 12 expect([{ name: 'Guybrush' }, { name: 'Elaine' }]).toBeArrayOf({ 13 name: expect.toBeNonEmptyString(), 14 }); 15 expect([2, true, 'string']).toBeArray(); 16 expect(async () => { 17 await fetch('...'); 18 }).toBeAsyncFunction(); 19 expect(new Date('2019-12-31')).toBeBefore(new Date('2020-01-01')); 20 expect(false).toBeBoolean(); 21 expect('100').toBeCalculable(); 22 expect(new Date('2019-12-11')).toBeDateBetween(new Date('2019-12-10'), new Date('2019-12-12')); 23 expect(new Date('2021-08-29')).toBeDateInMonth(7); 24 expect(new Date('2021-08-29')).toBeDateInYear(2021); 25 expect(new Date('2021-08-29')).toBeDateOnDayOfMonth(29); 26 expect(new Date('2021-08-29')).toBeDateOnDayOfWeek(0); 27 expect(new Date('2019-12-31')).toBeDateOnOrAfter(new Date('2019-12-15')); 28 expect(new Date('2019-12-15')).toBeDateOnOrBefore(new Date('2019-12-31')); 29 expect(new Date('2019-12-31')).toBeDate(); 30 expect(12.55).toBeDecimalNumber(); 31 expect(12).toBeDivisibleBy(2); 32 expect([]).toBeEmptyArray(); 33 expect({}).toBeEmptyObject(); 34 expect('').toBeEmptyString(); 35 expect(2).toBeEvenNumber(); 36 expect(false).toBeFalse(); 37 expect(() => 'i am a function').toBeFunction(); 38 expect(function* gen() { 39 yield 'i am a generator'; 40 }).toBeGeneratorFunction(); 41 expect('1999-12-31T23:59:59').toBeIso8601(); 42 expect('{"i":"am valid JSON"}').toBeJsonString(); 43 expect(['i', 'have', 3]).toBeLongerThan([2, 'items']); 44 expect(-18).toBeNegativeNumber(); 45 expect(undefined).toBeNil(); 46 expect(['i', 'am not empty']).toBeNonEmptyArray(); 47 expect({ i: 'am not empty' }).toBeNonEmptyObject(); 48 expect('i am not empty').toBeNonEmptyString(); 49 expect({ x: 12, y: 22 }).toBeNullableOf({ 50 x: expect.toBeNumber(), 51 y: expect.toBeNumber(), 52 }); 53 expect(null).toBeNullableOf({ 54 x: expect.toBeNumber(), 55 y: expect.toBeNumber(), 56 }); 57 expect(8).toBeNumber(); 58 expect({}).toBeObject(); 59 expect(5).toBeOddNumber(); 60 expect({ x: 12, y: 22 }).toBeOptionalOf({ 61 x: expect.toBeNumber(), 62 y: expect.toBeNumber(), 63 }); 64 expect(undefined).toBeOptionalOf({ 65 x: expect.toBeNumber(), 66 y: expect.toBeNumber(), 67 }); 68 expect(5).toBePositiveNumber(); 69 expect(new RegExp('i am a regular expression')).toBeRegExp(); 70 expect(['i also have', '2 items']).toBeSameLengthAs(['i have', '2 items']); 71 expect(['i have one item']).toBeShorterThan(['i', 'have', 4, 'items']); 72 expect('i am a string').toBeString(); 73 expect(true).toBeTrue(); 74 expect(new Date('2020-01-01')).toBeValidDate(); 75 expect('i am visible').toBeVisibleString(); 76 expect({}).toBeWalkable(); 77 expect(' ').toBeWhitespace(); 78 expect(8).toBeWholeNumber(); 79 expect(7).toBeWithinRange(0, 10); 80 expect('JavaScript').toEndWith('Script'); 81 expect('JavaScript').toStartWith('Java'); 82 }); 83});
🙋🏽♂️ Getting Help
Get help with issues by creating a Bug Report or discuss ideas by opening a Feature Request.
👀 Other Projects
If you find my Open Source projects useful, please share them ❤️
- eslint-formatter-git-log
ESLint Formatter featuring Git Author, Date, and Hash - eslint-plugin-move-files
Move and rename files while keeping imports up to date - eslint-plugin-prefer-arrow-functions
Convert functions to arrow functions - ImageOptim-CLI
Automates ImageOptim, ImageAlpha, and JPEGmini for Mac to make batch optimisation of images part of your automated build process. - karma-benchmark
Run Benchmark.js over multiple Browsers, with CI compatible output - self-help
Interactive Q&A Guides for Web and the Command Line - syncpack
Manage multiple package.json files, such as in Lerna Monorepos and Yarn Workspaces
🤓 Author
I'm Jamie Mason from Leeds in England, I began Web Design and Development in 1999 and have been Contracting and offering Consultancy as Fold Left Ltd since 2012. Who I've worked with includes Sky Sports, Sky Bet, Sky Poker, The Premier League, William Hill, Shell, Betfair, and Football Clubs including Leeds United, Spurs, West Ham, Arsenal, and more.
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
- Info: project has a license file: LICENSE:0
- Info: FSF or OSI recognized license: MIT License: LICENSE:0
Reason
Found 0/23 approved changesets -- score normalized to 0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'master'
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
- Warn: 0 commits out of 7 are checked with a SAST tool
Reason
14 existing vulnerabilities detected
Details
- Warn: Project is vulnerable to: GHSA-67hx-6x53-jw92
- Warn: Project is vulnerable to: GHSA-wf5p-g6vw-rhxx
- Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg
- Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275
- Warn: Project is vulnerable to: GHSA-ghr5-ch3p-vcr6
- Warn: Project is vulnerable to: GHSA-jchw-25xp-jwwc
- Warn: Project is vulnerable to: GHSA-cxjh-pqwp-8mfp
- Warn: Project is vulnerable to: GHSA-rc47-6667-2j5j
- Warn: Project is vulnerable to: GHSA-78xj-cgh5-2h22
- Warn: Project is vulnerable to: GHSA-2p57-rm9w-gvfp
- Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv
- Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw
- Warn: Project is vulnerable to: GHSA-f5x3-32g6-xq36
- Warn: Project is vulnerable to: GHSA-j8xg-fqg3-53r7
Score
1.7
/10
Last Scanned on 2025-01-13
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn MoreOther packages similar to expect-more-jest
expect-even-more-jest
expect-more-jest with even more stuff
jest-expect
Make jest expect more convenient.
expect-more-jasmine
Write Beautiful Specs with Custom Matchers for Jasmine
rocket-tester
- [jest-extended](https://github.com/jest-community/jest-extended) - [expect-more](https://github.com/JamieMason/expect-more/) - [jest-generator](https://github.com/doniyor2109/jest-generator)