Phoenix Liveview Tests are complaining duplicate key value violates unique constraint "users_tokens_context_token_index"

Hello guys I am testing and during the test raises this error:

 mix test
ERROR:  database "live_view_studio_test" already exists
STATEMENT:  CREATE DATABASE "live_view_studio_test" ENCODING 'UTF8'

17:43:16.840 [info]  Migrations already up
..................................................................................................................ERROR:  duplicate key value violates unique constraint "users_tokens_context_token_index"
DETAIL:  Key (context, token)=(session, \x800b64fb797b77e7d7fee950ccb21ac99085b7067f066b48f73968649a8c750c) already exists.
STATEMENT:  INSERT INTO "users_tokens" ("context","token","user_id","inserted_at") VALUES ($1,$2,$3,$4) RETURNING "id"
........................................................................................

Finished in 8.1 seconds
202 tests, 0 failures

It needs to do something?

The error message is already very detailed. which part do you need more explanation?

Sorry, I understand.
But it’s like more a warning, not an error.
I never see an error inside the tests like these.
I just asking here If anyone knows and maybe it’s good to set something and not show anymore.

1 Like

I’m also getting this exact same error when I run my tests. All the tests pass, but I see “duplicate key value violates unique constraint” referring to the user tokens. It is particularly difficult to understand because there is no stack trace to show which of the ~200 tests is causing the error. Has anyone else experienced this issue and found a solution or workaround?

1 Like