Supertest: Error: write EPIPE on test when updating to version 3.1.0

Created on 23 Jul 2018  路  2Comments  路  Source: visionmedia/supertest

Hello,

First, thank you for this module that I've been using for a while now.

I've recently run into a problem when updating module to 3.1.0.
A test I have is no longer working and throws me : Error: write EPIPE.

This is the following test :

it('uploads a file but 400 during validation', () => app.server
    .post(`${baseUrl}/files`)
    .set('Authorization', token)
    .attach('file', `${fixturesPath}/files.jpg`)
    .expect(400)
    .then((res) => {
        expect(res.body).have.property('success').and.equal(false);
        expect(res.body).have.property('error').and.to.be.an('object');
        expect(res.body.error).have.property('fileType').and.equal('is required');
    }));

The function I try to test here, just throws an error which should validate the _expect(400)_ and expects in the _then_.

The expected error is sent and printed in the terminal :

BadRequest { status: 400, message: { fileType: 'is required' } }
[0mPOST /api/v1/prospect/files [33m400[0m6.224 ms - 51[0m

But right after the end of the request I get the Error: write EPIPE., before entering the validation part of the test.

I've try logging something in the then but the error happens before that but after request is completed.

it('uploads a file but 400 during validation', () => app.server
    .post(`${baseUrl}/files`)
    .set('Authorization', token)
    .attach('file', `${fixturesPath}/files.jpg`)
    .expect(400)
    .then((res) => {
        console.log('something');    // <-- This code is never reached
        expect(res.body).have.property('success').and.equal(false);
        expect(res.body).have.property('error').and.to.be.an('object');
        expect(res.body.error).have.property('fileType').and.equal('is required');
    }));

Is this an issue with the way I write the test ? (I have 630 other tests working fine, with similar syntax).

This test is still working fine with 3.0.0 and only breaks in 3.1.0, I'm therefore unable to update the module since I don't know how to make this test work.

Would you need any more info on how we could fix this ?

Thank you,

Most helpful comment

After reverting to 3.0.0 I sometimes have a new fail : _Cannot read property 'status' of undefined_

I guess that rollbacking to 3.0.0 did not fix the problem and that my issue is caused by the update of a dependency in another module.

This might be the same issue as #352.

All 2 comments

After reverting to 3.0.0 I sometimes have a new fail : _Cannot read property 'status' of undefined_

I guess that rollbacking to 3.0.0 did not fix the problem and that my issue is caused by the update of a dependency in another module.

This might be the same issue as #352.

We have experienced the same error as well. We traced it back to the change made in _node-combined-stream_ module, which is introduced in this commit (https://github.com/felixge/node-combined-stream/commit/b5dc1ec338fbdead4677b577241a1efdcf7a7a47).

Maybe the author @alexindigo knows what is going on?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

hacker0limbo picture hacker0limbo  路  3Comments

EverettQuebral picture EverettQuebral  路  3Comments

mickaeltr picture mickaeltr  路  3Comments

nitrocode picture nitrocode  路  4Comments

jon301 picture jon301  路  5Comments