File tree Expand file tree Collapse file tree 3 files changed +14
-0
lines changed
Expand file tree Collapse file tree 3 files changed +14
-0
lines changed Original file line number Diff line number Diff line change 44
55### Fixes
66
7+ - ` [expect] ` Add type definitions for asymmetric ` closeTo ` matcher ([ #12304 ] ( https://github.com/facebook/jest/pull/12304 ) )
8+
79### Chore & Maintenance
810
911### Performance
Original file line number Diff line number Diff line change @@ -74,6 +74,7 @@ interface AsymmetricMatchers {
7474 any ( sample : unknown ) : AsymmetricMatcher ;
7575 anything ( ) : AsymmetricMatcher ;
7676 arrayContaining ( sample : Array < unknown > ) : AsymmetricMatcher ;
77+ closeTo ( sample : number , precision ?: number ) : AsymmetricMatcher ;
7778 objectContaining ( sample : Record < string , unknown > ) : AsymmetricMatcher ;
7879 stringContaining ( sample : string ) : AsymmetricMatcher ;
7980 stringMatching ( sample : string | RegExp ) : AsymmetricMatcher ;
Original file line number Diff line number Diff line change @@ -25,6 +25,17 @@ expectType<void>(expect(['B']).toEqual(expect.not.arrayContaining(['A'])));
2525expectError ( expect ( [ 'A' ] ) . toEqual ( expect . not . arrayContaining ( 'A' ) ) ) ;
2626expectError ( expect ( [ 'A' ] ) . toEqual ( expect . not . arrayContaining ( ) ) ) ;
2727
28+ expectType < void > ( expect ( 0.1 + 0.2 ) . toEqual ( expect . closeTo ( 0.3 ) ) ) ;
29+ expectType < void > ( expect ( 0.1 + 0.2 ) . toEqual ( expect . closeTo ( 0.3 , 5 ) ) ) ;
30+ expectError ( expect ( 0.1 + 0.2 ) . toEqual ( expect . closeTo ( 'three' ) ) ) ;
31+ expectError ( expect ( 0.1 + 0.2 ) . toEqual ( expect . closeTo ( 0.3 , false ) ) ) ;
32+ expectError ( expect ( 0.1 + 0.2 ) . toEqual ( expect . closeTo ( ) ) ) ;
33+ expectType < void > ( expect ( 0.1 + 0.2 ) . toEqual ( expect . not . closeTo ( 0.3 ) ) ) ;
34+ expectType < void > ( expect ( 0.1 + 0.2 ) . toEqual ( expect . not . closeTo ( 0.3 , 5 ) ) ) ;
35+ expectError ( expect ( 0.1 + 0.2 ) . toEqual ( expect . not . closeTo ( 'three' ) ) ) ;
36+ expectError ( expect ( 0.1 + 0.2 ) . toEqual ( expect . not . closeTo ( 0.3 , false ) ) ) ;
37+ expectError ( expect ( 0.1 + 0.2 ) . toEqual ( expect . not . closeTo ( ) ) ) ;
38+
2839expectType < void > ( expect ( { a : 1 } ) . toEqual ( expect . objectContaining ( { a : 1 } ) ) ) ;
2940expectError ( expect ( { a : 1 } ) . toEqual ( expect . objectContaining ( 1 ) ) ) ;
3041expectError ( expect ( { a : 1 } ) . toEqual ( expect . objectContaining ( ) ) ) ;
You can’t perform that action at this time.
0 commit comments