Skip to content

Commit

Permalink
test(integration): fixed loading of app after export changes
Browse files Browse the repository at this point in the history
  • Loading branch information
travi committed May 12, 2020
1 parent 5227c1c commit 4976390
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 24 deletions.
3 changes: 2 additions & 1 deletion lib/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@ import manifest from './manifest';

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

export default Glue.compose(manifest, {relativeTo: __dirname}).then(server => server.start(() => {
export default Glue.compose(manifest, {relativeTo: __dirname}).then(server => server.start().then(() => {
server.log(`Server started at http://${server.info.address}:${server.info.port}`);
return server;
})).catch(err => {
console.error(err); // eslint-disable-line no-console
console.trace(); // eslint-disable-line no-console
process.exitCode = 1;
});
7 changes: 3 additions & 4 deletions test/integration/features/step_definitions/common-steps.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import {OK, NOT_FOUND} from 'http-status-codes';
import {NOT_FOUND, OK} from 'http-status-codes';
import {defineSupportCode} from 'cucumber';
import {assert} from 'chai';
import {World} from '../support/world';
import loadApi from '../../../../lib/app';

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

Before((scenario, callback) => {
loadApi.then(() => callback());
Before(async function () {
this.server = await require('../../../../lib/app.js').default;
});

After(function () {
Expand Down
33 changes: 14 additions & 19 deletions test/integration/features/support/world.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ process.env.AUTH_COOKIE_ENCRYPTION_PASSWORD = any.string();
process.env.DATABASE_URL = any.url();

export function World() {
const loadApi = require('../../../../lib/app.js');

this.makeOzRequest = (requestDetails, appDetails, callback) => {
const method = 'POST';
const url = `http://example.com${requestDetails.endpoint}`;
Expand All @@ -33,23 +31,20 @@ export function World() {
};

this.requestTo = (options, callback) => {
loadApi.then(server => {
this.serverResponse = null;
this.server = server;

const headers = {Accept: this.mime, ...options.headers};

server.inject({
method: options.method,
url: options.url,
payload: options.payload,
headers
}, response => {
this.serverResponse = response;

callback();
});
}).catch(callback);
this.serverResponse = null;

const headers = {Accept: this.mime, ...options.headers};

this.server.inject({
method: options.method,
url: options.url,
payload: options.payload,
headers
}, response => {
this.serverResponse = response;

callback();
});
};

this.getRequestTo = (uri, callback) => {
Expand Down

0 comments on commit 4976390

Please sign in to comment.