Gathering detailed insights and metrics for expect-more-jasmine
Gathering detailed insights and metrics for expect-more-jasmine
Gathering detailed insights and metrics for expect-more-jasmine
Gathering detailed insights and metrics for expect-more-jasmine
npm install expect-more-jasmine
Typescript
Module System
Node Version
NPM Version
75.4
Supply Chain
98.1
Quality
75.4
Maintenance
100
Vulnerability
99.6
License
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
TypeScript (98.66%)
JavaScript (1.31%)
Shell (0.03%)
Total Downloads
31,816
Last Day
2
Last Week
20
Last Month
251
Last Year
4,708
171 Stars
209 Commits
10 Forks
5 Watching
3 Branches
3 Contributors
Minified
Minified + Gzipped
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
Cumulative downloads
Total Downloads
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
2
Write Beautiful Specs with Custom Matchers for Jasmine
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()
.
npm install expect-more-jasmine --save-dev
import 'expect-more-jasmine'
or require('expect-more-jasmine')
at the top your test file.
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});
Get help with issues by creating a Bug Report or discuss ideas by opening a Feature Request.
If you find my Open Source projects useful, please share them ❤️
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
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
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
14 existing vulnerabilities detected
Details
Score
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