Skip to content

Commit

Permalink
fix(unbound-method): only swollow MODULE_NOT_FOUND errors
Browse files Browse the repository at this point in the history
  • Loading branch information
G-Rath committed Mar 6, 2021
1 parent 46f2db0 commit c330ad9
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/rules/__tests__/unbound-method.test.ts
Expand Up @@ -124,13 +124,28 @@ const TSESLintPluginRef: { throwWhenRequiring: boolean } = {

jest.mock('@typescript-eslint/eslint-plugin', () => {
if (TSESLintPluginRef.throwWhenRequiring) {
throw new Error('oh noes!');
throw new (class extends Error {
public code = 'MODULE_NOT_FOUND';
})();
}

return jest.requireActual('@typescript-eslint/eslint-plugin');
});

describe('error handling', () => {
describe('when an error is thrown accessing the base rule', () => {
it('re-throws the error', () => {
jest.mock('@typescript-eslint/eslint-plugin', () => {
throw new Error('oh noes!');
});

jest.resetModuleRegistry();

// eslint-disable-next-line @typescript-eslint/no-require-imports,node/no-missing-require
expect(() => require('../unbound-method').default).toThrow(/oh noes!/iu);
});
});

describe('when @typescript-eslint/eslint-plugin is not available', () => {
const ruleTester = new ESLintUtils.RuleTester({
parser: '@typescript-eslint/parser',
Expand Down

0 comments on commit c330ad9

Please sign in to comment.