Skip to content

Commit badbdfc

Browse files
committed
Fix build setup on Travis
+ add mongodb as service + set and pass in NODE_PATH environment variable to fix ENOENT error when spawning a new process + increase timeout of cucumber-js (apparently we have a slow node container on travis)
1 parent ead1e30 commit badbdfc

File tree

4 files changed

+26
-8
lines changed

4 files changed

+26
-8
lines changed

.travis.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,13 @@
11
language: node_js
2+
env:
3+
- NODE_PATH=$(which node)
4+
install:
5+
- yarn install
6+
- cd human-connection-api
7+
- yarn install
8+
- cd ..
9+
services:
10+
- mongodb
211
node_js:
312
- "9"
413
script:

features/env/hooks.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@ let hcApi;
77

88
// Asynchronous Callback
99
BeforeAll({ timeout: 30 * 1000 }, (callback) => {
10-
hcApi = spawn('node', ['server/'], {
10+
hcApi = spawn((process.env.NODE_PATH || 'node'), ['server/'], {
1111
cwd: './human-connection-api/',
1212
env: {
1313
NODE_ENV: 'test',
1414
},
15-
});
15+
}).on('error', (err) => { throw err; });
1616

1717
hcApi.stdout.on('data', (data) => {
1818
console.log(`stdout: ${data}`);

features/env/timeout.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
var {setDefaultTimeout} = require('cucumber');
1+
const { setDefaultTimeout } = require('cucumber');
22

33
setDefaultTimeout(60 * 1000);

features/step_definitions/steps.js

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,11 @@ function authenticate(email, plainTextPassword) {
2222
method: 'post',
2323
body: JSON.stringify(formData),
2424
headers: { 'Content-Type': 'application/json' },
25-
}).then(response => response.json()).then(json => json.accessToken);
25+
}).then(response => response.json())
26+
.catch((err) => {
27+
throw (err);
28+
})
29+
.then(json => json.accessToken);
2630
}
2731

2832
Given('the Human Connection API is up and running', () => {
@@ -63,10 +67,15 @@ When('I send a POST request to {string} with:', (route, body, callback) => {
6367
if (currentUserAccessToken) {
6468
params.headers.Authorization = `Bearer ${currentUserAccessToken}`;
6569
}
66-
fetch(`${hcBackendUrl}${route}`, params).then(response => response.json()).then((json) => {
67-
httpResponse = json;
68-
callback();
69-
});
70+
fetch(`${hcBackendUrl}${route}`, params)
71+
.then(response => response.json())
72+
.catch((err) => {
73+
throw (err);
74+
})
75+
.then((json) => {
76+
httpResponse = json;
77+
callback();
78+
});
7079
});
7180

7281
Then('there is an access token in the response:', (_docString) => {

0 commit comments

Comments
 (0)