Remove test delays (#5579)
* Changing __indexBuildCompletionCallbackForTests callback to serverStartComplete * Improving serverStartComplete callback to avoid production unhandled promise rejection * Add test to check inexistence of unhandled promise rejection on server fail * Removing some hooks delays * Removing delay after reconfigureServer * Improving code style
This commit is contained in:
committed by
GitHub
parent
2f161c25cd
commit
893f1d376e
@@ -177,7 +177,7 @@ export interface ParseServerOptions {
|
||||
/* Live query server configuration options (will start the liveQuery server) */
|
||||
liveQueryServerOptions: ?LiveQueryServerOptions;
|
||||
|
||||
__indexBuildCompletionCallbackForTests: ?() => void;
|
||||
serverStartComplete: ?(error: ?Error) => void;
|
||||
}
|
||||
|
||||
export interface CustomPagesOptions {
|
||||
|
||||
@@ -80,7 +80,7 @@ class ParseServer {
|
||||
cloud,
|
||||
javascriptKey,
|
||||
serverURL = requiredParameter('You must provide a serverURL!'),
|
||||
__indexBuildCompletionCallbackForTests = () => {},
|
||||
serverStartComplete,
|
||||
} = options;
|
||||
// Initialize the node client SDK automatically
|
||||
Parse.initialize(appId, javascriptKey || 'unused', masterKey);
|
||||
@@ -100,11 +100,21 @@ class ParseServer {
|
||||
const hooksLoadPromise = hooksController.load();
|
||||
|
||||
// Note: Tests will start to fail if any validation happens after this is called.
|
||||
if (process.env.TESTING) {
|
||||
__indexBuildCompletionCallbackForTests(
|
||||
Promise.all([dbInitPromise, hooksLoadPromise])
|
||||
);
|
||||
}
|
||||
Promise.all([dbInitPromise, hooksLoadPromise])
|
||||
.then(() => {
|
||||
if (serverStartComplete) {
|
||||
serverStartComplete();
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
if (serverStartComplete) {
|
||||
serverStartComplete(error);
|
||||
} else {
|
||||
// eslint-disable-next-line no-console
|
||||
console.error(error);
|
||||
process.exit(1);
|
||||
}
|
||||
});
|
||||
|
||||
if (cloud) {
|
||||
addParseCloud();
|
||||
|
||||
Reference in New Issue
Block a user