mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-05-06 09:13:27 +08:00
Adapt jest transform for node-only files
Summary: This changes the jest preprocessor so that files targetet at node.js will be run with the node-specific transform. It also adapts tests that relied on inline requires. Benefit: packager tests run faster now. Reviewed By: cpojer Differential Revision: D3562007 fbshipit-source-id: e06c86d545926a5c546458025f505dca115e7ea8
This commit is contained in:
committed by
Facebook Github Bot 3
parent
31f01c02db
commit
ff0eb47dbd
@@ -11,18 +11,18 @@
|
||||
jest.unmock('../');
|
||||
jest.mock('path');
|
||||
|
||||
const Promise = require('promise');
|
||||
const Resolver = require('../');
|
||||
|
||||
const path = require('path');
|
||||
|
||||
let DependencyGraph = jest.fn();
|
||||
const DependencyGraph = jest.fn();
|
||||
jest.setMock('node-haste', DependencyGraph);
|
||||
let Module;
|
||||
let Polyfill;
|
||||
|
||||
describe('Resolver', function() {
|
||||
let Resolver, path;
|
||||
|
||||
beforeEach(function() {
|
||||
Resolver = require('../');
|
||||
path = require('path');
|
||||
DependencyGraph.mockClear();
|
||||
Module = jest.fn(function() {
|
||||
this.getName = jest.fn();
|
||||
@@ -131,7 +131,14 @@ describe('Resolver', function() {
|
||||
).then(function(result) {
|
||||
expect(result.mainModuleId).toEqual('index');
|
||||
expect(result.dependencies[result.dependencies.length - 1]).toBe(module);
|
||||
expect(DependencyGraph.prototype.createPolyfill.mock.calls.map((call) => call[0])).toEqual([
|
||||
expect(
|
||||
DependencyGraph
|
||||
.prototype
|
||||
.createPolyfill
|
||||
.mock
|
||||
.calls
|
||||
.map((call) => call[0]))
|
||||
.toEqual([
|
||||
{ id: 'polyfills/polyfills.js',
|
||||
file: 'polyfills/polyfills.js',
|
||||
dependencies: []
|
||||
|
||||
Reference in New Issue
Block a user