sparse-intern-71089
05/08/2020, 12:53 AMlittle-cartoon-10569
05/08/2020, 12:55 AMsetMockOptions
or how to check if I'm in testing mode. I am using the example code from the docs, so I'm calling setMocks
, which should call setMockOptions
, but I haven't been able to prove it. I don't think I can debug.. I certainly don't know how (using js/ts/vscode, but a beginner in all of them).little-cartoon-10569
05/08/2020, 12:57 AMlittle-cartoon-10569
05/08/2020, 2:07 AMwhite-balloon-205
little-cartoon-10569
05/08/2020, 2:10 AMlittle-cartoon-10569
05/08/2020, 2:13 AMmocha -r ts-node/register
or npm test
to run the Pulumi engine? It looks like it's almost doing the right thing, but the mock option testModeEnabled is false... maybe?little-cartoon-10569
05/08/2020, 2:13 AMlittle-cartoon-10569
05/08/2020, 2:23 AMconsole.log
outputting pulumi.runtime.isTestModeEnabled()
before and after the call to pulumi.runtime.setMocks()
and it's going from false to true.. good. But now I'm getting
Error: The root stack resource was referenced before it was initialized.
at Object.registerStackTransformation (/app/node_modules/@pulumi/pulumi/runtime/stack.js21115)
little-cartoon-10569
05/08/2020, 2:26 AMregisterStackTransformation
from my Pulumi code brings me back to
Error: Program run without the Pulumi engine available; re-run using the😡CLIpulumi
little-cartoon-10569
05/08/2020, 2:45 AMdescribe('Vpc', function () {
it('should contain tags', function (done) {
const vpc = new aws.ec2.Vpc("VPC", {
"cidrBlock": "10.10.10.10/20",
"tags": { "name": "steve" }
});
pulumi.output(vpc.tags).apply((tags) => {
console.log(tags); // Logged fine.
done(); // Test passes.
});
});
});
describe('VpcX', function () {
it('should contain tags', function (done) {
const vpc = new awsx.ec2.Vpc("VPC", {
"cidrBlock": "10.10.10.10/20",
"tags": { "name": "steve" }
});
pulumi.output(vpc.vpc.tags).apply((tags) => {
console.log(tags); // Doesn't get logged.
done(); // Test errors out.
});
});
});
little-cartoon-10569
05/08/2020, 2:46 AMsteve
, it stops them complaining about all the others having better names.)little-cartoon-10569
05/08/2020, 2:52 AMpulumi.runtime
... I'll raise an issue in pulumi/pulumi-awsx. ¯\_(ツ)_/¯little-cartoon-10569
05/08/2020, 3:01 AMlittle-cartoon-10569
05/08/2020, 4:43 AMwhite-balloon-205
Same module (pulumi/pulumi) appeared in a few places in my dependency graph and I think it had a hard time with that.Ahh - got it - sorry for the troubles there. We are trying to shift to a model that will avoid this class of problem in the future (more use of
peerDependencies
in our own libraries).little-cartoon-10569
05/09/2020, 10:21 PM