Jean Lauliac 32d35c31f7 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
2017-05-26 03:30:33 -07:00

44 lines
1.2 KiB
JavaScript

/**
* 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();
});
});