Skip to content

Commit c154bae

Browse files
committed
fix(unbound-method): only swollow MODULE_NOT_FOUND errors
1 parent f87f18f commit c154bae

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

src/rules/__tests__/unbound-method.test.ts

+16-1
Original file line numberDiff line numberDiff line change
@@ -124,13 +124,28 @@ const TSESLintPluginRef: { throwWhenRequiring: boolean } = {
124124

125125
jest.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

133135
describe('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(/oh noes!/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',

0 commit comments

Comments
 (0)