Hello, we're using Pulumi v3.2.1 and Azure-Native ...
# typescript
Hello, we're using Pulumi v3.2.1 and Azure-Native 1.1.0. We want to unit test creating resources. We've followed the guide here: https://www.pulumi.com/docs/guides/testing/unit/ Unit tests are written in Typescript with Jest Our Mock looks like this:
Copy code
    newResource(args: MockResourceArgs): { id: string | undefined; state: Record<string, any> } {
        const { type, id, name } = args;
        return {
            state: {
    call(args: MockCallArgs) {
        return args.inputs;
Running tests give: `Program run without the Pulumi engine available; re-run using the
CLI` Is anyone able to help with why this is?
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().