ageddesi/Mocked-API

Movies test seems brittle

computamike opened this issue · 0 comments

Describe the bug
Selecting a random movie end point returns the id to load based on the number of records in the list.

const randomNumber = Math.floor(Math.random() * movies.length) + 1

Firstly - it seems there is a utility function that could be used instead - so that might be a good refactor to do. This line will return a number between 1 and the number of records in the file

  • The source data is missing records :
    28,46,47,49, 52, 58, 76,86,87,89,90,102
    image
    Note that this screen shot shows records 89 & 90 are missing

If this is returned in a random number generator, then this will fail a test.

To Reproduce
This cannot be reproduced exactly, as it uses random.