Skip to content

Commit

Permalink
fix: remove optional param
Browse files Browse the repository at this point in the history
  • Loading branch information
andrew-the-drawer committed Feb 11, 2025
1 parent 43f6175 commit 1accf78
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
8 changes: 7 additions & 1 deletion packages/jest-resolve/src/__tests__/resolve.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -742,7 +742,9 @@ describe('getMockModuleAsync', () => {
} as ResolverConfig);
const src = require.resolve('../');

await resolver.resolveModuleAsync(src, 'dependentModule');
await resolver.resolveModuleAsync(src, 'dependentModule', {
conditions: ['browser'],
});

expect(mockUserResolverAsync.async).toHaveBeenCalled();
expect(mockUserResolverAsync.async.mock.calls[0][0]).toBe(
Expand All @@ -752,6 +754,10 @@ describe('getMockModuleAsync', () => {
'basedir',
path.dirname(src),
);
expect(mockUserResolverAsync.async.mock.calls[0][1]).toHaveProperty(
'conditions',
['browser'],
);
});
});

Expand Down
6 changes: 3 additions & 3 deletions packages/jest-resolve/src/resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,7 @@ export default class Resolver {
async getMockModuleAsync(
from: string,
name: string,
options?: Pick<ResolveModuleConfig, 'conditions'>,
options: Pick<ResolveModuleConfig, 'conditions'>,
): Promise<string | null> {

Check warning on line 506 in packages/jest-resolve/src/resolver.ts

View check run for this annotation

Codecov / codecov/patch

packages/jest-resolve/src/resolver.ts#L506

Added line #L506 was not covered by tests
const mock = this._moduleMap.getMockModule(name);
if (mock) {
Expand Down Expand Up @@ -601,7 +601,7 @@ export default class Resolver {
moduleName,
options,
);
const mockPath = await this._getMockPathAsync(from, moduleName);
const mockPath = await this._getMockPathAsync(from, moduleName, options);

Check warning on line 604 in packages/jest-resolve/src/resolver.ts

View check run for this annotation

Codecov / codecov/patch

packages/jest-resolve/src/resolver.ts#L604

Added line #L604 was not covered by tests

const sep = path.delimiter;
const id =
Expand Down Expand Up @@ -671,7 +671,7 @@ export default class Resolver {
private async _getMockPathAsync(
from: string,
moduleName: string,
options?: Pick<ResolveModuleConfig, 'conditions'>,
options: Pick<ResolveModuleConfig, 'conditions'>,
): Promise<string | null> {
return this.isCoreModule(moduleName)
? null
Expand Down

0 comments on commit 1accf78

Please sign in to comment.