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

__mocks__ style mocking of organization modules #121

Open
KristjanTammekivi opened this issue Sep 11, 2020 · 3 comments
Open

__mocks__ style mocking of organization modules #121

KristjanTammekivi opened this issue Sep 11, 2020 · 3 comments
Assignees

Comments

@KristjanTammekivi
Copy link

KristjanTammekivi commented Sep 11, 2020

Hi, I want to use projectroot/mocks/@organization/module.js style mock but the getMockName seems to look for the mock inside node_modules/@organization/module/mocks

@theKashey
Copy link
Owner

const getMockName = path => {
const delimiter = getDelimiter(path);
const paths = path.split(delimiter);
paths.splice(paths.length - 1, 0, '__mocks__');
return paths.join(delimiter);
};
const autoMock = (baseRequest) => {
const mockName = getMockName(baseRequest);
if (!fileExists(mockName)) {
return false;
}

This moment should check more than one directory.

@theKashey theKashey self-assigned this Sep 13, 2020
@KristjanTammekivi
Copy link
Author

I added logging to autoMock to log out mockName if mockName includes our org name/package name and it only logged out
/...project root.../node_modules/@ourorg/package/dist/mocks/index.js

@theKashey
Copy link
Owner

Yes. It is trying to resolve __mock__ only in one location, that's why you've created this issue.
It can be fixed, but it is yet to fix.

Actually you can just reimplement this plugin in user space in a way it will work best for you, or wait a few days untill I'll get time to fix it.

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

No branches or pull requests

2 participants