mirror of https://github.com/status-im/metro.git
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:
parent
5ad47b1a24
commit
29d2aa65ac
|
@ -54,6 +54,8 @@ type PublicBundleOptions = {
|
||||||
+sourceMapUrl?: string,
|
+sourceMapUrl?: string,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
exports.TransformCaching = TransformCaching;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is a public API, so we don't trust the value and purposefully downgrade
|
* 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
|
* it as `mixed`. Because it understands `invariant`, Flow ensure that we
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -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};
|
Binary file not shown.
After Width: | Height: | Size: 68 B |
Loading…
Reference in New Issue