http://kuukkanen.i2p/posts/testing
Let’s test the user creation logic. test ( "create user integration" , async () => { // Create a new user. expect ( await fetch ( "/api/user" , { method : "POST" , body : JSON . stringify ({ name : "user" , password : "password1234" , }), }). status , ). toBe ( 200 ); // Invalid request. expect ( await fetch ( "/api/user" , { method : "POST" , body : JSON . stringify ({}), }). status , ). toBe ( 400 ); // Create the same user again and fail. expect ( await fetch (...