github.com/kubeshop/testkube@v1.17.23/contrib/executor/playwright/pkg/runner/playwright_test.go (about)

     1  package runner
     2  
     3  import (
     4  	"context"
     5  	"os"
     6  	"path/filepath"
     7  	"testing"
     8  
     9  	cp "github.com/otiai10/copy"
    10  	"github.com/stretchr/testify/assert"
    11  
    12  	"github.com/kubeshop/testkube/pkg/api/v1/testkube"
    13  	"github.com/kubeshop/testkube/pkg/envs"
    14  	"github.com/kubeshop/testkube/pkg/utils/test"
    15  )
    16  
    17  func TestRun_Integration(t *testing.T) {
    18  	test.IntegrationTest(t)
    19  	t.Parallel()
    20  	// setup
    21  	tempDir, err := os.MkdirTemp("", "*")
    22  	assert.NoErrorf(t, err, "failed to create temp dir: %v", err)
    23  	defer os.RemoveAll(tempDir)
    24  
    25  	repoDir := filepath.Join(tempDir, "repo")
    26  	assert.NoError(t, os.Mkdir(repoDir, 0755))
    27  	_ = cp.Copy("../../examples", repoDir)
    28  
    29  	ctx := context.Background()
    30  
    31  	params := envs.Params{DataDir: tempDir}
    32  	runner, err := NewPlaywrightRunner(ctx, "npm", params)
    33  	if err != nil {
    34  		t.Fail()
    35  	}
    36  
    37  	result, err := runner.Run(
    38  		ctx,
    39  		testkube.Execution{
    40  			Content: &testkube.TestContent{
    41  				Type_: string(testkube.TestContentTypeGitDir),
    42  				Repository: &testkube.Repository{
    43  					Type_:  "git",
    44  					Uri:    "",
    45  					Branch: "master",
    46  					Path:   "",
    47  				},
    48  			},
    49  			Command: []string{
    50  				"<depManager>",
    51  			},
    52  			Args: []string{
    53  				"<depCommand>",
    54  				"playwright",
    55  				"test",
    56  			},
    57  		})
    58  
    59  	assert.Equal(t, result.Status, testkube.ExecutionStatusPassed)
    60  	assert.NoError(t, err)
    61  }