Class: TestQuickJSWASMModule
February 16, 2026 ยท View on GitHub
quickjs-emscripten / quickjs-emscripten / TestQuickJSWASMModule
Class: TestQuickJSWASMModule
Defined in: packages/quickjs-emscripten-core/src/module-test.ts:18
A test wrapper of QuickJSWASMModule that keeps a reference to each context or runtime created.
Call disposeAll to reset these sets and calls dispose on any left alive
(which may throw an error).
Call assertNoMemoryAllocated at the end of a test, when you expect that you've freed all the memory you've ever allocated.
Contents
Implements
Pick<QuickJSWASMModule, keyofQuickJSWASMModule>
Constructors
Constructor
new TestQuickJSWASMModule(
parent):TestQuickJSWASMModule
Defined in: packages/quickjs-emscripten-core/src/module-test.ts:21
Parameters
parent
Returns
TestQuickJSWASMModule
Properties
contexts
contexts:
Set<QuickJSContext>
Defined in: packages/quickjs-emscripten-core/src/module-test.ts:19
runtimes
runtimes:
Set<QuickJSRuntime>
Defined in: packages/quickjs-emscripten-core/src/module-test.ts:20
Methods
assertNoMemoryAllocated()
assertNoMemoryAllocated():
void
Defined in: packages/quickjs-emscripten-core/src/module-test.ts:62
Returns
void
disposeAll()
disposeAll():
void
Defined in: packages/quickjs-emscripten-core/src/module-test.ts:51
Returns
void
evalCode()
evalCode(
code,options?):unknown
Defined in: packages/quickjs-emscripten-core/src/module-test.ts:47
One-off evaluate code without needing to create a QuickJSRuntime or QuickJSContext explicitly.
To protect against infinite loops, use the shouldInterrupt option. The
shouldInterruptAfterDeadline function will create a time-based deadline.
If you need more control over how the code executes, create a QuickJSRuntime (with newRuntime) or a QuickJSContext (with newContext or QuickJSRuntime#newContext), and use its QuickJSContext#evalCode method.
Asynchronous callbacks may not run during the first call to evalCode. If
you need to work with async code inside QuickJS, create a runtime and use
QuickJSRuntime#executePendingJobs.
Parameters
code
string
options?
Returns
unknown
The result is coerced to a native Javascript value using JSON serialization, so properties and values unsupported by JSON will be dropped.
Throws
If code throws during evaluation, the exception will be
converted into a native Javascript value and thrown.
Throws
if options.shouldInterrupt interrupted execution, will throw a Error
with name "InternalError" and message "interrupted".
Implementation of
getWasmMemory()
getWasmMemory():
Memory
Defined in: packages/quickjs-emscripten-core/src/module-test.ts:79
Experimental
Retrieve the WebAssembly memory used by this QuickJS module. Use this access very carefully - you are responsible for safe interaction with the memory.
To supply a custom, pre-initialized memory to QuickJS, create a new variant and provide the CustomizeVariantOptions#wasmMemory option.
Returns
Memory
Implementation of
QuickJSWASMModule.getWasmMemory
newContext()
newContext(
options?):QuickJSContext
Defined in: packages/quickjs-emscripten-core/src/module-test.ts:35
A simplified API to create a new QuickJSRuntime and a QuickJSContext inside that runtime at the same time. The runtime will be disposed when the context is disposed.
Parameters
options?
Returns
Implementation of
newRuntime()
newRuntime(
options?):QuickJSRuntime
Defined in: packages/quickjs-emscripten-core/src/module-test.ts:23
Create a runtime. Use the runtime to set limits on CPU and memory usage and configure module loading for one or more QuickJSContexts inside the runtime.