See below full error detail:
FAIL test/get-comments.test.js
Get Comments
× Can fetch comments for a movie (419ms)
× comments should be sorted by date (375ms)
● Get Comments › Can fetch comments for a movie
expect(received).toEqual(expected) // deep equality
Expected: "The Express"
Received: "Blacksmith Scene"
9 | const id = "573a13b5f29313caabd42c2f"
10 | const movie = await MoviesDAO.getMovieByID(id)
> 11 | expect(movie.title).toEqual("The Express")
| ^
12 | expect(movie.comments.length).toBe(147)
13 | })
14 |
at toEqual (test/get-comments.test.js:11:25)
at tryCatch (node_modules/regenerator-runtime/runtime.js:45:40)
at Generator.invoke [as _invoke] (node_modules/regenerator-runtime/runtime.js:271:22)
at Generator.prototype.<computed> [as next] (node_modules/regenerator-runtime/runtime.js:97:21)
at asyncGeneratorStep (node_modules/@babel/runtime/helpers/asyncToGenerator.js:3:24)
at _next (node_modules/@babel/runtime/helpers/asyncToGenerator.js:25:9)
● Get Comments › comments should be sorted by date
TypeError: Cannot read property 'slice' of undefined
20 | const movie = await MoviesDAO.getMovieByID(id)
21 | const comments = movie.comments
> 22 | const sortedComments = comments.slice()
| ^
23 | sortedComments.sort((a, b) => b.date.getTime() - a.date.getTime())
24 |
25 | for (let i = 0; i < Math.min(10, comments.length); i++) {
at slice (test/get-comments.test.js:22:39)
at tryCatch (node_modules/regenerator-runtime/runtime.js:45:40)
at Generator.invoke [as _invoke] (node_modules/regenerator-runtime/runtime.js:271:22)
at Generator.prototype.<computed> [as next] (node_modules/regenerator-runtime/runtime.js:97:21)
at asyncGeneratorStep (node_modules/@babel/runtime/helpers/asyncToGenerator.js:3:24)
at _next (node_modules/@babel/runtime/helpers/asyncToGenerator.js:25:9)
● Get Comments › comments should be sorted by date
expect.assertions(10)
Expected ten assertions to be called but received zero assertion calls.
15 | test("comments should be sorted by date", async () => {
16 | // most recent to least
> 17 | expect.assertions(10)
| ^
18 | const movieIds = ["573a13b5f29313caabd42c2f"]
19 | const promises = movieIds.map(async id => {
20 | const movie = await MoviesDAO.getMovieByID(id)
at assertions (test/get-comments.test.js:17:12)
at tryCatch (node_modules/regenerator-runtime/runtime.js:45:40)
at Generator.invoke [as _invoke] (node_modules/regenerator-runtime/runtime.js:271:22)
at Generator.prototype.<computed> [as next] (node_modules/regenerator-runtime/runtime.js:97:21)
at asyncGeneratorStep (node_modules/@babel/runtime/helpers/asyncToGenerator.js:3:24)
at _next (node_modules/@babel/runtime/helpers/asyncToGenerator.js:25:9)
at node_modules/@babel/runtime/helpers/asyncToGenerator.js:32:7
at Object.<anonymous> (node_modules/@babel/runtime/helpers/asyncToGenerator.js:21:12)
Test Suites: 1 failed, 1 total
Tests: 2 failed, 2 total
Snapshots: 0 total
Time: 9.256s
Ran all test suites matching /get-comments/i.
Teardown Mongo Connection
npm ERR! Test failed. See above for more details.