Skip to content

Commit 4976390

Browse files
committed
test(integration): fixed loading of app after export changes
1 parent 5227c1c commit 4976390

File tree

3 files changed

+19
-24
lines changed

3 files changed

+19
-24
lines changed

lib/app.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,11 @@ import manifest from './manifest';
55

66
require('dotenv-safe').config();
77

8-
export default Glue.compose(manifest, {relativeTo: __dirname}).then(server => server.start(() => {
8+
export default Glue.compose(manifest, {relativeTo: __dirname}).then(server => server.start().then(() => {
99
server.log(`Server started at http://${server.info.address}:${server.info.port}`);
1010
return server;
1111
})).catch(err => {
1212
console.error(err); // eslint-disable-line no-console
1313
console.trace(); // eslint-disable-line no-console
14+
process.exitCode = 1;
1415
});

test/integration/features/step_definitions/common-steps.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
import {OK, NOT_FOUND} from 'http-status-codes';
1+
import {NOT_FOUND, OK} from 'http-status-codes';
22
import {defineSupportCode} from 'cucumber';
33
import {assert} from 'chai';
44
import {World} from '../support/world';
5-
import loadApi from '../../../../lib/app';
65

76
const statuses = {
87
'Not Found': NOT_FOUND,
@@ -12,8 +11,8 @@ const statuses = {
1211
defineSupportCode(({Before, After, When, Then, setWorldConstructor}) => {
1312
setWorldConstructor(World);
1413

15-
Before((scenario, callback) => {
16-
loadApi.then(() => callback());
14+
Before(async function () {
15+
this.server = await require('../../../../lib/app.js').default;
1716
});
1817

1918
After(function () {

test/integration/features/support/world.js

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ process.env.AUTH_COOKIE_ENCRYPTION_PASSWORD = any.string();
99
process.env.DATABASE_URL = any.url();
1010

1111
export function World() {
12-
const loadApi = require('../../../../lib/app.js');
13-
1412
this.makeOzRequest = (requestDetails, appDetails, callback) => {
1513
const method = 'POST';
1614
const url = `http://example.com${requestDetails.endpoint}`;
@@ -33,23 +31,20 @@ export function World() {
3331
};
3432

3533
this.requestTo = (options, callback) => {
36-
loadApi.then(server => {
37-
this.serverResponse = null;
38-
this.server = server;
39-
40-
const headers = {Accept: this.mime, ...options.headers};
41-
42-
server.inject({
43-
method: options.method,
44-
url: options.url,
45-
payload: options.payload,
46-
headers
47-
}, response => {
48-
this.serverResponse = response;
49-
50-
callback();
51-
});
52-
}).catch(callback);
34+
this.serverResponse = null;
35+
36+
const headers = {Accept: this.mime, ...options.headers};
37+
38+
this.server.inject({
39+
method: options.method,
40+
url: options.url,
41+
payload: options.payload,
42+
headers
43+
}, response => {
44+
this.serverResponse = response;
45+
46+
callback();
47+
});
5348
};
5449

5550
this.getRequestTo = (uri, callback) => {

0 commit comments

Comments
 (0)