mirror of
https://github.com/status-im/metro.git
synced 2025-01-27 03:14:49 +00:00
[React Native][react-packager] Fix test runner and fialing tests
This commit is contained in:
parent
887cb9ff71
commit
c435ce74b6
@ -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};
|
||||
|
||||
|
@ -5,7 +5,6 @@ jest
|
||||
.dontMock('q')
|
||||
.dontMock('path')
|
||||
.dontMock('absolute-path')
|
||||
.dontMock('../../../../fb-path-utils')
|
||||
.dontMock('../docblock')
|
||||
.setMock('../../../ModuleDescriptor', function(data) {return data;});
|
||||
|
||||
|
5
react-packager/src/FileWatcher/__mocks__/sane.js
vendored
Normal file
5
react-packager/src/FileWatcher/__mocks__/sane.js
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
'use strict';
|
||||
|
||||
module.exports = {
|
||||
WatchmanWatcher: jest.genMockFromModule('sane/src/watchman_watcher')
|
||||
};
|
6
react-packager/src/JSTransformer/__mocks__/q.js
vendored
Normal file
6
react-packager/src/JSTransformer/__mocks__/q.js
vendored
Normal 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');
|
5
react-packager/src/JSTransformer/__mocks__/underscore.js
vendored
Normal file
5
react-packager/src/JSTransformer/__mocks__/underscore.js
vendored
Normal 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');
|
@ -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();
|
||||
});
|
||||
});
|
||||
|
@ -2,7 +2,6 @@
|
||||
|
||||
jest
|
||||
.dontMock('worker-farm')
|
||||
.dontMock('q')
|
||||
.dontMock('os')
|
||||
.dontMock('../index');
|
||||
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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) {
|
||||
|
1
react-packager/src/Server/index.js
vendored
1
react-packager/src/Server/index.js
vendored
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user