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!
Used for testing that fake time uses real time correctly.
Alias of afterAll.
Run some shared teardown after all of the tests in the suite.
Run some shared teardown after each test in the suite.
The assert function checks if something is true.
If it's not true, it stops your code and tells you there's a problem.
This function checks if two numbers are almost equal.
A type that represents any class or constructor. Think of it as a blueprint for creating things.
This function, assertArrayIncludes, checks if all elements of one array are present in another array.
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.
The type of error that happens when a test check fails. This helps you identify when and why a test didn't work.
Checks if two things are equal.
This function checks if two values are the same.
This function, assertExists, checks if a value is present, meaning it is not null or undefined.
This function fails a test by throwing an error.
This function, assertFalse, checks if a given expression is false.
Values that JavaScript considers as "false-like". These are: false, 0, "", null, undefined
Gets the type of thing a class creates. Helps you work with the result of creating a new thing from a class.
This function checks if one value is greater than another.
This function checks if one value is greater than or equal to another value.
This function checks if an HTML element matches an expected HTML string.
This function checks if a given value is an instance of a specific type.
This class represents an error that occurs when an assertion fails.
This function checks if a given value is an error. It is useful when you want to test if your code correctly handles errors.
Checks if something is less than a certain value.
This function checks if one value is less than or equal to another value.
This function checks if a given text matches a specified pattern.
This function checks if two values are not the same.
This function checks if a given object is not an instance of a specific type.
This function checks if a given string does not match a specified pattern.
This function, assertNotStrictEquals, checks if two values are not strictly equal.
This function checks if two objects are equal by comparing their properties.
This function, assertRejects, checks if a function that returns a promise rejects with a specific error.
AssertSnapshot
Asserts that a spy is called as expected.
Asserts that a spy is called with a specific arg as expected.
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.
Asserts that an async spy is called as expected.
Asserts that a spy is called as much as expected and no more.
This function checks if two values are exactly the same.
This function checks if a string contains a specific substring.
This function checks if a function throws a specific error.
This function throws an error to indicate that a function is not implemented.
This function throws an error to indicate that a piece of code should never be reached.
Alias of 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.
BeforeEach Hook
Additional properties on the default function.
Register a benchmark that will be skipped
Register a benchmark that will be the only one executed
Alias for bench.ignore
A constructor wrapper that records all calls made to it.
CreateAssertSnapshot
Ignore the test suite.
Only execute this test suite.
Skip the test suite.
The arguments for a DescribeFunction.
Overrides the real Date object and timer functions with fake ones that can be controlled through the fake time instance.
Format InSpatial test name.
Collection of mock file system functions
return an instance of AssertionState
Returns the calls made to a mock function.
Checks if a function is a spy.
Ignore this test case.
Only execute this test case.
Skip this test case.
The arguments for an ItFunction.
An instance method wrapper that records all calls made to it.
An error related to spying on a function or instance method.
Creates a mock function that can be used for testing and assertions.
Creates a session that tracks all mocks created before it's restoredTest. If a callback is provided, it restoreTests all mocks created within it.
Creates an async session that tracks all mocks created before the promise resolves.
Configuration options for running tests on InSpatial.
Creates a function that resolves the awaited iterable values. Any awaited iterable values that are errors will be thrown.
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.
Creates a function that returns the iterable values. Any iterable values that are errors will be thrown.
Creates a function that returns one of its arguments.
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.
Creates a function that returns the instance the method was called on.
InSpatial Test can run in different environments, which are like different places where your code can execute.
Sets up mocks for console functions
Sets up mocks for Deno's file system functions
Combined setup for both file system and console mocks
The mode of snapshot testing.
Creates a spy function.
SpyPropLink object type.
A function or instance method wrapper that records all calls made to it.
Replaces an instance method with a StubProp with empty implementation.
InSpatial Test
TestingError can be used to test expected error behaviours in tests.
Throws back an error (can be used where statements are not allowed in syntax).
Represents an error when trying to execute an invalid operation on fake time, given the state fake time is in.
assert
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.
This function checks if two numbers are almost equal.
A type that represents any class or constructor. Think of it as a blueprint for creating things.
This function, assertArrayIncludes, checks if all elements of one array are present in another array.
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.
The type of error that happens when a test check fails. This helps you identify when and why a test didn't work.
Checks if two things are equal.
This function checks if two values are the same.
This function, assertExists, checks if a value is present, meaning it is not null or undefined.
This function fails a test by throwing an error.
This function, assertFalse, checks if a given expression is false.
Values that JavaScript considers as "false-like". These are: false, 0, "", null, undefined
Gets the type of thing a class creates. Helps you work with the result of creating a new thing from a class.
This function checks if one value is greater than another.
This function checks if one value is greater than or equal to another value.
This function checks if an HTML element matches an expected HTML string.
This function checks if a given value is an instance of a specific type.
This class represents an error that occurs when an assertion fails.
This function checks if a given value is an error. It is useful when you want to test if your code correctly handles errors.
Checks if something is less than a certain value.
This function checks if one value is less than or equal to another value.
This function checks if a given text matches a specified pattern.
This function checks if two values are not the same.
This function checks if a given object is not an instance of a specific type.
This function checks if a given string does not match a specified pattern.
This function, assertNotStrictEquals, checks if two values are not strictly equal.
This function checks if two objects are equal by comparing their properties.
This function, assertRejects, checks if a function that returns a promise rejects with a specific error.
This function checks if two values are exactly the same.
This function checks if a string contains a specific substring.
This function checks if a function throws a specific error.
This function throws an error to indicate that a function is not implemented.
This function throws an error to indicate that a piece of code should never be reached.
return an instance of AssertionState
bdd
Behavior-Driven Development (BDD)
Alias of afterAll.
Run some shared teardown after all of the tests in the suite.
Run some shared teardown after each test in the suite.
Alias of 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.
BeforeEach Hook
Ignore the test suite.
Only execute this test suite.
Skip the test suite.
The arguments for a DescribeFunction.
The options for creating a test suite with the describe function.
Ignore this test case.
Only execute this test case.
Skip this test case.
The arguments for an ItFunction.
Alias of it
Ignore this test case.
Only execute this test case.
Skip this test case.
Register a benchmark
Register a benchmark that will be skipped
Register a benchmark that will be the only one executed
Alias for bench.ignore
Benchmark function signature
Clear all registered benchmarks (useful for testing)
Get benchmark results
Get all registered benchmarks
Run all registered benchmarks
ci-cd
CI/CD Environment Utilities for InSpatial
Only run a test when in CI environment
Only run a test in specific CI providers
Only run a test in specific environments
Only run a test on specific platforms
Only run a test on specific runtime types
Skip a test when running in CI environment
Skip a test when running in specific CI providers
Skip a test in specific environments
Skip a test on specific platforms
Skip a test on specific runtime types
Skip a test when specific environment variables are missing
cleanup
Resource cleanup utilities for test environments
Create a temporary directory that will be cleaned up automatically
Create a temporary file that will be cleaned up automatically
Global cleanup manager instance
Resource manager for automatic cleanup of various resource types
Test cleanup manager for handling resource cleanup in tests
Decorator for automatic cleanup registration
Error thrown when an assertion fails.
A friendly testing helper that lets you check if things work the way you want.
The ExtendedExpected interface defines the available assertion methods.
- not
- rejects
- resolves
- toBeBase64
- toBeDate
- toBeEmail
- toBeEmpty
- toBeExtensible
- toBeFinite
- toBeFrozen
- toBeFuture
- toBeHashed
- toBeIterable
- toBeOneOf
- toBeParseableJSON
- toBePast
- toBeReverseSorted
- toBeSealed
- toBeShallowCopyOf
- toBeSorted
- toBeType
- toBeUrl
- toBeWithin
- toHaveDescribedProperty
- toHaveImmutableProperty
- toRespondWithStatus
- toSatisfy
- toThrow
fs
Filesystem Mocking
Collection of mock file system functions
Sets up mocks for console functions
Sets up mocks for Deno's file system functions
Combined setup for both file system and console mocks
Syntax highlights code strings within backticks with ANSI codes.
Asserts that a spy is called as expected.
Asserts that a spy is called with a specific arg as expected.
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.
Asserts that an async spy is called as expected.
Asserts that a spy is called as much as expected and no more.
A constructor wrapper that records all calls made to it.
Collection of mock file system functions
Returns the calls made to a mock function.
Checks if a function is a spy.
An instance method wrapper that records all calls made to it.
An error related to spying on a function or instance method.
Creates a mock function that can be used for testing and assertions.
Creates a session that tracks all mocks created before it's restoredTest. If a callback is provided, it restoreTests all mocks created within it.
Creates an async session that tracks all mocks created before the promise resolves.
Creates a function that resolves the awaited iterable values. Any awaited iterable values that are errors will be thrown.
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.
Creates a function that returns the iterable values. Any iterable values that are errors will be thrown.
Creates a function that returns one of its arguments.
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.
Creates a function that returns the instance the method was called on.
Sets up mocks for console functions
Sets up mocks for Deno's file system functions
Combined setup for both file system and console mocks
Creates a spy function.
SpyPropLink object type.
A function or instance method wrapper that records all calls made to it.
Replaces an instance method with a StubProp with empty implementation.
Clears performance marks and measures
Performance mark utility for creating named performance markers
Performance measure utility for measuring time between marks
Utility function to measure memory usage of a function (when available)
Utility function to measure the execution time of a function
Universal performance API that works across all JavaScript runtimes
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
Advanced retry function with comprehensive options
Retry configuration options
Retry a test function multiple times with configurable delay
Retry a test function with custom retry conditions
Retry a test function with exponential backoff
AssertSnapshot
CreateAssertSnapshot
The mode of snapshot testing.
time
Utilities for mocking time while testing.
Used for testing that fake time uses real time correctly.
Overrides the real Date object and timer functions with fake ones that can be controlled through the fake time instance.
Represents an error when trying to execute an invalid operation on fake time, given the state fake time is in.