Skip to content

Commit

Permalink
Add a test to ensure that module can be disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
ankur22 committed Dec 8, 2022
1 parent abcfa44 commit ae5c339
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions browser/module_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"testing"

"github.com/dop251/goja"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"github.com/grafana/xk6-browser/chromium"
Expand Down Expand Up @@ -32,3 +33,15 @@ func TestModuleNew(t *testing.T) {
require.NotNil(t, m.mod.Devices, "Devices should be set")
require.Equal(t, m.mod.Version, version, "Incorrect version")
}

func TestModuleNewDisabled(t *testing.T) {
t.Setenv("K6_BROWSER_DISABLE_RUN", "")

vu := &k6modulestest.VU{
RuntimeField: goja.New(),
InitEnvField: &k6common.InitEnvironment{
Registry: k6metrics.NewRegistry(),
},
}
assert.Panics(t, func() { New().NewModuleInstance(vu) })
}

0 comments on commit ae5c339

Please sign in to comment.