limited-rainbow-51650
05/07/2020, 9:09 PMchai
test helper in a Pulumi unit test?
network.name.apply((name) => {
name.should.equal('empty_network')
});
results in my test passing, but still got this stack:
(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)
white-balloon-205
05/07/2020, 9:48 PMname
is undefined - is that "expected" based on the surrounding code?limited-rainbow-51650
05/08/2020, 5:49 AMit
block, I started from this:
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:
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:
network.name.should.eventually.equal('empty_network')
But here I get a failure:
TypeError: {} is not a thenable.