Skip to content

Commit

Permalink
fix: use PLAYWRIGHT_NODEJS_PATH in getNodeExecutable (#468)
Browse files Browse the repository at this point in the history
  • Loading branch information
carsonmeyer-wk committed Jun 17, 2024
1 parent 5628be8 commit 3158371
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
5 changes: 5 additions & 0 deletions run.go
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,11 @@ func transformRunOptions(options []*RunOptions) *RunOptions {
}

func getNodeExecutable(driverDirectory string) string {
envPath := os.Getenv("PLAYWRIGHT_NODEJS_PATH")
if envPath != "" {
return envPath
}

node := "node"
if runtime.GOOS == "windows" {
node = "node.exe"
Expand Down
16 changes: 16 additions & 0 deletions run_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"testing"

"github.com/mitchellh/go-ps"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)

Expand Down Expand Up @@ -88,6 +89,21 @@ func TestShouldNotHangWhenPlaywrightUnexpectedExit(t *testing.T) {
require.Error(t, err)
}

func TestGetNodeExecutable(t *testing.T) {
// When PLAYWRIGHT_NODEJS_PATH is set, use that path.
err := os.Setenv("PLAYWRIGHT_NODEJS_PATH", "envDir/node.exe")
require.NoError(t, err)

executable := getNodeExecutable("testDirectory")
assert.Equal(t, "envDir/node.exe", executable)

err = os.Unsetenv("PLAYWRIGHT_NODEJS_PATH")
require.NoError(t, err)

executable = getNodeExecutable("testDirectory")
assert.Contains(t, executable, "testDirectory")
}

// find and kill playwright process
func killPlaywrightProcess() error {
all, err := ps.Processes()
Expand Down

0 comments on commit 3158371

Please sign in to comment.