From cf0e40ad3dbeb5e5ab90b9b92b77ba3b69ad8228 Mon Sep 17 00:00:00 2001 From: Tadeu Zagallo Date: Thu, 18 Jun 2015 15:56:33 -0100 Subject: [PATCH] [ReactNative] Fix MessageQueue-test on open source Summary: @public Fix mocking on MessageQueue-test Test Plan: Run the test --- Libraries/Utilities/__tests__/MessageQueue-test.js | 11 +++++------ jestSupport/scriptPreprocess.js | 7 ++----- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/Libraries/Utilities/__tests__/MessageQueue-test.js b/Libraries/Utilities/__tests__/MessageQueue-test.js index a8d5fc5bd..60fae4c6b 100644 --- a/Libraries/Utilities/__tests__/MessageQueue-test.js +++ b/Libraries/Utilities/__tests__/MessageQueue-test.js @@ -8,9 +8,12 @@ */ 'use strict'; -jest.dontMock('MessageQueue'); +jest.setMock('ReactUpdates', { + batchedUpdates: fn => fn() +}); -var ReactUpdates = require('ReactUpdates'); +jest.dontMock('MessageQueue'); +jest.dontMock('keyMirror'); var MessageQueue = require('MessageQueue'); let MODULE_IDS = 0; @@ -95,10 +98,6 @@ describe('MessageQueue', () => { describe('processBatch', () => { - beforeEach(() => { - ReactUpdates.batchedUpdates = (fn) => fn(); - }); - it('should call __invokeCallback for invokeCallbackAndReturnFlushedQueue', () => { queue.__invokeCallback = jasmine.createSpy(); queue.processBatch([{ diff --git a/jestSupport/scriptPreprocess.js b/jestSupport/scriptPreprocess.js index fe675a577..ac219c97d 100644 --- a/jestSupport/scriptPreprocess.js +++ b/jestSupport/scriptPreprocess.js @@ -18,16 +18,13 @@ module.exports = { transformSource: transformSource, process: function(src, fileName) { - if (fileName.match(/node_modules/)) { - return src; - } - try { return transformSource(src, fileName); } catch(e) { - throw new Error('\nError transforming file:\n js/' + + console.error('\nError transforming file:\n js/' + (fileName.split('/js/')[1] || fileName) + ':' + e.lineNumber + ': \'' + e.message + '\'\n'); + return src; } } };