Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test case fails #18

Open
prashantprabhakar opened this issue Mar 18, 2018 · 2 comments
Open

test case fails #18

prashantprabhakar opened this issue Mar 18, 2018 · 2 comments

Comments

@prashantprabhakar
Copy link

I just ran the Hello world module of the webshop. The simplest test case failed with error Error: expected "Content-Length" of "11", got "11". The complete error log mentioned below.

 Hello World
    1) should return hello world


  0 passing (24ms)
  1 failing

  1) Hello World
       should return hello world:
     Error: expected "Content-Length" of "11", got "11"
      at Test._assertHeader (D:\projects\techonology\node\koa\workshop\node_modules\supertest\lib\test.js:247:12)
      at Test._assertFunction (D:\projects\techonology\node\koa\workshop\node_modules\supertest\lib\test.js:281:11)
      at Test.assert (D:\projects\techonology\node\koa\workshop\node_modules\supertest\lib\test.js:171:18)
      at assert (D:\projects\techonology\node\koa\workshop\node_modules\supertest\lib\test.js:131:12)
      at D:\projects\techonology\node\koa\workshop\node_modules\supertest\lib\test.js:128:5
      at Test.Request.callback (D:\projects\techonology\node\koa\workshop\node_modules\superagent\lib\node\index.js:706:12)
      at IncomingMessage.parser (D:\projects\techonology\node\koa\workshop\node_modules\superagent\lib\node\index.js:906:18)
      at endReadableNT (_stream_readable.js:1101:12)
      at process._tickCallback (internal/process/next_tick.js:114:19)
@RHM-DanielKlier
Copy link

This threw me off, too at first. I updated the test to check for the string "11" and then the test passed. Is this an issue with the test itself or is this caused by a change in the underlying assertion library?

@AkatQuas
Copy link

AkatQuas commented Nov 12, 2019

It is an issue caused by the library supertest.

The following the an example from supertest.

const request = require('supertest');
const express = require('express');

const app = express();

app.get('/user', function(req, res) {
  res.status(200).json({ name: 'john' });
});

request(app)
  .get('/user')
  .expect('Content-Type', /json/)
  .expect('Content-Length', '15')
  .expect(200)
  .end(function(err, res) {
    if (err) throw err;
  });

The expected result in content-length is a string rather than a number.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants