I need help, i am unable to pass Ticket: Faceted Search

Documents/mflix-js$ npm test -t facets

server@1.0.0 test /home/coder/Documents/mflix-js
jest --passWithNoTests “facets”

Determining test suites to run…Setup Mongo Connection
FAIL test/facets.test.js
Facets
✓ should require cast members to perform search with (2ms)
✕ should return movies and runtime/rating facets for returned movies (947ms)
✕ should also support paging (790ms)
✓ should throw an error if castMembers is empty (1ms)

● Facets › should return movies and runtime/rating facets for returned movies

expect(received).toBe(expected) // Object.is equality

Expected: 4
Received: 5

  16 |     expect(actual.movies.length).toBe(20)
  17 |     expect(actual.rating.length).toBe(5)
> 18 |     expect(actual.runtime.length).toBe(4)
     |                                   ^
  19 |     expect(actual.count).toBe(37)
  20 |   })
  21 | 

  at toBe (test/facets.test.js:18:35)
  at tryCatch (node_modules/regenerator-runtime/runtime.js:62:40)
  at Generator.invoke [as _invoke] (node_modules/regenerator-runtime/runtime.js:296:22)
  at Generator.prototype.(anonymous function) [as next] (node_modules/regenerator-runtime/runtime.js:114:21)
  at step (node_modules/babel-runtime/helpers/asyncToGenerator.js:17:30)
  at node_modules/babel-runtime/helpers/asyncToGenerator.js:28:13

● Facets › should also support paging

expect(received).toBe(expected) // Object.is equality

Expected: 4
Received: 3

  25 |     expect(actual.movies.length).toBe(18)
  26 |     expect(actual.rating.length).toBe(3)
> 27 |     expect(actual.runtime.length).toBe(4)
     |                                   ^
  28 |     expect(actual.count).toBe(38)
  29 |   })
  30 | 

  at toBe (test/facets.test.js:27:35)
  at tryCatch (node_modules/regenerator-runtime/runtime.js:62:40)
  at Generator.invoke [as _invoke] (node_modules/regenerator-runtime/runtime.js:296:22)
  at Generator.prototype.(anonymous function) [as next] (node_modules/regenerator-runtime/runtime.js:114:21)
  at step (node_modules/babel-runtime/helpers/asyncToGenerator.js:17:30)
  at node_modules/babel-runtime/helpers/asyncToGenerator.js:28:13

Test Suites: 1 failed, 1 total
Tests: 2 failed, 2 passed, 4 total
Snapshots: 0 total
Time: 4.537s
Ran all test suites matching /facets/i.
Teardown Mongo Connection
npm ERR! Test failed. See above for more details.

I think i have followed the instruction, please help

static async facetedSearch({
filters = null,
page = 0,
moviesPerPage = 20,
} = {}) {
if (!filters || !filters.cast) {
throw new Error(“Must specify cast members to filter by.”)
}
const matchStage = { $match: filters }
const sortStage = { $sort: { “tomatoes.viewer.rating”: -1 } }
const countingPipeline = [matchStage, sortStage, { $count: “count” }]
const skipStage = { $skip: moviesPerPage * page }
const limitStage = { $limit: moviesPerPage }
const facetStage = {
$facet: {
runtime: [
{
$bucket: {
groupBy: “$runtime”,
boundaries: [0, 60, 90, 120, 180],
default: “other”,
output: {
count: { $sum: 1 },
},
},
},
],
rating: [
{
$bucket: {
groupBy: “$metacritic”,
boundaries: [0, 50, 70, 90, 100],
default: “other”,
output: {
count: { $sum: 1 },
},
},
},
],
movies: [
{
$addFields: {
title: “$title”,
},
},
],
},
}

/**
Ticket: Faceted Search
Please append the skipStage, limitStage, and facetStage to the queryPipeline
(in that order). You can accomplish this by adding the stages directly to
the queryPipeline.
The queryPipeline is a Javascript array, so you can use push() or concat()
to complete this task, but you might have to do something about `const`.
*/

const queryPipeline = [
  matchStage,
  sortStage,
  skipStage,
  limitStage,
  facetStage
  // TODO Ticket: Faceted Search
  // Add the stages to queryPipeline in the correct order.
]

try {
  const results = await (await movies.aggregate(queryPipeline)).next()
  const count = await (await movies.aggregate(countingPipeline)).next()
  return {
    ...results,
    ...count,
  }
} catch (e) {
  return { error: "Results too large, be more restrictive in filter" }
}

}

/**

  • Finds and returns movies by country.
  • Returns a list of objects, each object contains a title and an _id.
  • @param {Object} filters - The search parameters to use in the query.
  • @param {number} page - The page of movies to retrieve.
  • @param {number} moviesPerPage - The number of movies to display per page.
  • @returns {GetMoviesResult} An object with movie results and total results
  • that would match this query
    */
    static async getMovies({
    // here’s where the default parameters are set for the getMovies method
    filters = null,
    page = 0,
    moviesPerPage = 20,
    } = {}) {
    let queryParams = {}
    if (filters) {
    if (“text” in filters) {
    queryParams = this.textSearchQuery(filters[“text”])
    } else if (“cast” in filters) {
    queryParams = this.castSearchQuery(filters[“cast”])
    } else if (“genre” in filters) {
    queryParams = this.genreSearchQuery(filters[“genre”])
    }
    }
let { query = {}, project = {}, sort = DEFAULT_SORT } = queryParams
let cursor
try {
  cursor = await movies
    .find(query)
    .project(project)
    .sort(sort)
} catch (e) {
  console.error(`Unable to issue find command, ${e}`)
  return { moviesList: [], totalNumMovies: 0 }
}

/**
Ticket: Paging
Before this method returns back to the API, use the "moviesPerPage" and
"page" arguments to decide the movies to display.
Paging can be implemented by using the skip() and limit() cursor methods.
*/

// TODO Ticket: Paging
// Use the cursor to only return the movies that belong on the current page
const displayCursor = cursor.limit(moviesPerPage).skip(moviesPerPage * page)

try {
  const moviesList = await displayCursor.toArray()
  const totalNumMovies = page === 0 ? await movies.countDocuments(query) : 0

  return { moviesList, totalNumMovies }
} catch (e) {
  console.error(
    `Unable to convert cursor to array or problem counting documents, ${e}`,
  )
  return { moviesList: [], totalNumMovies: 0 }
}

}

<!doctype html>

mflix You need to enable JavaScript to run this app.
!function(l){function e(e){ for(var r,t,n=e[0],o=e[1],u=e[2],f=0,i=[];f<n.length;f++)t=n[f],p[t]&&i.push(p[t][0]),p[t]=0; for(r in o)Object.prototype.hasOwnProperty.call(o,r)&&(l[r]=o[r]); for(s&&s(e);i.length;)i.shift()(); return c.push.apply(c,u||[]),a() }
    function a(){
        for(var e,r=0;r<c.length;r++){
            for(var t=c[r],n=!0,o=1;o<t.length;o++){var u=t[o];0!==p[u]&&(n=!1)}n&&(c.splice(r--,1),e=f(f.s=t[0]))}
            return e}var t={},p={2:0},c=[];function f(e){
                if(t[e])
                return t[e].exports;var r=t[e]={i:e,l:!1,exports:{}};
                return l[e].call(r.exports,r,r.exports,f),r.l=!0,r.exports}f.m=l,f.c=t,f.d=function(e,r,t){f.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:t})},f.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},f.t=function(r,e){if(1&e&&(r=f(r)),8&e)return r;if(4&e&&"object"==typeof r&&r&&r.__esModule)return r;var t=Object.create(null);if(f.r(t),Object.defineProperty(t,"default",{enumerable:!0,value:r}),2&e&&"string"!=typeof r)for(var n in r)f.d(t,n,function(e){return r[e]}.bind(null,n));return t},f.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return f.d(r,"a",r),r},f.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},f.p="/";var r=window.webpackJsonp=window.webpackJsonp||[],n=r.push.bind(r);r.push=e,r=r.slice();for(var o=0;o<r.length;o++)e(r[o]);var s=n;a()}([])</script><script src="/static/js/1.18f02ebe.chunk.js">
    </script>
    <script
     src="/static/js/main.a01f0687.chunk.js">
    </script>
    </body>
    </html>