hi everyone, Quick question about unit testing com...
# typescript
s
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
Copy code
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
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
Interesting… that’s quite strong but perhaps right
In any case thank you for responding @little-cartoon-10569 🙏