Is there a way to tell if code is running in a tes...
# general
l
Is there a way to tell if code is running in a test? I think there used to be, but I can't find it any more. There's some functionality that's breaking tests, and I'm happy to live without while running my tests, but that means my component resources need to know if they're being constructed in a test stack or a real one...
a
l
No, that's for preview. In test mode, isDryRun can be set as a parameter to setMocks (4th parameter,
preview
), so it can be true or false.
Huh, don't know why I didn't see it before, it's right beside isDryRun: isTestModeEnabled.
Ah.. didn't see it before because it's been removed...
Removed in 3.38... 🤔
Looks like either
hasEngine()
or
hasMonitor()
will do what I need, but they're not documented as fas as I can tell. At least, their intent isn't documented, and I can't find tests for them that explain why I would call these methods. Developers aren't good at writing tests... sad panda