packager: add basic top-level integration test

Summary: I'd like us to start having some decent testing at the packager/bundler level to check that there are no major breakage hapenning. This changeset introduce a simple test that just test the `buildBundle` public API. On the same model, I'd like to test the server API and behavior, and things such as hot module reloading. I hope this will also highlight the gross inconsistencies of the API, for example the Bundle/BundleBase hierarchy, that we can proceed to fix later.

Reviewed By: davidaurelio, cpojer

Differential Revision: D5121817

fbshipit-source-id: e0f3758c7fbb7a85cf51fb3cbc34c12d5374b7d3
This commit is contained in:
Jean Lauliac 2017-05-26 03:17:15 -07:00 коммит произвёл Facebook Github Bot
Родитель e40d1a1065
Коммит 32d35c31f7
7 изменённых файлов: 1382 добавлений и 0 удалений

Просмотреть файл

@ -54,6 +54,8 @@ type PublicBundleOptions = {
+sourceMapUrl?: string,
};
exports.TransformCaching = TransformCaching;
/**
* This is a public API, so we don't trust the value and purposefully downgrade
* it as `mixed`. Because it understands `invariant`, Flow ensure that we

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -0,0 +1,43 @@
/**
* Copyright (c) 2015-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @format
*/
'use strict';
jest.disableAutomock();
jest.useRealTimers();
const Packager = require('../..');
const path = require('path');
jasmine.DEFAULT_TIMEOUT_INTERVAL = 30 * 1000;
const INPUT_PATH = path.resolve(__dirname, '../basic_bundle');
const POLYFILLS_PATH = path.resolve(__dirname, '../../src/Resolver/polyfills');
describe('basic_bundle', () => {
it('bundles package as expected', async () => {
const bundle = await Packager.buildBundle(
{
projectRoots: [INPUT_PATH, POLYFILLS_PATH],
transformCache: Packager.TransformCaching.none(),
transformModulePath: require.resolve('../../transformer'),
},
{
dev: false,
entryFile: path.join(INPUT_PATH, 'TestBundle.js'),
platform: 'ios',
},
);
const absPathRe = new RegExp(INPUT_PATH, 'g');
expect(bundle.getSource().replace(absPathRe, '')).toMatchSnapshot();
});
});

Просмотреть файл

@ -0,0 +1,16 @@
/**
* Copyright (c) 2015-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @format
*/
'use strict';
const Foo = require('./Foo');
module.exports = {type: 'bar', foo: Foo.type};

Просмотреть файл

@ -0,0 +1,16 @@
/**
* Copyright (c) 2015-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @format
*/
'use strict';
const asset = require('./test.png');
module.exports = {type: 'foo', asset};

Просмотреть файл

@ -0,0 +1,17 @@
/**
* Copyright (c) 2015-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @format
*/
'use strict';
const Bar = require('./Bar');
const Foo = require('./Foo');
module.exports = {Foo, Bar};

Двоичные данные
packager/integration_tests/basic_bundle/test.png Normal file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 68 B