Does anyone know the best way to mock the resource...
# typescript
Does anyone know the best way to mock the resource to unit test?
To fake a resource, Pulumi provides the
function, which allows you to create dumb or smart stubs for all resource constructors and provider getters. Is that what you're looking for?
👍 1
There is no true mocking support, you would have to add that yourself, maybe via a mocking library.
I have pretty lengthy stack.yaml and using static variables on a class to get access to the configs, but I think you're right I just need to actually just do the mock myself. Thanks!
Generally, configs are best loaded by index.ts, which isn't faked / stubbed. All configuration values, wherever they come from, should be passed into the constructor of a resource.
This helps with lowering coupling and increasing both testability and readability.
❤️ 2
Don't test your use of configuration, just class/component logic.
Very helpful thank you