Quality Assurance Projects - Metric-Imperial Converter

Tell us what’s happening:
Describe your issue in detail here.

Your project link(s)
const chaiHttp = require(‘chai-http’);
const chai = require(‘chai’);
let assert = chai.assert;
const server = require(‘…/server’);

chai.use(chaiHttp);

suite(‘Functional Tests’, function() {
suite(“Routing Test”,function(){
suite(‘Get /api/convert => conversion object’,function(){
test(“Convert 10L(valid input)”,function(done){
chai.request(server)
.get(“/api/convert”)
.query({input:“10L”})
.end(function(err,res){
assert.equal(res.status,200);
assert.equal(res.body.initNum,10);
assert.equal(res.body.initUnit,“L”);
assert.approximately(res.body.returnNum,2.64172,0.1);
assert.equal(res.body.returnUnit,“gal”);
done();

    })
  })
   test("Convert 32g(invalid input)",function(done){
    chai.request(server)
    .get("/api/convert")
    .query({input:"32g"})
    .end(function(err,res){
      assert.equal(res.status,200);
      assert.equal(res.body.initUnit,undefined);
      done();
    })})

   test("Convert 3/7.2/4kg(invalid number)",function(done){
    chai.request(server)
    .get("/api/convert")
    .query({input:"3/7.2/4kg"})
    .end(function(err,res){
      assert.equal(res.status,200);
      assert.equal(res.body.initUnit,undefined);
      done();
    })})

   test("Convert 3/7.2/4kilogram(invalid number and unit)",function(done){
    chai.request(server)
    .get("/api/convert")
    .query({input:"3/7.2/4kilogram"})
    .end(function(err,res){
      assert.equal(res.status,200);
      assert.equal(res.body.initNum,undefined);
      assert.equal(res.body.initUnit,undefined);
      done();
    })})

   test("Convert kg(no number)",function(done){
    chai.request(server)
    .get("/api/convert")
    .query(({input:"kg"}))
    .end(function(err,res){
      assert.equal(res.status,200);
      assert.equal(res.body.initNum,1);
      assert.equal(res.body.initUnit,"kg");
      assert.approximately(res.body.returnNum,2.20462,0.1);
      assert.equal(res.body.returnUnit,"lbs");
      done();
    
    })
  })
  
})

})

});
anayone here who can tell me what is wrong with the code bcoz it is not loading the webapage server is not running passed allthe 5 test but page is not loading

solution: https://boilerplate-project-metricimpconverter-2--pavan-singhsin1.repl.co

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36

Challenge: Quality Assurance Projects - Metric-Imperial Converter

Link to the challenge:

Guys anyone here who can help me with this i am stuck

no one here who can help me??

i am having timeout issue

You may have to add .keepOpen() after any .request(server) call.

chai
  .request(server)
  .keepOpen()

thank you so much now its working i forgot to add

The boilerplate should maybe have a comment about it or the challenge text. Other challenge boilerplates that have tests skeleton code in the starting code have had that call added to them. But I’m not sure how to deal with it for this challenge as the starting code doesn’t really have any skeleton tests code.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.