@@ -17,6 +17,7 @@ class AssertionError extends Error {
1717
1818 this . assertion = opts . assertion ;
1919 this . fixedSource = opts . fixedSource ;
20+ this . improperUsage = opts . improperUsage || false ;
2021 this . operator = opts . operator ;
2122 this . values = opts . values || [ ] ;
2223
@@ -130,6 +131,7 @@ function wrapAssertions(callbacks) {
130131 } else if ( typeof fn !== 'function' ) {
131132 fail ( this , new AssertionError ( {
132133 assertion : 'throws' ,
134+ improperUsage : true ,
133135 message : '`t.throws()` must be called with a function, Promise, or Observable' ,
134136 values : [ formatAssertError . formatWithLabel ( 'Called with:' , fn ) ]
135137 } ) ) ;
@@ -200,6 +202,7 @@ function wrapAssertions(callbacks) {
200202 } else if ( typeof fn !== 'function' ) {
201203 fail ( this , new AssertionError ( {
202204 assertion : 'notThrows' ,
205+ improperUsage : true ,
203206 message : '`t.notThrows()` must be called with a function, Promise, or Observable' ,
204207 values : [ formatAssertError . formatWithLabel ( 'Called with:' , fn ) ]
205208 } ) ) ;
@@ -315,13 +318,15 @@ function wrapAssertions(callbacks) {
315318 if ( typeof string !== 'string' ) {
316319 throw new AssertionError ( {
317320 assertion : 'regex' ,
321+ improperUsage : true ,
318322 message : '`t.regex()` must be called with a string' ,
319323 values : [ formatAssertError . formatWithLabel ( 'Called with:' , string ) ]
320324 } ) ;
321325 }
322326 if ( ! ( regex instanceof RegExp ) ) {
323327 throw new AssertionError ( {
324328 assertion : 'regex' ,
329+ improperUsage : true ,
325330 message : '`t.regex()` must be called with a regular expression' ,
326331 values : [ formatAssertError . formatWithLabel ( 'Called with:' , regex ) ]
327332 } ) ;
@@ -343,13 +348,15 @@ function wrapAssertions(callbacks) {
343348 if ( typeof string !== 'string' ) {
344349 throw new AssertionError ( {
345350 assertion : 'notRegex' ,
351+ improperUsage : true ,
346352 message : '`t.notRegex()` must be called with a string' ,
347353 values : [ formatAssertError . formatWithLabel ( 'Called with:' , string ) ]
348354 } ) ;
349355 }
350356 if ( ! ( regex instanceof RegExp ) ) {
351357 throw new AssertionError ( {
352358 assertion : 'notRegex' ,
359+ improperUsage : true ,
353360 message : '`t.notRegex()` must be called with a regular expression' ,
354361 values : [ formatAssertError . formatWithLabel ( 'Called with:' , regex ) ]
355362 } ) ;
0 commit comments