ntedgi / node-efficientnet

tensorflowJS implementation of EfficientNet 🚀
https://www.npmjs.com/package/node-efficientnet
MIT License
257 stars 37 forks source link

add missing coverage line unit test to complete 100% coverage of server code #63

Closed ntedgi closed 1 year ago

ntedgi commented 2 years ago
      at server.js:21:13

 PASS  __tests__/server.test.js (55.073 s)
  Post Endpoints
    ✓ should predict simple gold fish (5443 ms)
    ✓ sanity test server/version (44 ms)

----------|---------|----------|---------|---------|-------------------
File      | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
----------|---------|----------|---------|---------|-------------------
All files |      92 |      100 |     100 |      92 |
 ...er.js |      92 |      100 |     100 |      92 | 31-32
----------|---------|----------|---------|---------|-------------------
Test Suites: 1 passed, 1 total
Tests:       2 passed, 2 total
Snapshots:   0 total
Time:        55.247 s, estimated 64 s

the lines that should be covered are the error handling of the upload router so in order to do so add this test to /playground/server/__test___/server.test.js


  it("/api/upload should throw exception when not passing a file", async (done) => {
        jest.setTimeout(60000);
        const res = await request(app)
            .post("/api/upload")
            .expect(500)
            .then((_, err) => {
                if (err) {
                    done()
                }
                else {
                    done(err)
                }
            })
            .catch((err, res) => {
                done(err);
            });
    });
});