Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make partial mocks an optional thing rather than default thing #64

Closed
iambumblehead opened this issue Jul 18, 2022 · 1 comment · Fixed by #65
Closed

make partial mocks an optional thing rather than default thing #64

iambumblehead opened this issue Jul 18, 2022 · 1 comment · Fixed by #65

Comments

@iambumblehead
Copy link
Owner

iambumblehead commented Jul 18, 2022

the situation reported in this ticket should not happen unless it is specified somehow #51

so instead of something like this

const originalFile = await import( pathtooriginalfile );
const mockedFile = Object.assign({}, originalFile, mockDefinitions);

return mockedFile

we want something like this to happen instead

const originalFile = isPartialMockEnabled && await import( pathtooriginalfile );
const mockedFile = Object.assign({}, originalFile, mockDefinitions);

return mockedFile
@iambumblehead
Copy link
Owner Author

iambumblehead commented Jul 18, 2022

maybe the behaviour could be specified by calling esmock this way

const mainWithPartialMockedModules = await esmock.px('../src/main.js', {}, {
  fs : {
    readFileSync : () => 'this function will be merged with other fs definitions';
  }
});

const mainWithStrictMockedModules = await esmock('../src/main.js', {}, {
  fs : {
    readFileSync : () => 'only this function will be defined on fs';
  }
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant