Skip to content

Commit 3158371

Browse files
fix: use PLAYWRIGHT_NODEJS_PATH in getNodeExecutable (#468)
1 parent 5628be8 commit 3158371

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

run.go

+5
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,11 @@ func transformRunOptions(options []*RunOptions) *RunOptions {
284284
}
285285

286286
func getNodeExecutable(driverDirectory string) string {
287+
envPath := os.Getenv("PLAYWRIGHT_NODEJS_PATH")
288+
if envPath != "" {
289+
return envPath
290+
}
291+
287292
node := "node"
288293
if runtime.GOOS == "windows" {
289294
node = "node.exe"

run_test.go

+16
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"testing"
1010

1111
"github.com/mitchellh/go-ps"
12+
"github.com/stretchr/testify/assert"
1213
"github.com/stretchr/testify/require"
1314
)
1415

@@ -88,6 +89,21 @@ func TestShouldNotHangWhenPlaywrightUnexpectedExit(t *testing.T) {
8889
require.Error(t, err)
8990
}
9091

92+
func TestGetNodeExecutable(t *testing.T) {
93+
// When PLAYWRIGHT_NODEJS_PATH is set, use that path.
94+
err := os.Setenv("PLAYWRIGHT_NODEJS_PATH", "envDir/node.exe")
95+
require.NoError(t, err)
96+
97+
executable := getNodeExecutable("testDirectory")
98+
assert.Equal(t, "envDir/node.exe", executable)
99+
100+
err = os.Unsetenv("PLAYWRIGHT_NODEJS_PATH")
101+
require.NoError(t, err)
102+
103+
executable = getNodeExecutable("testDirectory")
104+
assert.Contains(t, executable, "testDirectory")
105+
}
106+
91107
// find and kill playwright process
92108
func killPlaywrightProcess() error {
93109
all, err := ps.Processes()

0 commit comments

Comments
 (0)