Hello! The code that the scratchpad automatically generates is not always ready to be run as is. Sometimes you'll need to define some variables or copy paste your Unit Test to get it to run. The idea is that we attempt to generate a sample test file for you, but it is not always perfect.
We have acknowledged this as a bit confusing, so we are working on some changes to simplify + clarify how scratchpad works! I'll make sure to update this thread when the changes go live.