https://pulumi.com logo
#general
Title
# general
l

little-cartoon-10569

10/18/2022, 10:56 PM
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

able-bird-91336

10/19/2022, 5:18 AM
l

little-cartoon-10569

10/19/2022, 7:34 PM
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
4 Views