From 2f1343826811f2d24d487d383cf3a21ad55f72b7 Mon Sep 17 00:00:00 2001 From: Mihail Stoykov Date: Wed, 7 Apr 2021 12:37:05 +0300 Subject: [PATCH] Reenable TestNewJSRunnerWithCustomModule --- js/init_and_modules_test.go | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/js/init_and_modules_test.go b/js/init_and_modules_test.go index 89c20be9a8d..0a72fd90cc7 100644 --- a/js/init_and_modules_test.go +++ b/js/init_and_modules_test.go @@ -22,7 +22,9 @@ package js_test import ( "context" + "fmt" "net/url" + "sync/atomic" "testing" "time" @@ -59,20 +61,23 @@ func (cm *CheckModule) VuCtx(ctx context.Context) { assert.NotNil(cm.t, lib.GetState(ctx)) } +var uniqueModuleNumber int64 //nolint:gochecknoglobals + func TestNewJSRunnerWithCustomModule(t *testing.T) { - t.Skip() + t.Parallel() checkModule := &CheckModule{t: t} - modules.Register("k6/check", checkModule) + moduleName := fmt.Sprintf("k6/check-%d", atomic.AddInt64(&uniqueModuleNumber, 1)) + modules.Register(moduleName, checkModule) - script := ` - var check = require("k6/check"); + script := fmt.Sprintf(` + var check = require("%s"); check.initCtx(); module.exports.options = { vus: 1, iterations: 1 }; module.exports.default = function() { check.vuCtx(); }; - ` + `, moduleName) logger := testutils.NewLogger(t) rtOptions := lib.RuntimeOptions{CompatibilityMode: null.StringFrom("base")}