Installations
npm install expect-more-jasmine
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
75.4
Supply Chain
98.1
Quality
75.4
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
31,816
Last Day
2
Last Week
20
Last Month
251
Last Year
4,708
GitHub Statistics
171 Stars
209 Commits
10 Forks
5 Watching
3 Branches
3 Contributors
Bundle Size
147.38 kB
Minified
30.79 kB
Minified + Gzipped
Package Meta Information
Latest Version
0.5.0
Package Id
expect-more-jasmine@0.5.0
Unpacked Size
214.79 kB
Size
26.55 kB
File Count
237
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
31,816
Last day
-50%
2
Compared to previous day
Last week
-74%
20
Compared to previous week
Last month
-44.2%
251
Compared to previous month
Last year
-31.1%
4,708
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Dependencies
2
expect-more-jasmine
Write Beautiful Specs with Custom Matchers for Jasmine
Table of Contents
Overview
expect-more-jasmine 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-jasmine --save-dev
🕹 Configuration
import 'expect-more-jasmine'
or require('expect-more-jasmine')
at the top your test file.
🔬 Matchers
1describe('expect-more-jasmine', () => { 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([2, true, 'string']).toBeArray(); 13 expect(async () => { 14 await fetch('...'); 15 }).toBeAsyncFunction(); 16 expect(new Date('2019-12-31')).toBeBefore(new Date('2020-01-01')); 17 expect(false).toBeBoolean(); 18 expect('100').toBeCalculable(); 19 expect(new Date('2019-12-11')).toBeDateBetween(new Date('2019-12-10'), new Date('2019-12-12')); 20 expect(new Date('2021-08-29')).toBeDateInMonth(7); 21 expect(new Date('2021-08-29')).toBeDateInYear(2021); 22 expect(new Date('2021-08-29')).toBeDateOnDayOfMonth(29); 23 expect(new Date('2021-08-29')).toBeDateOnDayOfWeek(0); 24 expect(new Date('2019-12-31')).toBeDateOnOrAfter(new Date('2019-12-15')); 25 expect(new Date('2019-12-15')).toBeDateOnOrBefore(new Date('2019-12-31')); 26 expect(new Date('2019-12-31')).toBeDate(); 27 expect(12.55).toBeDecimalNumber(); 28 expect(12).toBeDivisibleBy(2); 29 expect([]).toBeEmptyArray(); 30 expect({}).toBeEmptyObject(); 31 expect('').toBeEmptyString(); 32 expect(2).toBeEvenNumber(); 33 expect(() => 'i am a function').toBeFunction(); 34 expect(function* gen() { 35 yield 'i am a generator'; 36 }).toBeGeneratorFunction(); 37 expect('1999-12-31T23:59:59').toBeIso8601(); 38 expect('{"i":"am valid JSON"}').toBeJsonString(); 39 expect(['i', 'have', 3]).toBeLongerThan([2, 'items']); 40 expect(-18).toBeNegativeNumber(); 41 expect(undefined).toBeNil(); 42 expect(['i', 'am not empty']).toBeNonEmptyArray(); 43 expect({ i: 'am not empty' }).toBeNonEmptyObject(); 44 expect('i am not empty').toBeNonEmptyString(); 45 expect(8).toBeNumber(); 46 expect({}).toBeObject(); 47 expect(5).toBeOddNumber(); 48 expect(5).toBePositiveNumber(); 49 expect(new RegExp('i am a regular expression')).toBeRegExp(); 50 expect(['i also have', '2 items']).toBeSameLengthAs(['i have', '2 items']); 51 expect(['i have one item']).toBeShorterThan(['i', 'have', 4, 'items']); 52 expect('i am a string').toBeString(); 53 expect(new Date('2020-01-01')).toBeValidDate(); 54 expect('i am visible').toBeVisibleString(); 55 expect({}).toBeWalkable(); 56 expect(' ').toBeWhitespace(); 57 expect(8).toBeWholeNumber(); 58 expect(7).toBeWithinRange(0, 10); 59 expect('JavaScript').toEndWith('Script'); 60 expect({ child: { grandchild: [12, 0, 14, 'Ivo'] } }).toHaveArrayIncludingAllOf('child.grandchild', ['Ivo', 14]); 61 expect({ child: { grandchild: [12, 0, 14, 'Ginola'] } }).toHaveArrayIncludingAnyOf('child.grandchild', ['Ginola', 3]); 62 expect({ child: { grandchild: [5, 10, 1] } }).toHaveArrayIncludingOnly('child.grandchild', [1, 5, 10]); 63 expect({ child: { grandchild: [true, false, new Boolean(true)] } }).toHaveArrayOfBooleans('child.grandchild'); 64 expect({ child: { grandchild: [12, 0, 14] } }).toHaveArrayOfNumbers('child.grandchild'); 65 expect({ child: { grandchild: [{}, new Object()] } }).toHaveArrayOfObjects('child.grandchild'); 66 expect({ child: { grandchild: ['i', 'contain', 4, 'items'] } }).toHaveArrayOfSize('child.grandchild', 4); 67 expect({ child: { grandchild: ['we', 'are', 'all', 'strings'] } }).toHaveArrayOfStrings('child.grandchild'); 68 expect({ child: { grandchild: [2, true, 'string'] } }).toHaveArray('child.grandchild'); 69 expect({ 70 child: { 71 grandchild: async () => { 72 await fetch('...'); 73 }, 74 }, 75 }).toHaveAsyncFunction('child.grandchild'); 76 expect({ child: { grandchild: false } }).toHaveBoolean('child.grandchild'); 77 expect({ child: { grandchild: '100' } }).toHaveCalculable('child.grandchild'); 78 expect({ child: { grandchild: new Date('2020-01-01') } }).toHaveDateAfter('child.grandchild', new Date('2019-12-31')); 79 expect({ child: { grandchild: new Date('2019-12-31') } }).toHaveDateBefore('child.grandchild', new Date('2020-01-01')); 80 expect({ child: { grandchild: new Date('2019-12-11') } }).toHaveDateBetween('child.grandchild', new Date('2019-12-10'), new Date('2019-12-12')); 81 expect({ child: { grandchild: new Date('2021-08-29') } }).toHaveDateInMonth('child.grandchild', 7); 82 expect({ child: { grandchild: new Date('2021-08-29') } }).toHaveDateInYear('child.grandchild', 2021); 83 expect({ child: { grandchild: new Date('2021-08-29') } }).toHaveDateOnDayOfMonth('child.grandchild', 29); 84 expect({ child: { grandchild: new Date('2021-08-29') } }).toHaveDateOnDayOfWeek('child.grandchild', 0); 85 expect({ child: { grandchild: new Date('2019-12-31') } }).toHaveDateOnOrAfter('child.grandchild', new Date('2019-12-15')); 86 expect({ child: { grandchild: new Date('2019-12-15') } }).toHaveDateOnOrBefore('child.grandchild', new Date('2019-12-31')); 87 expect({ child: { grandchild: new Date('2019-12-31') } }).toHaveDate('child.grandchild'); 88 expect({ child: { grandchild: 12.55 } }).toHaveDecimalNumber('child.grandchild'); 89 expect({ child: { grandchild: 12 } }).toHaveDivisibleBy('child.grandchild', 2); 90 expect({ child: { grandchild: [] } }).toHaveEmptyArray('child.grandchild'); 91 expect({ child: { grandchild: {} } }).toHaveEmptyObject('child.grandchild'); 92 expect({ child: { grandchild: '' } }).toHaveEmptyString('child.grandchild'); 93 expect({ child: { grandchild: 'JavaScript' } }).toHaveEndingWith('child.grandchild', 'Script'); 94 expect({ child: { grandchild: 2 } }).toHaveEvenNumber('child.grandchild'); 95 expect({ child: { grandchild: false } }).toHaveFalse('child.grandchild'); 96 expect({ 97 child: { 98 grandchild: function* gen() { 99 yield 'i am a generator'; 100 }, 101 }, 102 }).toHaveGeneratorFunction('child.grandchild'); 103 expect({ child: { grandchild: 10 } }).toHaveGreaterThanOrEqualTo('child.grandchild', 5); 104 expect({ child: { grandchild: '1999-12-31T23:59:59' } }).toHaveIso8601('child.grandchild'); 105 expect({ child: { grandchild: '{"i":"am valid JSON"}' } }).toHaveJsonString('child.grandchild'); 106 expect({ child: { grandchild: 8 } }).toHaveLessThanOrEqualTo('child.grandchild', 12); 107 expect({ child: { grandchild: ['i', 'have', 3] } }).toHaveLongerThan('child.grandchild', [2, 'items']); 108 expect({ child: { grandchild: () => 'i am a function' } }).toHaveMethod('child.grandchild'); 109 expect({ child: { grandchild: -18 } }).toHaveNegativeNumber('child.grandchild'); 110 expect({ child: { grandchild: undefined } }).toHaveNil('child.grandchild'); 111 expect({ child: { grandchild: ['i', 'am not empty'] } }).toHaveNonEmptyArray('child.grandchild'); 112 expect({ child: { grandchild: { i: 'am not empty' } } }).toHaveNonEmptyObject('child.grandchild'); 113 expect({ child: { grandchild: 'i am not empty' } }).toHaveNonEmptyString('child.grandchild'); 114 expect({ child: { grandchild: null } }).toHaveNull('child.grandchild'); 115 expect({ child: { grandchild: 4.8 } }).toHaveNumberNear('child.grandchild', 5, 0.5); 116 expect({ child: { grandchild: 7 } }).toHaveNumberWithinRange('child.grandchild', 0, 10); 117 expect({ child: { grandchild: 8 } }).toHaveNumber('child.grandchild'); 118 expect({ child: { grandchild: {} } }).toHaveObject('child.grandchild'); 119 expect({ child: { grandchild: 5 } }).toHaveOddNumber('child.grandchild'); 120 expect({ child: { grandchild: 5 } }).toHavePositiveNumber('child.grandchild'); 121 expect({ child: { grandchild: new RegExp('i am a regular expression') } }).toHaveRegExp('child.grandchild'); 122 expect({ child: { grandchild: ['i also have', '2 items'] } }).toHaveSameLengthAs('child.grandchild', ['i have', '2 items']); 123 expect({ child: { grandchild: ['i have one item'] } }).toHaveShorterThan('child.grandchild', ['i', 'have', 4, 'items']); 124 expect({ child: { grandchild: 'JavaScript' } }).toHaveStartingWith('child.grandchild', 'Java'); 125 expect({ child: { grandchild: 'i am a string' } }).toHaveString('child.grandchild'); 126 expect({ child: { grandchild: true } }).toHaveTrue('child.grandchild'); 127 expect({ child: { grandchild: undefined } }).toHaveUndefined('child.grandchild'); 128 expect({ child: { grandchild: new Date('2020-01-01') } }).toHaveValidDate('child.grandchild'); 129 expect({ child: { grandchild: 'i am visible' } }).toHaveVisibleString('child.grandchild'); 130 expect({ child: { grandchild: {} } }).toHaveWalkable('child.grandchild'); 131 expect({ child: { grandchild: ' ' } }).toHaveWhitespace('child.grandchild'); 132 expect({ child: { grandchild: 8 } }).toHaveWholeNumber('child.grandchild'); 133 expect('JavaScript').toStartWith('Java'); 134 }); 135});
🙋🏽♂️ 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 More