modulestest

package
v0.2.8 Latest Latest
Warning

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

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

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 *workerMetrics.BuiltinMetrics
}

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

func NewRuntime

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

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

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

type VU

type VU struct {
	CtxField              context.Context
	InitEnvField          *common.InitEnvironment
	StateField            *libWorker.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

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

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

func (*VU) InitEnv

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

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

func (*VU) RegisterCallback

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

RegisterCallback is not really implemented

func (*VU) Runtime

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

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

func (*VU) State

func (m *VU) State() *libWorker.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