User-report test fails but status report ok

When running test user-report getting results for same user but with diferent count total:

Expected value to equal:
  {"_id": "roger_ashton-griffiths@gameofthron.es", "count": 909}
Received:
  {"_id": "roger_ashton-griffiths@gameofthron.es", "count": 818}

other test failed:

- Expected
+ Received

  Object {
    "_id": "roger_ashton-griffiths@gameofthron.es",
-   "count": 909,
+   "count": 818,
  }

The /status link verificaton for this does not actually have very stringent tests that you actually implemented this correctly. As such I’m not going to say what the very easy way to fake a result here is, but it’s actually all too easy.

That you are getting different results to what the unit test expects is basically due to either of two options:

  1. Aggregation pipeline implemented incorrectly.

  2. Data has been corrupted or not imported properly.

In the case of 1. or just basically with the very fact you already got a verification code from the /status page, you can simply compare your aggregation pipeline with the one which will now be available to you as a possible answer as this link becomes available once you submit the verification code.

In the case of 2, or indeed where you compared the pipelines but still get a different result, then your best bet is to download the handouts again, extract the /data directory from within the mflix-js folder and run the mongoimport again. Ensuring to include the --drop option so that all data is overwritten.

Note if you do “re-import”, you need to run the migration script again in order to get that test operating. But for “data only” restores, nothing in the other tests is effected as all changes for those are self contained.

Restored (several times) data and then worked.

const pipeline = [{ $group: { email: comments.email, num_Comments: { $sum: 1 } } }]

please correct me what am missing