https://pulumi.com logo
Title
s

straight-energy-17452

11/30/2022, 9:25 AM
hi everyone, Quick question about unit testing component resources, I’m looking at this old answer from Joe https://github.com/pulumi/pulumi/issues/5461#issuecomment-1003424526 It’s consistent with the docs in how all the importing is done, specifically
let megabucket: typeof import("./megabucket");

    before(async () => {
        megabucket = await import("./megabucket");
    });
Is it really necessary? It’s a lot of ceremony and for my a component resource a regular top-level import works for me. This incantation only seems to be needed if people define resources not wrapped by a function or by a component resource?
l

little-cartoon-10569

11/30/2022, 7:28 PM
You're right. It's not necessary. I would go further and say that this syntax is a code smell.
If you're doing the OO thing with ComponentResource, then you should not have anything at the top level of any file, and this syntax will not be necessary.
s

straight-energy-17452

12/01/2022, 7:16 PM
Interesting… that’s quite strong but perhaps right
In any case thank you for responding @little-cartoon-10569 🙏