Skip to content

Commit

Permalink
dodge a flow error
Browse files Browse the repository at this point in the history
  • Loading branch information
SimenB committed Oct 8, 2018
1 parent 8c16548 commit ce6b56d
Showing 1 changed file with 16 additions and 11 deletions.
27 changes: 16 additions & 11 deletions e2e/instanceof/__tests__/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,24 @@ test('fs Error', () => {
}
});

test('http error', done => {
const request = http.request('http://does-not-exist/blah', res => {
console.log(`STATUS: ${res.statusCode}`);
res.on('end', () => {
done(new Error('Ended before failure'));
test('http error', () =>
new Promise((resolve, reject) => {
const request = http.request('http://does-not-exist/blah', res => {
console.log(`STATUS: ${res.statusCode}`);
res.on('end', () => {
reject(new Error('Ended before failure'));
});
});
});

request.once('error', err => {
expect(err).toBeInstanceOf(Error);
done();
});
});
request.once('error', err => {
try {
expect(err).toBeInstanceOf(Error);
resolve();
} catch (e) {
reject(e);
}
});
}));

test('Array', () => {
expect([]).toBeInstanceOf(Array);
Expand Down

0 comments on commit ce6b56d

Please sign in to comment.