Skip to main content
Home

A universal testing module that works seamlessly across Deno, Node.js, and Bun runtimes. Write tests once, run them anywhere - from mobile to desktop, and 3D/spatial environments!

This package works with Cloudflare Workers, Node.js, Deno, Bun, Browsers
This package works with Cloudflare Workers
This package works with Node.js
This package works with Deno
This package works with Bun
This package works with Browsers
JSR Score
58%
Published
3 months ago (0.7.1)
v
_internalsFT

Used for testing that fake time uses real time correctly.

f
after

Alias of afterAll.

f
afterAll

Run some shared teardown after all of the tests in the suite.

f
afterEach

Run some shared teardown after each test in the suite.

f
assert

The assert function checks if something is true. If it's not true, it stops your code and tells you there's a problem.

f
assertAlmostEquals

This function checks if two numbers are almost equal.

T
AssertAnyConstructorProp

A type that represents any class or constructor. Think of it as a blueprint for creating things.

f
assertArrayIncludes

This function, assertArrayIncludes, checks if all elements of one array are present in another array.

T
AssertArrayLikeArgProp

A type for anything that works like a list (has a length and numbered items). This could be an array, string, or any other list-like thing.

T
AssertAssertionErrorProp

The type of error that happens when a test check fails. This helps you identify when and why a test didn't work.

f
assertEqual

Checks if two things are equal.

f
assertEquals

This function checks if two values are the same.

f
assertExists

This function, assertExists, checks if a value is present, meaning it is not null or undefined.

f
assertFail

This function fails a test by throwing an error.

f
assertFalse

This function, assertFalse, checks if a given expression is false.

T
AssertFalsyProp

Values that JavaScript considers as "false-like". These are: false, 0, "", null, undefined

T
AssertGetConstructorTypeProp

Gets the type of thing a class creates. Helps you work with the result of creating a new thing from a class.

f
assertGreater

This function checks if one value is greater than another.

f
assertGreaterOrEqual

This function checks if one value is greater than or equal to another value.

f
assertHTMLEquals

This function checks if an HTML element matches an expected HTML string.

f
assertInstanceOf

This function checks if a given value is an instance of a specific type.

c
AssertionError

This class represents an error that occurs when an assertion fails.

f
assertIsError

This function checks if a given value is an error. It is useful when you want to test if your code correctly handles errors.

f
assertLess

Checks if something is less than a certain value.

f
assertLessOrEqual

This function checks if one value is less than or equal to another value.

f
assertMatch

This function checks if a given text matches a specified pattern.

f
assertNotEquals

This function checks if two values are not the same.

f
assertNotInstanceOf

This function checks if a given object is not an instance of a specific type.

f
assertNotMatch

This function checks if a given string does not match a specified pattern.

f
assertNotStrictEquals

This function, assertNotStrictEquals, checks if two values are not strictly equal.

f
assertObjectMatch

This function checks if two objects are equal by comparing their properties.

f
assertRejects

This function, assertRejects, checks if a function that returns a promise rejects with a specific error.

f
assertSnapshot

AssertSnapshot

f
assertSpyCall

Asserts that a spy is called as expected.

f
assertSpyCallArg

Asserts that a spy is called with a specific arg as expected.

f
assertSpyCallArgs

Asserts that an spy is called with a specific range of args as expected. If a start and end index is not provided, the expected will be compared against all args. If a start is provided without an end index, the expected will be compared against all args from the start index to the end. The end index is not included in the range of args that are compared.

f
assertSpyCallAsync

Asserts that an async spy is called as expected.

f
assertSpyCalls

Asserts that a spy is called as much as expected and no more.

f
assertStrictEquals

This function checks if two values are exactly the same.

f
assertStringIncludes

This function checks if a string contains a specific substring.

f
assertThrows

This function checks if a function throws a specific error.

f
assertUnimplemented

This function throws an error to indicate that a function is not implemented.

f
assertUnreachable

This function throws an error to indicate that a piece of code should never be reached.

f
before

Alias of beforeAll

f
beforeAll

Run some shared setup before all of the tests in the group. Useful for async setup in describe blocks. Outside them, top-level initialization code should be used instead.

f
beforeEach

BeforeEach Hook

N
bench

Additional properties on the default function.

v
bench.ignore

Register a benchmark that will be skipped

v
bench.only

Register a benchmark that will be the only one executed

v
bench.skip

Alias for bench.ignore

I
ConsoleMocks

Collection of mock console functions

I
ConstructorSpyProp

A constructor wrapper that records all calls made to it.

f
createAssertSnapshot

CreateAssertSnapshot

f
createTest
No documentation available
f
I
N
describe

Describe Function

v
describe.ignore

Ignore the test suite.

v
describe.only

Only execute this test suite.

v
describe.skip

Skip the test suite.

T
DescribeArgs

The arguments for a DescribeFunction.

I
ExpectedSpyCallProp

Call information recorded by a spy.

c
FakeTime

Overrides the real Date object and timer functions with fake ones that can be controlled through the fake time instance.

I
f
formatTestName

Format InSpatial test name.

I
FsMockOptions

Options for file system mocking

I
FsMocks

Collection of mock file system functions

f
getAssertionState

return an instance of AssertionState

f
getMockCalls

Returns the calls made to a mock function.

f
isTestSpy

Checks if a function is a spy.

f
I
N
it

Registers an individual test case.

v
it.ignore

Ignore this test case.

v
it.only

Only execute this test case.

v
it.skip

Skip this test case.

T
ItArgs

The arguments for an ItFunction.

I
MethodSpyProp

An instance method wrapper that records all calls made to it.

c
MockError

An error related to spying on a function or instance method.

f
mockFn

Creates a mock function that can be used for testing and assertions.

f
mockSession

Creates a session that tracks all mocks created before it's restoredTest. If a callback is provided, it restoreTests all mocks created within it.

f
mockSessionAsync

Creates an async session that tracks all mocks created before the promise resolves.

T
OptionProp

Configuration options for running tests on InSpatial.

f
registerMock
No documentation available
f
resolvesNext

Creates a function that resolves the awaited iterable values. Any awaited iterable values that are errors will be thrown.

f
restoreTest

restoreTests all mocks registered in the current session that have not already been restoredTest. If an id is provided, it will restoreTest all mocks registered in the session associed with that id that have not already been restoredTest.

f
returnsNext

Creates a function that returns the iterable values. Any iterable values that are errors will be thrown.

f
returnsTestArg

Creates a function that returns one of its arguments.

f
returnsTestArgs

Creates a function that returns its arguments or a subset of them. If end is specified, it will return arguments up to but not including the end.

f
returnsThis

Creates a function that returns the instance the method was called on.

I
Runner

InSpatial Test runner.

v
runtime

InSpatial Test can run in different environments, which are like different places where your code can execute.

f
serialize
No documentation available
f
setupConsoleMocks

Sets up mocks for console functions

f
setupFsMocks

Sets up mocks for Deno's file system functions

f
setupMocks

Combined setup for both file system and console mocks

T
SnapshotMode

The mode of snapshot testing.

T
SnapshotOptions

The options for assertSnapshot.

f
spy

Creates a spy function.

I
SpyCallProp

Call information recorded by a spy.

T
SpyLikeProp

SpyPropLink object type.

I
SpyProp

A function or instance method wrapper that records all calls made to it.

f
stub

Replaces an instance method with a StubProp with empty implementation.

I
StubProp

An instance method replacement that records all calls made to it.

v
test

InSpatial Test

c
TestingError

TestingError can be used to test expected error behaviours in tests.

v
testSessions
No documentation available
f
throws

Throws back an error (can be used where statements are not allowed in syntax).

c
TimeError

Represents an error when trying to execute an invalid operation on fake time, given the state fake time is in.

f
unregisterMock
No documentation available

assert

Assert

f
assert

The assert function checks if something is true. If it's not true, it stops your code and tells you there's a problem.

f
assertAlmostEquals

This function checks if two numbers are almost equal.

T
AssertAnyConstructorProp

A type that represents any class or constructor. Think of it as a blueprint for creating things.

f
assertArrayIncludes

This function, assertArrayIncludes, checks if all elements of one array are present in another array.

T
AssertArrayLikeArgProp

A type for anything that works like a list (has a length and numbered items). This could be an array, string, or any other list-like thing.

T
AssertAssertionErrorProp

The type of error that happens when a test check fails. This helps you identify when and why a test didn't work.

f
assertEqual

Checks if two things are equal.

f
assertEquals

This function checks if two values are the same.

f
assertExists

This function, assertExists, checks if a value is present, meaning it is not null or undefined.

f
assertFail

This function fails a test by throwing an error.

f
assertFalse

This function, assertFalse, checks if a given expression is false.

T
AssertFalsyProp

Values that JavaScript considers as "false-like". These are: false, 0, "", null, undefined

T
AssertGetConstructorTypeProp

Gets the type of thing a class creates. Helps you work with the result of creating a new thing from a class.

f
assertGreater

This function checks if one value is greater than another.

f
assertGreaterOrEqual

This function checks if one value is greater than or equal to another value.

f
assertHTMLEquals

This function checks if an HTML element matches an expected HTML string.

f
assertInstanceOf

This function checks if a given value is an instance of a specific type.

c
AssertionError

This class represents an error that occurs when an assertion fails.

f
assertIsError

This function checks if a given value is an error. It is useful when you want to test if your code correctly handles errors.

f
assertLess

Checks if something is less than a certain value.

f
assertLessOrEqual

This function checks if one value is less than or equal to another value.

f
assertMatch

This function checks if a given text matches a specified pattern.

f
assertNotEquals

This function checks if two values are not the same.

f
assertNotInstanceOf

This function checks if a given object is not an instance of a specific type.

f
assertNotMatch

This function checks if a given string does not match a specified pattern.

f
assertNotStrictEquals

This function, assertNotStrictEquals, checks if two values are not strictly equal.

f
assertObjectMatch

This function checks if two objects are equal by comparing their properties.

f
assertRejects

This function, assertRejects, checks if a function that returns a promise rejects with a specific error.

f
assertStrictEquals

This function checks if two values are exactly the same.

f
assertStringIncludes

This function checks if a string contains a specific substring.

f
assertThrows

This function checks if a function throws a specific error.

f
assertUnimplemented

This function throws an error to indicate that a function is not implemented.

f
assertUnreachable

This function throws an error to indicate that a piece of code should never be reached.

f
getAssertionState

return an instance of AssertionState

bdd

Behavior-Driven Development (BDD)

f
after

Alias of afterAll.

f
afterAll

Run some shared teardown after all of the tests in the suite.

f
afterEach

Run some shared teardown after each test in the suite.

f
before

Alias of beforeAll

f
beforeAll

Run some shared setup before all of the tests in the group. Useful for async setup in describe blocks. Outside them, top-level initialization code should be used instead.

f
beforeEach

BeforeEach Hook

f
I
N
describe

Describe Function

v
describe.ignore

Ignore the test suite.

v
describe.only

Only execute this test suite.

v
describe.skip

Skip the test suite.

T
DescribeArgs

The arguments for a DescribeFunction.

I
DescribeDefinition

The options for creating a test suite with the describe function.

f
I
N
it

Registers an individual test case.

v
it.ignore

Ignore this test case.

v
it.only

Only execute this test case.

v
it.skip

Skip this test case.

T
ItArgs

The arguments for an ItFunction.

I
ItDefinition

The options for creating an individual test case with the it function.

f
N
test

Alias of it

v
test.ignore

Ignore this test case.

v
test.only

Only execute this test case.

v
test.skip

Skip this test case.

I
TestSuite

A group of tests.

f
N
bench

Register a benchmark

v
bench.ignore

Register a benchmark that will be skipped

v
bench.only

Register a benchmark that will be the only one executed

v
bench.skip

Alias for bench.ignore

I
BenchContext

Benchmark context providing timing control

I
BenchDefinition

Benchmark definition

T
BenchFunction

Benchmark function signature

I
BenchmarkRunner
No documentation available
f
clearBenchmarks

Clear all registered benchmarks (useful for testing)

f
createBenchmark
No documentation available
I
CreateBenchmarkOptions
No documentation available
f
getBenchmarkResults

Get benchmark results

f
getBenchmarks

Get all registered benchmarks

f
runBenchmarks

Run all registered benchmarks

ci-cd

CI/CD Environment Utilities for InSpatial

f
onlyInCI

Only run a test when in CI environment

f
onlyInCIProviders

Only run a test in specific CI providers

f
onlyInEnvironments

Only run a test in specific environments

f
onlyOnPlatforms

Only run a test on specific platforms

f
onlyOnRuntimes

Only run a test on specific runtime types

f
skipInCI

Skip a test when running in CI environment

f
skipInCIProviders

Skip a test when running in specific CI providers

f
skipInEnvironments

Skip a test in specific environments

f
skipOnPlatforms

Skip a test on specific platforms

f
skipOnRuntimes

Skip a test on specific runtime types

f
skipWithoutEnvVars

Skip a test when specific environment variables are missing

cleanup

Resource cleanup utilities for test environments

I
CleanupOptions

Options for cleanup execution

f
createTempDir

Create a temporary directory that will be cleaned up automatically

f
createTempFile

Create a temporary file that will be cleaned up automatically

v
globalCleanup

Global cleanup manager instance

c
ResourceManager

Resource manager for automatic cleanup of various resource types

c
TestCleanup

Test cleanup manager for handling resource cleanup in tests

f
withCleanup

Decorator for automatic cleanup registration

expect

An extended expect that defines additional matchers.

fs

Filesystem Mocking

I
ConsoleMocks

Collection of mock console functions

I
FsMockOptions

Options for file system mocking

I
FsMocks

Collection of mock file system functions

f
setupConsoleMocks

Sets up mocks for console functions

f
setupFsMocks

Sets up mocks for Deno's file system functions

f
setupMocks

Combined setup for both file system and console mocks

f
highlight

Syntax highlights code strings within backticks with ANSI codes.

f
assertSpyCall

Asserts that a spy is called as expected.

f
assertSpyCallArg

Asserts that a spy is called with a specific arg as expected.

f
assertSpyCallArgs

Asserts that an spy is called with a specific range of args as expected. If a start and end index is not provided, the expected will be compared against all args. If a start is provided without an end index, the expected will be compared against all args from the start index to the end. The end index is not included in the range of args that are compared.

f
assertSpyCallAsync

Asserts that an async spy is called as expected.

f
assertSpyCalls

Asserts that a spy is called as much as expected and no more.

I
ConsoleMocks

Collection of mock console functions

I
ConstructorSpyProp

A constructor wrapper that records all calls made to it.

I
ExpectedSpyCallProp

Call information recorded by a spy.

I
FsMockOptions

Options for file system mocking

I
FsMocks

Collection of mock file system functions

f
getMockCalls

Returns the calls made to a mock function.

f
isTestSpy

Checks if a function is a spy.

I
MethodSpyProp

An instance method wrapper that records all calls made to it.

c
MockError

An error related to spying on a function or instance method.

f
mockFn

Creates a mock function that can be used for testing and assertions.

f
mockSession

Creates a session that tracks all mocks created before it's restoredTest. If a callback is provided, it restoreTests all mocks created within it.

f
mockSessionAsync

Creates an async session that tracks all mocks created before the promise resolves.

f
registerMock
No documentation available
f
resolvesNext

Creates a function that resolves the awaited iterable values. Any awaited iterable values that are errors will be thrown.

f
restoreTest

restoreTests all mocks registered in the current session that have not already been restoredTest. If an id is provided, it will restoreTest all mocks registered in the session associed with that id that have not already been restoredTest.

f
returnsNext

Creates a function that returns the iterable values. Any iterable values that are errors will be thrown.

f
returnsTestArg

Creates a function that returns one of its arguments.

f
returnsTestArgs

Creates a function that returns its arguments or a subset of them. If end is specified, it will return arguments up to but not including the end.

f
returnsThis

Creates a function that returns the instance the method was called on.

f
setupConsoleMocks

Sets up mocks for console functions

f
setupFsMocks

Sets up mocks for Deno's file system functions

f
setupMocks

Combined setup for both file system and console mocks

f
spy

Creates a spy function.

I
SpyCallProp

Call information recorded by a spy.

T
SpyLikeProp

SpyPropLink object type.

I
SpyProp

A function or instance method wrapper that records all calls made to it.

f
stub

Replaces an instance method with a StubProp with empty implementation.

I
StubProp

An instance method replacement that records all calls made to it.

v
testSessions
No documentation available
f
unregisterMock
No documentation available
f
clearPerformanceData

Clears performance marks and measures

f
mark

Performance mark utility for creating named performance markers

f
measure

Performance measure utility for measuring time between marks

f
measureMemoryUsage

Utility function to measure memory usage of a function (when available)

f
measurePerformance

Utility function to measure the execution time of a function

v
performance

Universal performance API that works across all JavaScript runtimes

I
PerformanceMark
No documentation available
I
PerformanceMeasure
No documentation available
I
PerformanceMemory

Universal Performance API for InSpatial Test

reporter

Test reporting utilities for generating comprehensive test reports

retry

Retry utilities for handling flaky tests in CI/CD environments

f
retry

Advanced retry function with comprehensive options

f
retryTest

Retry a test function multiple times with configurable delay

f
retryTestConditional

Retry a test function with custom retry conditions

f
retryTestWithBackoff

Retry a test function with exponential backoff

f
assertSnapshot

AssertSnapshot

f
createAssertSnapshot

CreateAssertSnapshot

f
serialize
No documentation available
T
SnapshotMode

The mode of snapshot testing.

T
SnapshotOptions

The options for assertSnapshot.

time

Utilities for mocking time while testing.

v
_internalsFT

Used for testing that fake time uses real time correctly.

c
FakeTime

Overrides the real Date object and timer functions with fake ones that can be controlled through the fake time instance.

I
c
TimeError

Represents an error when trying to execute an invalid operation on fake time, given the state fake time is in.

New Ticket: Report package

Please provide a reason for reporting this package. We will review your report and take appropriate action.

Please review the JSR usage policy before submitting a report.