test: add test for logging trace of dynamic = error (#61811)
Add test that we can log the error trace when we found invalid dynamic
usage when `dynamic = "error"`

Closes NEXT-2402
Closes NEXT-2383