File tree Expand file tree Collapse file tree 1 file changed +16
-1
lines changed Expand file tree Collapse file tree 1 file changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -124,13 +124,28 @@ const TSESLintPluginRef: { throwWhenRequiring: boolean } = {
124124
125125jest . mock ( '@typescript-eslint/eslint-plugin' , ( ) => {
126126 if ( TSESLintPluginRef . throwWhenRequiring ) {
127- throw new Error ( 'oh noes!' ) ;
127+ throw new ( class extends Error {
128+ public code = 'MODULE_NOT_FOUND' ;
129+ } ) ( ) ;
128130 }
129131
130132 return jest . requireActual ( '@typescript-eslint/eslint-plugin' ) ;
131133} ) ;
132134
133135describe ( 'error handling' , ( ) => {
136+ describe ( 'when an error is thrown accessing the base rule' , ( ) => {
137+ it ( 're-throws the error' , ( ) => {
138+ jest . mock ( '@typescript-eslint/eslint-plugin' , ( ) => {
139+ throw new Error ( 'oh noes!' ) ;
140+ } ) ;
141+
142+ jest . resetModuleRegistry ( ) ;
143+
144+ // eslint-disable-next-line @typescript-eslint/no-require-imports,node/no-missing-require
145+ expect ( ( ) => require ( '../unbound-method' ) . default ) . toThrow ( / o h n o e s ! / iu) ;
146+ } ) ;
147+ } ) ;
148+
134149 describe ( 'when @typescript-eslint/eslint-plugin is not available' , ( ) => {
135150 const ruleTester = new ESLintUtils . RuleTester ( {
136151 parser : '@typescript-eslint/parser' ,
You can’t perform that action at this time.
0 commit comments