This message was deleted.
# typescript
s
This message was deleted.
l
This isn't a problem with setMocks, just with the runtime not detecting that you're running as a test. Normally it does detect this correctly, but it is possible to "break" this detection. For example, in some of my test code I use pulumi.runtime.registerStackTransformation() which does not play well with Pulumi's test-detection logic.
The workaround is to run the tests where this problem happens within a pulumi.runtime.runInPulumiStack() block. You don't need to change your pulumi.runtime.setMocks() code, just the tests where Pulumi resources are constructed.
In my code, the calls to setMocks() and runInPulumiStack() are at the same level. It's important not to nest setMocks() inside runInPulumiStack().