Documentation ¶
Overview ¶
Package modulestest contains helpers to test js modules
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Runtime ¶
type Runtime struct { VU *VU EventLoop *eventloop.EventLoop CancelContext func() BuiltinMetrics *metrics.BuiltinMetrics // contains filtered or unexported fields }
Runtime is a helper struct that contains what is needed to run a (simple) module test
func NewRuntime ¶
NewRuntime will create a new test runtime and will cancel the context on test/benchmark end
func (*Runtime) MoveToVUContext ¶
MoveToVUContext will set the state and nil the InitEnv just as a real VU
func (*Runtime) SetupModuleSystem ¶
func (r *Runtime) SetupModuleSystem(goModules map[string]any, loader modules.FileLoader, c *compiler.Compiler) error
SetupModuleSystem sets up the modules system for the Runtime. See modules.NewModuleResolver for the meaning of the parameters.
func (*Runtime) SetupModuleSystemFromAnother ¶
SetupModuleSystemFromAnother sets up the modules system for the Runtime by using the resolver of another runtime.
type VU ¶
type VU struct { CtxField context.Context InitEnvField *common.InitEnvironment StateField *lib.State RuntimeField *goja.Runtime RegisterCallbackField func() func(f func() error) }
VU is a modules.VU implementation meant to be used within tests
func (*VU) InitEnv ¶
func (m *VU) InitEnv() *common.InitEnvironment
InitEnv returns internally set field to conform to modules.VU interface
func (*VU) RegisterCallback ¶
RegisterCallback is not really implemented