Can I still use the `chai` test helper in a Pulumi...
# typescript
l
Can I still use the
chai
test helper in a Pulumi unit test?
Copy code
network.name.apply((name) => {
            name.should.equal('empty_network')
        });
results in my test passing, but still got this stack:
Copy code
(node:50206) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'should' of undefined
    at /Users/ringods/Projects/cumundi/libraries/packages/iac-gcp/test/network.spec.ts:60:18
    at /Users/ringods/Projects/cumundi/libraries/node_modules/@pulumi/pulumi/output.js:249:35
    at Generator.next (<anonymous>)
    at /Users/ringods/Projects/cumundi/libraries/node_modules/@pulumi/pulumi/output.js:21:71
    at new Promise (<anonymous>)
    at __awaiter (/Users/ringods/Projects/cumundi/libraries/node_modules/@pulumi/pulumi/output.js:17:12)
    at applyHelperAsync (/Users/ringods/Projects/cumundi/libraries/node_modules/@pulumi/pulumi/output.js:228:12)
    at /Users/ringods/Projects/cumundi/libraries/node_modules/@pulumi/pulumi/output.js:182:65
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
w
What kind of Pulumi unit test is this? Are you following the patterns in https://www.pulumi.com/docs/guides/testing/unit/, or something else? Note that the error here is that
name
is undefined - is that "expected" based on the surrounding code?
l
@white-balloon-205 this is a Mocha test. Within the
it
block, I started from this:
Copy code
network.name.apply((name) => {
    if (name == 'empty_network') {
        done()
    } else {
        done(new Error(`name is ${name}`))
    }
});
But this if/else block pattern is quite verbose for each test, so I tried to mix in
chai
. First revision:
Copy code
network.name.apply((name) => {
    name.should.equal('empty_network')
});
I dropped the
done
argument from the
it
function callback. This works. But an
Output
is
Promise
-like, so I tried the
eventually
feature from
chai
in a second revision:
Copy code
network.name.should.eventually.equal('empty_network')
But here I get a failure:
TypeError: {} is not a thenable.