Optional
[Bail out on the first failed test point
Numeric identifier for this test
Method that writes to stderr when debug: true
is set in the options,
or no-ops otherwise
Show diagnostics for this test. A value of null
means that
diagnostics will be shown only if the test is failing.
Set true when @tapjs/core!test-base.TestBase#end is called
number of spaces to indent the TAP stream
Nesting level, for serialization to node test runner
Note that this is zero for parent-less tests, and also zero for the first level of children.
Do not emit the TAP version 14
line at the start
Options provided to this test
Do not elide extraneous whitespace and empty lines.
true if the stream can be read
Set upon test completion when a child test is ready to be processed by its parent.
True if this test should be buffered and only emit data if it fails
Treat non-TAP data as an error.
May be set with pragma +strict
in the TAP stream, or unset with
pragma: -strict
.
Set to true when the test times out, so its failure status can be determined later.
true if the stream can be written
True if the stream has been aborted.
No-op setter. Stream aborted status is set via the AbortSignal provided in the constructor options.
true if this is an async stream
Set to true to make this stream async.
Once set, it cannot be unset, as this would potentially cause incorrect behavior. Ie, a sync stream can be made async, but an async stream cannot be safely made sync.
The amount of data stored in the buffer waiting to be read.
For Buffer strings, this will be the total byte length.
For string encoding streams, this will be the string character length,
according to JavaScript's string.length
logic.
For objectMode streams, this is a count of the items waiting to be
emitted.
Method that will be called on snapshot strings. This can be used to remove transient run-specific data from snapshots using simple string transforms.
Options that will be used when formatting snapshots and diffing/comparing objects using any assertion methods.
true if the stream has been forcibly destroyed
true if the 'end' event has been emitted
The BufferEncoding
currently in use, or null
true if the stream is currently in a flowing state, meaning that any writes will be immediately emitted.
Function that turns an object into a snapshot string.
By default tcompare!format is used. If a string is returned, then that string is the snapshot string. If any other type is returned, then the returned value will be formatted using tcompare!format.
The full name of the test, starting with the main script name, and including all parent names.
True if the test is currently in an idle state
True if this is an objectMode stream
true if the stream is currently in a paused state
The string signature of the plugins built into this Test class
Set whether the fixture should be saved or not
Must be set BEFORE calling @tapjs/fixture!index.TestFixtures#testdir, or it will not have any effect.
The file where snapshots will be written to and read from
Boolean indicating whether the underlying stream can be written to, or if it has been ended.
In the worker thread, the worker data that was provided to the t.worker method.
In the main thread, this field is undefined
.
Asynchronous for await of
iteration.
This will continue emitting all chunks until the stream terminates.
Optional
[captureOptional
noDrain: booleanSynchronous for of
iteration.
The iteration will terminate when the internal buffer runs out, even if the stream has not yet terminated.
Alias for Minipass#on
Change the working directory, for the context of a single test.
Return a Promise that resolves to an array of all emitted data once the stream ends.
output a TAP comment, formatted like console.log()
If the test is currently awaiting a child test, it will be deferred until after the child test completes.
If the test is already completed, the comment will be emitted on the parent, or if no parent is available, it will be printed to standard output.
Return a Promise that resolves to the concatenation of all emitted data once the stream ends.
Not allowed on objectMode streams.
Destroy a stream, preventing it from being used for any further purpose.
If the stream has a close()
method, then it will be called on
destruction.
After destruction, any attempt to write data, read data, or emit most events will be ignored.
If an error argument is provided, then it will be emitted in an 'error' event.
Optional
er: unknownReturns an array listing the events for which the emitter has registered
listeners. The values in the array are strings or Symbol
s.
import { EventEmitter } from 'node:events';
const myEE = new EventEmitter();
myEE.on('foo', () => {});
myEE.on('bar', () => {});
const sym = Symbol('symbol');
myEE.on(sym, () => {});
console.log(myEE.eventNames());
// Prints: [ 'foo', 'bar', Symbol(symbol) ]
Returns the current max listener value for the EventEmitter
which is either
set by emitter.setMaxListeners(n)
or defaults to EventEmitter.defaultMaxListeners.
Returns the number of listeners listening for the event named eventName
.
If listener
is provided, it will return how many times the listener is found
in the list of the listeners of the event.
The name of the event being listened for
Optional
listener: FunctionThe event handler function
Returns a copy of the array of listeners for the event named eventName
.
server.on('connection', (stream) => {
console.log('someone connected!');
});
console.log(util.inspect(server.listeners('connection')));
// Prints: [ [Function] ]
Set some mocks that will be used for all subsequent @tapjs/mock!index.TapMock#mockImport and @tapjs/mock!index.TapMock#mockRequire calls made by this test.
Mocks added with mockAll
are overridden by any explicit mocks set in the
t.mockRequire
or t.mockImport
call.
Repeated calls to t.mockAll()
will add mocks to the set. If the same
name is used again, it will replace the previous value, not merge.
If a key is set to undefined
or null
, then it will be removed from
the mockAll
set.
Reset by calling t.mockAll(null)
Call with no args to return the current mockAll
object.
Optional
mocks: null | Record<string, any>Mostly identical to EventEmitter.off
If a 'data' event handler is removed, and it was the last consumer (ie, there are no pipe destinations or other 'data' event listeners), then the flow of data will stop until there is another consumer or Minipass#resume is explicitly called.
Mostly identical to EventEmitter.on
, with the following
behavior differences to prevent data loss and unnecessary hangs:
Adding a 'data' event handler will trigger the flow of data
Adding a 'readable' event handler when there is data waiting to be read will cause 'readable' to be emitted immediately.
Adding an 'endish' event handler ('end', 'finish', etc.) which has already passed will cause the event to be emitted immediately and all handlers removed.
Adding an 'error' event handler after an error has been emitted will cause the event to be re-emitted immediately with the error previously raised.
Adds a one-time listener
function for the event named eventName
. The
next time eventName
is triggered, this listener is removed and then invoked.
server.once('connection', (stream) => {
console.log('Ah, we have our first user!');
});
Returns a reference to the EventEmitter
, so that calls can be chained.
By default, event listeners are invoked in the order they are added. The emitter.prependOnceListener()
method can be used as an alternative to add the
event listener to the beginning of the listeners array.
import { EventEmitter } from 'node:events';
const myEE = new EventEmitter();
myEE.once('foo', () => console.log('a'));
myEE.prependOnceListener('foo', () => console.log('b'));
myEE.emit('foo');
// Prints:
// b
// a
The name of the event.
The callback function
Pause the stream
Set TAP pragma configs to affect the behavior of the parser.
Only strict
is supported by the parser.
Adds the listener
function to the beginning of the listeners array for the
event named eventName
. No checks are made to see if the listener
has
already been added. Multiple calls passing the same combination of eventName
and listener
will result in the listener
being added, and called, multiple times.
server.prependListener('connection', (stream) => {
console.log('someone connected!');
});
Returns a reference to the EventEmitter
, so that calls can be chained.
The name of the event.
The callback function
Adds a one-timelistener
function for the event named eventName
to the beginning of the listeners array. The next time eventName
is triggered, this
listener is removed, and then invoked.
server.prependOnceListener('connection', (stream) => {
console.log('Ah, we have our first user!');
});
Returns a reference to the EventEmitter
, so that calls can be chained.
The name of the event.
The callback function
Return a void Promise that resolves once the stream ends.
Returns a copy of the array of listeners for the event named eventName
,
including any wrappers (such as those created by .once()
).
import { EventEmitter } from 'node:events';
const emitter = new EventEmitter();
emitter.once('log', () => console.log('log once'));
// Returns a new Array with a function `onceWrapper` which has a property
// `listener` which contains the original listener bound above
const listeners = emitter.rawListeners('log');
const logFnWrapper = listeners[0];
// Logs "log once" to the console and does not unbind the `once` event
logFnWrapper.listener();
// Logs "log once" to the console and removes the listener
logFnWrapper();
emitter.on('log', () => console.log('log persistently'));
// Will return a new Array with a single function bound by `.on()` above
const newListeners = emitter.rawListeners('log');
// Logs "log persistently" twice
newListeners[0]();
emitter.emit('log');
Low-level explicit read method.
In objectMode, the argument is ignored, and one item is returned if available.
n
is the number of bytes (or in the case of encoding streams,
characters) to consume. If n
is not provided, then the entire buffer
is returned, or null
is returned if no data is available.
If n
is greater that the amount of data in the internal buffer,
then null
is returned.
Optional
n: null | numberregister this tap instance as being in charge of the current process ignore epipe errors, set exit code, etc.
Happens automatically if piped to stdout.
Mostly identical to EventEmitter.removeAllListeners
If all 'data' event handlers are removed, and they were the last consumer (ie, there are no pipe destinations), then the flow of data will stop until there is another consumer or Minipass#resume is explicitly called.
Optional
ev: EventAlias for Minipass#off
Resume the stream if it is currently in a paused state
If called when there are no pipe destinations or data
event listeners,
this will place the stream in a "discarded" state, where all data will
be thrown away. The discarded state is removed if a pipe destination or
data handler is added, if pause() is called, or if any synchronous or
asynchronous iteration is started.
By default EventEmitter
s will print a warning if more than 10
listeners are
added for a particular event. This is a useful default that helps finding
memory leaks. The emitter.setMaxListeners()
method allows the limit to be
modified for this specific EventEmitter
instance. The value can be set to Infinity
(or 0
) to indicate an unlimited number of listeners.
Returns a reference to the EventEmitter
, so that calls can be chained.
Similar to the normal @tapjs/core!test-base.TestBase#timeout, but
with the added feature that it will kill the process with SIGALRM
if it
has been registered, and will decorate the diagnostics with some
information about currently running handles and requests, as these may be
the reason the process is not gracefully closing in time.
The root test runner will time out if the process receives a SIGALRM
signal, or if it receives a timeout message via IPC or worker thread
channel.
Fully unhook a piped destination stream.
If the destination stream was the only consumer of this stream (ie,
there are no other piped destinations or 'data'
event listeners)
then the flow of data will stop until there is another consumer or
Minipass#resume is explicitly called.
Just the normal Minipass.write method, but automatically pipes to stdout if not piped anywhere else.
Returns the error object if it throws and that does not fail the test (by virtue of being marked skip or todo). Otherwise returns the passing status, like other assertions.
Asserts that the emitter emits the specified event before the test ends. Returns a promise that resolves when the event is emitted. Note that waiting on the returned promise within a test can deadlock the test, if the event never emits, but the returned promise can be a handy way to pause a test until an event happens, if you are reasonably confident that it will fire.
Verify that the values are equal
Assert that an error object is not provided.
Like with @tapjs/asserts!index.Assertions#doesNotThrow, you can also usually just throw the error, and tap will handle that reasonably.
This is useful in cases where you just want to assert that a callback did not receive an error, without necessarily aborting the callback function entirely. Both the origin of the error and the location of the failed assertion will be printed in the test results.
It is also used internally in @tapjs/asserts!index.Assertions#resolves, @tapjs/asserts!index.Assertions#doesNotThrow, and @tapjs/asserts!index.Assertions#resolveMatch to show both the source of a raised error as well as the callsite where the assertion failed.
Verify that the object has all of the properties and values in the pattern, matching loosely.
Verify that the object has the wanted property, using Object#hasOwnProperty
Verify that the object has all of the properties listed in the
wanted
list, using Object#hasOwnProperties()
Verify that the object has all of the properties listed in the
wanted
list, using Object#hasOwnProperties(), and no others
Verify that the object has the wanted property, anywhere in its prototype chain.
Verify that the object has all of the properties in the wanted
list, anywhere in its prototype chain.
Verify that the value has all of the properties and values in the pattern, matching strictly.
Verify that the value matches the pattern provided
Verify that the value matches the pattern provided, with no extra properties.
Verify that the value matches the pattern provided, with no extra properties.
In --snapshot
mode, takes a snapshot of the object provided, and writes
to the snapshot file.
Otherwise, reads the snapshot file, and verifies that a snapshot of the object provided matches the stored snapshot.
Verify that the value matches the pattern provided, but fail if any fields only match via type coercion.
For example,
t.matchStrict({ a: 1 }, { a: Number }, 'this passes')
t.matchStrict({ a: 1 }, { a: '1' }, 'this fails')
Verify that the values are not equal
Verify that the object does NOT have all of the properties and values in the pattern, matching loosely.
Verify that the value does NOT contain all of the properties and values in the test pattern, comparing strictly.
Note that this will pass if the value has some of the listed properties, or if they do not match the same type.
Verify that the value does NOT match the pattern provided.
Verify that the value does not match the pattern provided, with no extra properties. Ie, it might either not match, or have extra props.
Verify that the value does not match the pattern provided, with no extra properties. Ie, it might either not match, or have extra props.
Verify that the value does not match the pattern provided, without type coercion.
Verify that the value is not truthy
Verify that the value is not loosely equivalent to the supplied pattern
resolves to the error object rejected if it rejects as expected, 'false' if it does not, or 'true' if it fails to reject but is marked as skip/todo.
Test the resolved promise result with t.match()
Resolves to true if it passes, false if the promise rejects or the match fails, or the rejection error value if the promise rejects but the assertion passes by being marked todo/skip.
Resolve a promise, and verify that the resulting value matches the snapshot.
Resolves to 'true' if the promise resolves successfully, 'false' if it rejects and fails, or the rejection error if it rejects but the failure is accepted by by being marked todo or skip
Verify that the value is loosely equivalent to the supplied pattern
Verify that the value is not strictly equivalent to the supplied pattern object
Verify that the value is strictly equivalent to the supplied pattern
Verify that the function throws an error.
Thrown error is tested against the wanted
param if provided, using
t.match()
.
Returns false on failure, or the error object thrown on success
Verify that the value is of the type specified Type can be either a string, or a constructor.
If a string, then it can match either the typeof
result
or 'null' for null
values, or the name
property of the
object's constructor.
Subtests that are currently in process.
Internal
bufferedTrue if this test should be buffered and only processed on completion
Optional
Internal
cbFunction that will get this test as an argument when it is processed
Optional
deferredA Deferred
promise wrapper that is resolved when this test completes.
Optional
doneA promise that resolves when the test is done.
TapWrap AsyncResource that limits the async-hook-domain
the async-hook-domain that catches throws and Promise rejections
Internal
outputthe TAP stream data for buffered tests
Optional
parentParent test of this TAP stream
The tap parser attached to this TAP stream
The pool of parallel tests currently in process
Queue of items awaiting processing. Can be any @tapjs/core!test-base.QueueEntry item.
high resolution bigint time when this test started
Array of all subtests that have been added/scheduled, and have not yet completed.
Optional
timerThe timer that fires when the test times out
The current assertion being processed. Set at the start of all assertions, and used for calculating stack traces.
Internal
EventEmitter emit method, but closes the
@tapjs/core!base.Base#hook and
@tapjs/core!base.Base#hookDomain when emitting 'end'
.
Internal
Called when a test times out or bails out, or the process ends, marking all currently active or queued subtests as incomplete.
No need to ever call this directly, exposed so that it can be extended by @tapjs/core!spawn.Spawn and @tapjs/core!worker.Worker, which have special behaviors that are required when a process hangs indefinitely.
Optional
sub: booleanInternal
The main function that starts a test running. Generally no need to call this directly.
Internal
Method called when the parser encounters a bail out
To listen to bailout events, listen to the @tapjs/core!base.TapBaseEvents#bailout event:
t.on('bailout', message => {
// test bailed out!
})
Optional
reason: stringInternal
extension point for plugins that want to be notified when the test is about to end, whether explicitly or implicitly.
If the function returns a Promise, it will be awaited before ending the TAP stream.
Internal
Method called when the parser completes and emits its final results
Extended by @tapjs/core!worker.Worker and @tapjs/core!tap.TAP classes
Internal
extension point for TestBase to know when a child tests is done being processed and it's safe to move on to the next one.
Internal
extension point for plugins that want to be notified when the test is completely done, and terminating its parser.
Internal
Run the main
test function. Called by
@tapjs/core!test-base.TestBase when starting a subtest.
Initializes the TapWrap hook
Internal
Return true if the child test represented by the options object
should be skipped. Extended by the @tapjs/filter
plugin.
Internal
Await the end of a Promise before proceeding. The supplied callback is called with the Waiter object.
This is internal, used in some plugins when a promise must be awaited
before proceeding. In normal test usage, it's usually best to simply use
an async test function and await
promises as normal.
Optional
cb: (w: Waiter) => anyOptional
expectReject: booleanAdd a plugin at run-time.
Creates a subclass of @tapjs/test!index.Test which has the specified plugin, and which applies the plugin to all child tests it creates.
Typically, it's best to load plugins using configuration, set via the
tap plugin <add|rm>
command.
However, in some cases, for example while developing plugins or if a certain plugin is only needed in a small number of tests, it can be useful to apply it after the fact.
This is best used sparingly, as it may result in poor typescript compilation performance, which can manifest in slower test start-up times and lag loading autocomplete in editors. If you find yourself calling applyPlugin often, consider whether it'd be better to just add the plugin to the entire test suite, so that it can be built up front.
The name of the folder that this test will use with @tapjs/fixture!index.TestFixtures#testdir.
By default, it uses a folder name based on the name of the test file
and subtest, within .tap/fixtures
in the root of the project.
Intercept calls to a method to track the arguments, call site, and return/throw status, and replace the implementation.
By default, the method is set to a no-op. To retain the method behavior, pass the current value of the method as the third argument. For example:
const results = t.capture(obj, 'foo', obj.foo)
Automatically restores at t.teardown()
if the @tapjs/after
plugin is not disabled. Otherwise, it is important to call the
restore()
method on the returned function when you are done capturing.
Just wrap the function and return it. Does not have any logic to restore, since it's not actually modifying anything. The results hang off the function as the 'calls' property.
The added fn.args()
method will return an array of the arguments
passed to each call since the last time it was inspected.
Convenience method to create a mock from an existing object by overriding some (possibly deeply nested) methods or properties.
Example:
import * as fs from 'node:fs'
const mockedThing = t.mockRequire('./module.js', t.createMock(
{ fs },
{ fs: { statSync: myMockedStatSync }}
)
This can also appear anywhere in the object hierarchy, which may be more convenient in some cases:
import * as blah from '@long-name/blah-api'
const mockedThing = t.mockRequire('./module.js', {
fs: t.createMock(fs, { statSync: myMockedStatSync }),
child_process: t.createMock(child_process, { spawn: mockSpawn }),
'@long-name/blah-api': t.createMock(blah, {
some: {
nested: {
prop: true
}
}
})
})
To remove a property, set it as undefined in the override.
Create a fixture object for use in a @tapjs/fixture!index.TestFixtures#testdir method.
Intercept and track object property sets and gets.
If a PropertyDescriptor is set, then it will be used as the replacement value. Otherwise, the original descriptor will be used.
If the strictMode
param is set, then attempts to write to read-only
properties will throw an error.
Deprecated alias for @tapjs/mock!index.TapMock#mockRequire
Prints a warning to stderr the first time it used, otherwise identical.
Optional
mocks: { [k: string]: any }Load the supplied module asynchronously using import(), replacing any of the referenced modules with the mocks provided.
Works with either ESM or CommonJS modules, but as with import()
of
CommonJS modules, the module.exports
value will be set as the
default
property on the resolved object, making
@tapjs/mock!index.TapMock#mockRequire somewhat more intuitive in
those cases.
For type info, cast using as typeof import(...)
or use the type
parameter, as TypeScript lacks a way to infer imports dynamically.
For example:
const myThing = await t.mockImport<
typeof import('../my-thing.js')
>('../my-thing.js', {
some: { tricky: 'mocks' },
})
Note: The terms "mock" and "import" are unfortunately very overloaded in the testing space. This is not "mock all imports of this module". It's "load this module, but with its imports mocked". The code of the target module is run normally, but its dependencies are injected with the supplied values, which is useful for triggering hard-to-reach error cases and other situations.
It is also useful for just loading a fresh copy of a module in your tests, if for example your program behaves differently based on environment variables or other system settings. For example:
t.test('windows behavior', async t => {
t.intercept(process, 'platform', { value: 'win32' })
const myThing = t.mockImport('../my-thing.js')
t.equal(myThing.separator, '\\')
})
t.test('posix behavior', async t => {
t.intercept(process, 'platform', { value: 'linux' })
const myThing = t.mockImport('../my-thing.js')
t.equal(myThing.separator, '/')
})
Optional
mocks: Record<string, any>Load the supplied module synchronously using require()
,
replacing any of the referenced modules with the mocks provided.
Only works with CommonJS modules.
For type info, cast using as typeof import(...)
or use the type
parameter, as TypeScript lacks a way to infer imports dynamically.
For example:
const myThing = t.mockRequire<
typeof import('../my-thing.js')
>('../my-thing.js', {
some: { tricky: 'mocks' },
})
Optional
mocks: Record<string, any>Create a test directory, optionally filling it up with contents
The testdir will be automatically deleted at the end of the test.
To not delete the directory after the test, use the
saveFixture: true
option when creating the test, or specify
--save-fixture
on the command line or in the tap configuration.
Optional
content: FixtureDirContentUnwind the mocks and free up the memory at the end of the test.
Called automatically if the @tapjs/after
plugin is not disabled.
Run a child test that will run when the --only
config is set,
or { runOnly: true }
is set in the parent test options.
Run a child test that will run when the --only
config is set,
or { runOnly: true }
is set in the parent test options.
Run a child test that will run when the --only
config is set,
or { runOnly: true }
is set in the parent test options.
Run a child test that will run when the --only
config is set,
or { runOnly: true }
is set in the parent test options.
Create a subtest which is marked as skip
Create a subtest which is marked as skip
Create a subtest which is marked as skip
Create a subtest which is marked as skip
Spawn a child process and parse its standard output as a subtest
Spawn a child process and parse its standard output as a subtest
Optional
name: stringSpawn a child process and parse its standard output as a subtest
Optional
name: stringSpawn a child process and parse its standard output as a subtest
Optional
name: stringParse standard input as a child test
Parse stdin as the only tap stream (ie, not as a child test) If used, then no other subtests or assertions are allowed.
Optional
extra: T & {Internal
Mount a subtest, using this Test object as a harness.
Exposed so that it can be used by some builtin plugins, but perhaps
the least convenient way imaginable to create subtests. Just use
t.test()
to do that, it's much easier.
Optional
extra: TestBaseOpts | OOptional
caller: (...a: any[]) => unknownCreate a child Test object and parse its output as a subtest
Create a child Test object and parse its output as a subtest
Create a child Test object and parse its output as a subtest
Create a child Test object and parse its output as a subtest
Create a subtest which is marked as todo
Create a subtest which is marked as todo
Create a subtest which is marked as todo
Create a subtest which is marked as todo
Start a Node Worker thread and parse its standard output as a child test
Start a Node Worker thread and parse its standard output as a child test
Optional
name: stringStart a Node Worker thread and parse its standard output as a child test
Optional
name: stringThe number of subtests to run in parallel, if allowed
Runs the supplied function after the test is completely finished, and before the next test starts.
Run the supplied function after every child test, and any of those child tests' children, and so on.
The test that has just completed is passed in as an argument to the function. Note that at this point, the test is fully ended, so attempting to call assertion methods on it will raise an error.
immediately exit this and all parent tests with a TAP Bail out! message.
Optional
message: stringJust run the supplied function right away, but do not run any child tests until it has completed.
This is handy when some setup may require asynchronous actions, and tests should wait until after it completes.
Run the supplied function before any child tests, and all of their children, and so on.
The test about to run is an argument to the function. While its test
method has not yet run, it is safe to call test methods on it, but note
that this may potentially be confusing if for example you call t.plan()
and this conflicts with the t.plan()
called in the test method.
Explicitly mark the test as completed, outputting the TAP plan line if needed.
This is not required to be called if the test function returns a promise, or if a plan is explicitly declared and eventually fulfilled.
Specify the number of Test Points expected by this test. Outputs a TAP plan line.
Optional
comment: stringSet the amount of time in milliseconds before this test is considered
a timeout. The time is counted from right now, so for example, repeatedly
calling t.setTimeout(100)
can keep it going indefinitely, as long as
you call it more often than every 100ms.
Calling setTimeout(0)
will remove the timer and allow the test to run
indefinitely.
True if this test emitted a bailout
The count of all assertions made directly on this test.
The count of all assertions that this stream emitted
Unrecoverable TAP protocol errors in the stream
High resolution time in ns that this test took to complete.
True if in the main thread. False when running in a worker thread spawned by t.worker
Lists of todo, skip, and failure test points. If passes: true
is
set in the options, then passing test points will also be tracked.
the name of this test
Optional
resultsSet on completion. The results of the test run.
Attached when the Test class is instantiated from a TestBase, as a reference to the final plugged-in Test instance. If TestBase is used directly (outside the context of a plugin) or during plugin setup time, this will be undefined, so watch out.
Amount of time in milliseconds that this test took to complete.
Count of all asserts in this and all child tests, excluding child test summary points
true if the test is currently waiting for something to finish
True if the test has printed some output of any kind
true if the test has printed at least one TestPoint
Returns true if this test has begun
returns true if the test has not as yet encountered any failures
This is a singleton subclass of the @tapjs/test!index.Test base class.
Instantiate it by calling the exported @tapjs/core!tap.tap method.
It has all of the same plugins, fields, properties etc of a "normal" Test object, but with some additional characteristics to make it suitable for use as the root test runner.
The @tapjs/core!tap.TAP#register method will hook onto the process object, to set the exit code to 1 if there are test failures, and ignore any
EPIPE
errors that happen on stdout. (This is quite common in cases where a test aborts, and then attempts to write more data.)A brief summary is printed at the end of the test run.
If piped to stdout, then
this.register()
will be called automatically.If not piped anywhere else, the first time it writes any data, it will begin piping to stdout.
Options are set based on relevant environment variables, rather than taking an options object, since in normal cases, it will be instantiated automatically before any user code is run.
The test will automatically implicitly end when the process exits. If there are any unfinished tests at this time, they will be emitted as failures.
If a
teardown
function is added, then the test will automatically implicitly end if it is idle for 3 consecutivesetTimeout
deferrals. This is a bit of a kludge, but it allows tests to run servers or other things that would prevent a graceful process exit, and close them down in a teardown function.Lastly, since test files are often spawned by the runner using
t.spawn()
, this class listens for the timeout signal, and attempts to print diagnostic information about currently active handles and requests, as these are usually the cause of a test hanging indefinitely.