[React Native][react-packager] Fix test runner and fialing tests

This commit is contained in:
Amjad Masad 2015-02-28 14:30:34 -08:00
parent 887cb9ff71
commit c435ce74b6
10 changed files with 33 additions and 15 deletions

View File

@ -10,6 +10,7 @@ describe('Activity', function() {
beforeEach(function() {
console.log = jest.genMockFn();
Activity = require('../');
jest.runOnlyPendingTimers();
});
afterEach(function() {
@ -60,12 +61,15 @@ describe('Activity', function() {
expect(function() {
Activity.endEvent(eid);
}).toThrow('event(1) has already ended!');
}).toThrow('event(3) has already ended!');
jest.runOnlyPendingTimers();
});
});
describe('signal', function() {
it('writes a SIGNAL event out to the console', function() {
var EVENT_NAME = 'EVENT_NAME';
var DATA = {someData: 42};

View File

@ -5,7 +5,6 @@ jest
.dontMock('q')
.dontMock('path')
.dontMock('absolute-path')
.dontMock('../../../../fb-path-utils')
.dontMock('../docblock')
.setMock('../../../ModuleDescriptor', function(data) {return data;});

View File

@ -0,0 +1,5 @@
'use strict';
module.exports = {
WatchmanWatcher: jest.genMockFromModule('sane/src/watchman_watcher')
};

View File

@ -0,0 +1,6 @@
'use strict';
// Bug with Jest because we're going to the node_modules that is a sibling
// of what jest thinks our root (the dir with the package.json) should be.
module.exports = require.requireActual('q');

View File

@ -0,0 +1,5 @@
'use strict';
// Bug with Jest because we're going to the node_modules that is a sibling
// of what jest thinks our root (the dir with the package.json) should be.
module.exports = require.requireActual('underscore');

View File

@ -3,7 +3,6 @@
jest
.dontMock('underscore')
.dontMock('path')
.dontMock('q')
.dontMock('absolute-path')
.dontMock('../Cache');
@ -194,7 +193,7 @@ describe('JSTransformer Cache', function() {
return q('baz value');
});
jest.runAllTimers();
jest.runAllTicks();
expect(fs.writeFile).toBeCalled();
});
});

View File

@ -2,7 +2,6 @@
jest
.dontMock('worker-farm')
.dontMock('q')
.dontMock('os')
.dontMock('../index');

View File

@ -1,10 +1,6 @@
'use strict';
jest
.dontMock('underscore')
.dontMock('../base64-vlq')
.dontMock('source-map')
.dontMock('../Package');
jest.autoMockOff();
var SourceMapGenerator = require('source-map').SourceMapGenerator;

View File

@ -3,9 +3,13 @@
jest.setMock('worker-farm', function() { return function() {}; })
.dontMock('q')
.dontMock('os')
.dontMock('errno/custom')
.dontMock('path')
.dontMock('url')
.setMock('timers', {
setImmediate: function(fn) {
return setTimeout(fn, 0);
}
})
.dontMock('../');
var q = require('q');
@ -75,16 +79,16 @@ describe('processRequest', function() {
});
pit('returns sourcemap on request of *.map', function() {
makeRequest(
return makeRequest(
requestHandler,
'mybundle.includeRequire.runModule.bundle.map'
).then(function(response) {
expect(response).toEqual('this is the source map');
expect(response).toEqual('"this is the source map"');
});
});
pit('watches all files in projectRoot', function() {
makeRequest(
return makeRequest(
requestHandler,
'mybundle.includeRequire.runModule.bundle'
).then(function(response) {
@ -107,7 +111,7 @@ describe('processRequest', function() {
});
pit('invalides files in package when file is updated', function() {
makeRequest(
return makeRequest(
requestHandler,
'mybundle.includeRequire.runModule.bundle'
).then(function(response) {

View File

@ -6,6 +6,7 @@ var declareOpts = require('../lib/declareOpts');
var FileWatcher = require('../FileWatcher');
var Packager = require('../Packager');
var Activity = require('../Activity');
var setImmediate = require('timers').setImmediate;
var q = require('q');
module.exports = Server;