Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
Mark Molinaro authored Aug 14, 2021
1 parent a8cbeb1 commit 859be58
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
6 changes: 3 additions & 3 deletions packages/jest-resolve/src/__tests__/resolve.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import * as fs from 'graceful-fs';
import {sync as resolveSync} from 'resolve';
import {ModuleMap} from 'jest-haste-map';
import userResolver from '../__mocks__/userResolver';
import defaultResolver, { ResolverOptions } from '../defaultResolver';
import defaultResolver, {ResolverOptions} from '../defaultResolver';
import nodeModulesPaths from '../nodeModulesPaths';
import Resolver from '../resolver';
import type {ResolverConfig} from '../types';
Expand Down Expand Up @@ -325,9 +325,9 @@ describe('Resolver.getModulePaths() -> nodeModulesPaths()', () => {
});

describe('defaultResolver', () => {
it("does not change outwardly stackTraceLimit", () => {
it('does not change outwardly stackTraceLimit', () => {
const oldStackTraceValue = Error.stackTraceLimit;
expect(() => defaultResolver("test", {} as ResolverOptions)).toThrow()
expect(() => defaultResolver('test', {} as ResolverOptions)).toThrow();
expect(oldStackTraceValue).toBe(Error.stackTraceLimit);
});
});
7 changes: 5 additions & 2 deletions packages/jest-resolve/src/defaultResolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,14 +80,17 @@ function statSyncCached(path: string): IPathType {
let stat;
const oldTrace = Object.getOwnPropertyDescriptors(Error).stackTraceLimit;
try {
Object.defineProperty(Error, "stackTraceLimit", { value: 0, writable: false });
Object.defineProperty(Error, 'stackTraceLimit', {
value: 0,
writable: false,
});
stat = fs.statSync(path);
} catch (e) {
if (!(e && (e.code === 'ENOENT' || e.code === 'ENOTDIR'))) {
throw e;
}
} finally {
Object.defineProperty(Error, "stackTraceLimit", oldTrace);
Object.defineProperty(Error, 'stackTraceLimit', oldTrace);
}

if (stat) {
Expand Down

0 comments on commit 859be58

Please sign in to comment.