Conversation
|
Need to figure out how to reset the mock each time. The first run |
|
@andrewda have you tried with |
|
@alejandronanez What should I use them for? |
|
@andrewda I think you can reset the mock for every test that is run. (or I am just misunderstanding everything 😞 ) |
|
Yea, but I'm not sure how to reset just the Dimension and PixelRatio mocks, instead of everything (like the ones defined in testenv.js). |
|
@andrewda I had a look at this PR and after a lot of trial and error, the only working thing I can come up with is chaining .mockReturnValueOnce() calls: jest.mock('Dimensions', () => ({
get: jest
.fn()
.mockReturnValueOnce(mockScreens.iPhone5)
.mockReturnValueOnce(mockScreens.iPhone6),
}));
jest.mock('PixelRatio', () => ({
get: jest
.fn()
.mockReturnValueOnce(2)
.mockReturnValueOnce(2),
}));
describe('Normalize Text', () => {
// iOS Devices
it('should normalize correctly on iPhone 5', () => {
const { normalize } = require('config');
expect(normalize(1)).toEqual(0.95);
});
it('should normalize correctly on iPhone 6', () => {
const { normalize } = require('config');
expect(normalize(1)).toEqual(0.95);
});This require a change in the |
|
How about |
|
Didn't work for me. If you console.log() in mockClassWithGetter , you'll see the log only once |
|
Jest@24 provides jest.isolateModules(fn). I think it is what we want. |
|
Closing in favor of #899 (thanks @chinesedfan!) |
* test: cherry-pick files from #598 * test: jest.isolateModules works * fix: device info * fix: pass tests * fix: consider as intervals
Description
Adds a test for the
text-normalizefile. Currently WIP.