Fix exceptions during JS Code Hint Unit Tests

This is for #5099.

This avoids exception, but I'm not sure about intent of code, and no unit tests are failing. Maybe this is a symptom of missing methods on some objects?

Note that this only happens during unit tests, so it might be a timing difference or maybe something it not setup right. Still seems like a good safety check.