You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As a fellow open source maintainer, thank you for spending your time on this project.
That said, I'm really struggling with the format and verbiage in the documentation. It's very hard to parse, and the punctuation and structure is hard to read. I'd highly recommend breaking it up into multiple, short, focused documents that are linked with a table of contents on a main README.
With regard to Jest, the README states: jest.mocks - jest is awesome. As well as rewiremock. and earlier versions of it stated jest.mocks - Jest is awesome. But rewiremock can do the same. Both are super confusing and vague. Does this work the same as all aspects of Jest, is it a 1:1 comparison in terms of functionality, or does rewiremock only support some of the same functionality? I don't think these statements are adding to your README and the developer experience. To the contrary, I think it's adding confusion to your documentation.
Going further into the README with the jest-like section (https://github.com/theKashey/rewiremock#jest---like) it would appear that there's 1:1 functionality with jest.mock, which is awesome. Unfortunately, in my testing of this I found that relative dependencies required from other files don't seem to be mocked - this is something that jest.mock supports out of the box. Here's my test setup:
This results in printing 42 and not {} as I would expect. Further, if I move rewire.js up a directory in the tree, I'll get a MODULE_NOT_FOUND error (requiring me to change the target of the mock to ../foo.js). All of this behavior is counter to what I would get using jest.mock, and thus confusing. The documentation doesn't contain any direct instructions on how to make this very direct jump from jest.mock to rewiremock, and it's a darn shame.
The text was updated successfully, but these errors were encountered:
Keep in mind - It will not work with require, only with ESM imports.
Speaking of ../foo.js case - as a TypeScript-first person I encourage you to use another syntax - rewiremock(() => require('./foo')).with({ action: () => {} });. That will just end all possible "MODULE_NOT_FOUND" stuff as well as enable type-safety for mocks.
👉 speaking about of jest.mock - only with babel plugin rewiremock can enable itself, mocks what is needed, import what is required, and then disable itself. It your case it's has not been activated.
As a fellow open source maintainer, thank you for spending your time on this project.
That said, I'm really struggling with the format and verbiage in the documentation. It's very hard to parse, and the punctuation and structure is hard to read. I'd highly recommend breaking it up into multiple, short, focused documents that are linked with a table of contents on a main README.
With regard to Jest, the README states:
jest.mocks - jest is awesome. As well as rewiremock.
and earlier versions of it statedjest.mocks - Jest is awesome. But rewiremock can do the same.
Both are super confusing and vague. Does this work the same as all aspects of Jest, is it a 1:1 comparison in terms of functionality, or does rewiremock only support some of the same functionality? I don't think these statements are adding to your README and the developer experience. To the contrary, I think it's adding confusion to your documentation.Going further into the README with the
jest-like
section (https://github.com/theKashey/rewiremock#jest---like) it would appear that there's 1:1 functionality withjest.mock
, which is awesome. Unfortunately, in my testing of this I found that relative dependencies required from other files don't seem to be mocked - this is something thatjest.mock
supports out of the box. Here's my test setup:bar.js
foo.js
rewire.js
- this is executed withnode rewrire.js
This results in printing
42
and not{}
as I would expect. Further, if I moverewire.js
up a directory in the tree, I'll get aMODULE_NOT_FOUND
error (requiring me to change the target of the mock to../foo.js
). All of this behavior is counter to what I would get usingjest.mock
, and thus confusing. The documentation doesn't contain any direct instructions on how to make this very direct jump fromjest.mock
torewiremock
, and it's a darn shame.The text was updated successfully, but these errors were encountered: