Summary: Adds a test runner for jest test and adds three simple test cases: - render the app - start a server - client connecting to the app Test can be run using `yarn test`. To make the test runner work, some changes needed to be made: - remove the export of `init()` from `'flipper'`, because it was a cyclic dependency - updating Button.js to the new ref-API Reviewed By: jknoxville Differential Revision: D10027078 fbshipit-source-id: 49107b0dd4dec666b92ecd841422fe7e6b3a7756
47 lines
1.1 KiB
JavaScript
47 lines
1.1 KiB
JavaScript
/**
|
|
* Copyright 2018-present Facebook.
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
* @format
|
|
*/
|
|
|
|
import type Client from '../Client';
|
|
|
|
import Server, {SECURE_PORT, INSECURE_PORT} from '../server.js';
|
|
import LogManager from '../fb-stubs/Logger';
|
|
|
|
let server;
|
|
|
|
beforeAll(() => {
|
|
server = new Server(new LogManager());
|
|
});
|
|
|
|
test('servers starting at ports', done => {
|
|
const serversToBeStarted = new Set([SECURE_PORT, INSECURE_PORT]);
|
|
|
|
server.addListener('listening', port => {
|
|
if (!serversToBeStarted.has(port)) {
|
|
throw Error(`unknown server started at port ${port}`);
|
|
} else {
|
|
serversToBeStarted.delete(port);
|
|
}
|
|
if (serversToBeStarted.size === 0) {
|
|
done();
|
|
}
|
|
});
|
|
});
|
|
|
|
test('Layout plugin is connecting', done => {
|
|
server.addListener('new-client', (client: Client) => {
|
|
if (client.plugins.indexOf('Inspector -') === -1) {
|
|
done.fail(new Error('Layout inspector plugin not found'));
|
|
} else {
|
|
done();
|
|
}
|
|
});
|
|
});
|
|
|
|
afterAll(() => {
|
|
server.close();
|
|
});
|