-
-
Notifications
You must be signed in to change notification settings - Fork 6.4k
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
requiring json - odd behaviour #238
Comments
I just noticed this as well. Very confusing. Here's a sample file and a jest test to show the behaviour: SimpleObject.js: module.exports = {
"boolean": true,
"stringly": "string",
"numberly": 23
} __ tests __/test.js describe('Boolean Property Test', function() {
it('should mock boolean object properties', function() {
expect(require("../SimpleObject")).toEqual({
"boolean": true,
"stringly": "string",
"numberly": 23
});
});
}); |
I've noticed this as well. |
I'm having the same issue with arrays
After requiring it:
|
I had the same issue when importing JSON fixtures. However
|
This will be fixed by #713 in 0.9.0 so I'm closing this issue out. |
Mocking arrays is also broken, they come out empty with jest |
No it is not. Mocking an array will give you an empty array. If that is not what you expect, you can explicitly define it or unmock it. |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
I've just started using Jest and was requiring a JSON file with fake data to use in the tests and encountered the following behaviour:
If I don't use jest.dontMock the JSON file is imported, but boolean variables get removed.
Mind you, I should have used jest.dontMock to begin with.
Having said that I'm not sure why Jest would return all the properties except the boolean ones.
The text was updated successfully, but these errors were encountered: