modulestest

package
v0.43.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 20, 2023 License: AGPL-3.0 Imports: 9 Imported by: 4

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 added in v0.40.0

type Runtime struct {
	VU             *VU
	EventLoop      *eventloop.EventLoop
	CancelContext  func()
	BuiltinMetrics *metrics.BuiltinMetrics
}

Runtime is a helper struct that contains what is needed to run a (simple) module test

func NewRuntime added in v0.40.0

func NewRuntime(t testing.TB) *Runtime

NewRuntime will create a new test runtime and will cancel the context on test/benchmark end

func (*Runtime) MoveToVUContext added in v0.40.0

func (r *Runtime) MoveToVUContext(state *lib.State)

MoveToVUContext will set the state and nil the InitEnv just as a real VU

type VU added in v0.35.0

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) Context added in v0.35.0

func (m *VU) Context() context.Context

Context returns internally set field to conform to modules.VU interface

func (*VU) InitEnv added in v0.35.0

func (m *VU) InitEnv() *common.InitEnvironment

InitEnv returns internally set field to conform to modules.VU interface

func (*VU) RegisterCallback added in v0.37.0

func (m *VU) RegisterCallback() func(f func() error)

RegisterCallback is not really implemented

func (*VU) Runtime added in v0.35.0

func (m *VU) Runtime() *goja.Runtime

Runtime returns internally set field to conform to modules.VU interface

func (*VU) State added in v0.35.0

func (m *VU) State() *lib.State

State returns internally set field to conform to modules.VU interface

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL