@@ -7,8 +7,11 @@ import * as fg from '.';
77describe ( 'Package' , ( ) => {
88 describe ( '.sync' , ( ) => {
99 it ( 'should throw an error when input values can not pass validation' , ( ) => {
10+ const message = 'Patterns must be a string (non empty) or an array of strings' ;
11+
1012 // eslint-disable-next-line @typescript-eslint/no-explicit-any
11- assert . throws ( ( ) => fg . sync ( null as any ) , / T y p e E r r o r : P a t t e r n s m u s t b e a s t r i n g o r a n a r r a y o f s t r i n g s / ) ;
13+ assert . throws ( ( ) => fg . sync ( null as any ) , { message } ) ;
14+ assert . throws ( ( ) => fg . sync ( '' ) , { message } ) ;
1215 } ) ;
1316
1417 it ( 'should returns entries' , ( ) => {
@@ -49,13 +52,11 @@ describe('Package', () => {
4952
5053 describe ( '.async' , ( ) => {
5154 it ( 'should throw an error when input values can not pass validation' , async ( ) => {
52- try {
53- // eslint-disable-next-line @typescript-eslint/no-explicit-any
54- await fg ( null as any ) ;
55- throw new Error ( 'An unexpected error was found.' ) ;
56- } catch ( error ) {
57- assert . strictEqual ( ( error as Error ) . toString ( ) , 'TypeError: Patterns must be a string or an array of strings' ) ;
58- }
55+ const message = 'Patterns must be a string (non empty) or an array of strings' ;
56+
57+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
58+ await assert . rejects ( ( ) => fg ( null as any ) , { message } ) ;
59+ await assert . rejects ( ( ) => fg ( '' ) , { message } ) ;
5960 } ) ;
6061
6162 it ( 'should returns entries' , async ( ) => {
@@ -96,8 +97,11 @@ describe('Package', () => {
9697
9798 describe ( '.stream' , ( ) => {
9899 it ( 'should throw an error when input values can not pass validation' , ( ) => {
100+ const message = 'Patterns must be a string (non empty) or an array of strings' ;
101+
99102 // eslint-disable-next-line @typescript-eslint/no-explicit-any
100- assert . throws ( ( ) => fg . stream ( null as any ) , / T y p e E r r o r : P a t t e r n s m u s t b e a s t r i n g o r a n a r r a y o f s t r i n g s / ) ;
103+ assert . throws ( ( ) => fg . stream ( null as any ) , { message } ) ;
104+ assert . throws ( ( ) => fg . stream ( '' ) , { message } ) ;
101105 } ) ;
102106
103107 it ( 'should returns entries' , ( done ) => {
@@ -152,8 +156,11 @@ describe('Package', () => {
152156
153157 describe ( '.generateTasks' , ( ) => {
154158 it ( 'should throw an error when input values can not pass validation' , ( ) => {
159+ const message = 'Patterns must be a string (non empty) or an array of strings' ;
160+
155161 // eslint-disable-next-line @typescript-eslint/no-explicit-any
156- assert . throws ( ( ) => fg . generateTasks ( null as any ) , / T y p e E r r o r : P a t t e r n s m u s t b e a s t r i n g o r a n a r r a y o f s t r i n g s / ) ;
162+ assert . throws ( ( ) => fg . generateTasks ( null as any ) , { message } ) ;
163+ assert . throws ( ( ) => fg . generateTasks ( '' ) , { message } ) ;
157164 } ) ;
158165
159166 it ( 'should return tasks' , ( ) => {
0 commit comments