Problem with Text and Subfield Search ticket

my genreSearchQuery is as follows.

static genreSearchQuery(genre) {
/**
Ticket: Text and Subfield Search

Given an array of one or more genres, construct a query that searches
MongoDB for movies with that genre.
*/

const searchGenre = Array.isArray(genre) ? genre : genre.split(", ")


// TODO Ticket: Text and Subfield Search
// Construct a query that will search for the chosen genre.
const query = {genres: { $in: searchGenre}}
const project = {}
const sort = DEFAULT_SORT

return { query, project, sort }

}

when running the jest tests, i get the following mess of error messages

Determining test suites to run…Setup Mongo Connection
FAIL test/text-subfield.test.js
Text and Subfield Search
√ Can perform a text search (490ms)
× Can perform a genre search with one genre (442ms)
× Can perform a genre search with multiple genres (447ms)
√ Can perform a cast search with one cast member (412ms)
√ Can perform a cast search with multiple cast members (509ms)
√ Can perform a search and return a non-default number of movies per page (377ms)

● Text and Subfield Search › Can perform a genre search with one genre

expect(received).toEqual(expected)

Expected value to equal:
  20
Received:
  0

  22 |       filters,
  23 |     })
> 24 |     expect(moviesList.length).toEqual(20)
     |                               ^
  25 |     expect(totalNumMovies).toEqual(5917)
  26 |     const firstMovie = moviesList[0]
  27 |     expect(firstMovie["title"]).toEqual("Gladiator")

  at toEqual (test/text-subfield.test.js:24:31)
  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

● Text and Subfield Search › Can perform a genre search with multiple genres

expect(received).toEqual(expected)

Expected value to equal:
  20
Received:
  0

  33 |       filters,
  34 |     })
> 35 |     expect(moviesList.length).toEqual(20)
     |                               ^
  36 |     expect(totalNumMovies).toEqual(7259)
  37 |     const firstMovie = moviesList[0]
  38 |     expect(firstMovie["title"]).toEqual("2 Fast 2 Furious")

  at toEqual (test/text-subfield.test.js:35:31)
  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, 4 passed, 6 total
Snapshots: 0 total
Time: 5.29s, estimated 6s
Ran all test suites matching /text-subfield/i.
Teardown Mongo Connection
npm ERR! Test failed. See above for more details.

but when I run the query in compass, I get the record numbers expected by the test parameters.

Can anyone help?

Thanks

In both cases your code return 0 movies. By looking at where genreSearchQuery() is used, the exception handling explicitly return an empty list. I would add some traces in this part of the code to know more about the error. I would also make sure that the test driver connects to the same cluster?

in db genres are uppercase