Quality Assurance Projects - Personal Library

I have written all the routes code, in Replit, and passed all the tests, except for the last one which is the functional tests:

Solution Link
https://boilerplate-project-library.alanbra.repl.co

// running tests
All 10 functional tests required are complete and passing.
// tests completed

I then wrote all the functional tests, added NODE_ENV with a value of test to Secrets and ran it through Replit - they all pass:

îș§ npm run start

> fcc-library@1.0.0 start
> node server.js

Your app is listening on port 3000
Running Tests...


  Functional Tests
    Routing tests
      POST /api/books with title => create book object/expect book object
        ✓ Test POST /api/books with title (190ms)
        ✓ Test POST /api/books with no title given
      GET /api/books => array of books
        ✓ Test GET /api/books (105ms)
      GET /api/books/[id] => book object with [id]
        ✓ Test GET /api/books/[id] with id not in db (105ms)
        ✓ Test GET /api/books/[id] with valid id in db (111ms)
      POST /api/books/[id] => add comment/expect book object with id
        ✓ Test POST /api/books/[id] with comment (115ms)
        ✓ Test POST /api/books/[id] without comment field
        ✓ Test POST /api/books/[id] with comment, id not in db (105ms)
      DELETE /api/books/[id] => delete book object id
        ✓ Test DELETE /api/books/[id] with valid id in db (126ms)
        ✓ Test DELETE /api/books/[id] with  id not in db (117ms)


  10 passing (1s)

But if I try and run the Replit and then immediately switch to freeCodeCamp and run, all the tests fail with timeouts:

// running tests
You can send a POST request to /api/books with title as part of the form data to add a book.  The returned response will be an object with the title and a unique _id as keys.  If title is not included in the request, the returned response should be the string missing required field title. (Test timed out)
You can send a GET request to /api/books and receive a JSON response representing all the books. The JSON response will be an array of objects with each object (book) containing title, _id, and commentcount properties. (Test timed out)
You can send a GET request to /api/books/{_id} to retrieve a single object of a book containing the properties title, _id, and a comments array (empty array if no comments present). If no book is found, return the string no book exists. (Test timed out)
You can send a POST request containing comment as the form body data to /api/books/{_id} to add a comment to a book. The returned response will be the books object similar to GET /api/books/{_id} request in an earlier test. If comment is not included in the request, return the string missing required field comment. If no book is found, return the string no book exists. (Test timed out)
You can send a DELETE request to /api/books/{_id} to delete a book from the collection. The returned response will be the string delete successful if successful. If no book is found, return the string no book exists. (Test timed out)
You can send a DELETE request to /api/books to delete all books in the database. The returned response will be the string complete delete successful if successful. (Test timed out)
All 10 functional tests required are complete and passing. (Test timed out)
// tests completed

Please advise

Your project link(s)

solution: boilerplate-project-library - Replit

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/110.0

Challenge: Quality Assurance Projects - Personal Library

Link to the challenge:

I found the following tip from Makoto-Araki:

   chai
     .request(server)
     .keepOpen()  // add

I put .keepOpen() after the .request(server) in each of my tests and now it works

Many thanks Makoto-Araki

1 Like

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