Are there any examples of how to test a component ...
# package-authoring
Are there any examples of how to test a component when using the
? I see some test when you are using resources like here, but not seeing anything with testing components like this one for example. Any docs or guidance in that regard?
There isn’t test support at the
level. I would use Pulumi's standard testing framework as a wrapper around the component you are implementing.
For simple components this seems pretty straightforward. However, when I go to test a more complex component I can’t figure out how to get it to work. For instance, I have a component that accepts an eks.ClusterOutput as an argument, and the component then makes use of the clusters name (I know I could refactor to pass the name and if it was just that I would) and I can’t see what I need to do.
Copy code
func TestConstruct(t *testing.T) {
	err := pulumi.RunErr(func(ctx *pulumi.Context) error {
		cluster, err := eks.NewCluster(ctx, "my-cluster", &eks.ClusterArgs{
			Name: pulumi.String("my-cluster"),
		assert.NoError(t, err)

		sa := Blah{}
		args := BlahArgs{
			EksCluster:     cluster.ToClusterOutput(),
			Bar: pulumi.String("baz"),

		_, err = sa.Construct(ctx, "my-sa", "xyx:abc:Blah", args, pulumi.Protect(false))
		assert.NoError(t, err)

		return nil
	}, pulumi.WithMocks("project", "stack", mocks(0)))
	if err != nil {
results in a
panic: runtime error: invalid memory address or nil pointer dereference
every time