'needs' block appears to not be working

I am trying to understand how to use the needs block in gitlab yaml. As I understand from the docs, you would use this statement to run jobs in any order but enforce that some jobs require others to be completed. So I have my starting point which has a needs: [ ] statement which I take to imply that this job does not depend on other jobs. This works and it is fine

Now I have a file in which the various steps for the frontend are configured. Here there is a job that has the needs: [ ] (empty array) and this job starts first. This job builds the frontend and has a name of frontend:build.

Next there is the job to run unit tests, this job is called frontend:test:unit and has needs: ["frontend:build"]. Unless I completely misunderstand the scant documentation on needs I would assume this means that the unit test job ‘needs’ the build job.

When I run the pipeline, the build job starts and then sometimes it fails. At the same time the unit test job also runs.

Am I fundamentally misunderstanding how ‘needs’ is supposed to work? Does it have a different meaning than ‘this job needs another job to start’ ?

Any advice would be appreciated
Thanks