Skip to content

Commit

Permalink
feat(testing): Add bootstrap method to TestServer
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelbromley committed Apr 8, 2020
1 parent 4912a29 commit dab9e21
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion packages/testing/src/test-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,16 @@ export class TestServer {
console.error(e);
process.exit(1);
}
await this.bootstrap();
}

/**
* @description
* Bootstraps a Vendure server instance. Generally the `.init()` method should be used, as that will also
* populate the test data. However, the `bootstrap()` method is sometimes useful in tests which need to
* start and stop a Vendure instance multiple times without re-populating data.
*/
async bootstrap() {
const [app, worker] = await this.bootstrapForTesting(this.vendureConfig);
if (app) {
this.app = app;
Expand All @@ -62,7 +71,7 @@ export class TestServer {
*/
async destroy() {
// allow a grace period of any outstanding async tasks to complete
await new Promise(resolve => global.setTimeout(resolve, 500));
await new Promise((resolve) => global.setTimeout(resolve, 500));
await this.app.close();
if (this.worker) {
await this.worker.close();
Expand Down

0 comments on commit dab9e21

Please sign in to comment.