This directory contains modules used to test the Node.js implementation.
The common
module is used by tests for consistency across repeated
tasks.
Takes whitelist
and concats that with predefined knownGlobals
.
A stream to push an array into a REPL
time
<Number>
Blocks for time
amount of time.
- return [<Boolean>]
Checks whether the current running process can create symlinks. On Windows, this
returns false
if the process running doesn't have privileges to create
symlinks
(SeCreateSymbolicLinkPrivilege).
On non-Windows platforms, this always returns true
.
Installs a process.on('unhandledRejection')
handler that crashes the process
after a tick. This is useful for tests that use Promises and need to make sure
no unexpected rejections occur, because currently they result in silent
failures.
- return <Object>
Platform normalizes the dd
command
Indicates if there is more than 1gb of total memory.
-
settings
<Object> with the following optional properties:code
<String> expected error must have this value for itscode
propertytype
<Function> expected error must be an instance oftype
message
<String> or <RegExp> if a string is provided formessage
, expected error must have it for itsmessage
property; if a regular expression is provided formessage
, the regular expression must match themessage
property of the expected error
-
return function suitable for use as a validation function passed as the second argument to
assert.throws()
The expected error should be subclassed by the internal/errors
module.
Tests whether name
and expected
are part of a raised warning.
Checks if pathname
exists
Path to the 'fixtures' directory.
buf
<Buffer>- return <ArrayBufferView[]>
Returns an instance of all possible ArrayBufferView
s of the provided Buffer.
func
[<Function>]- return [<String>]
Returns the file name and line number for the provided Function.
Set to false
if the test should not check for global leaks.
Indicates whether OpenSSL is available.
Indicates hasCrypto
and crypto
with fips.
Indicates whether IPv6
is supported on this platform.
Indicates if there are multiple localhosts available.
Checks whether free BSD Jail is true or false.
Platform check for Advanced Interactive eXecutive (AIX).
Attempts to 'kill' pid
Platform check for Free BSD.
Platform check for Linux.
Platform check for Linux on PowerPC.
Platform check for macOS.
Platform check for SunOS.
Platform check for Windows.
Platform check for Windows 32-bit on Windows 64-bit.
Indicates whether any globals are not on the knownGlobals
list.
IP of localhost
.
Array of IPV6 representations for localhost
.
fn
<Function> default = () => {}exact
<Number> default = 1- return <Function>
Returns a function that calls fn
. If the returned function has not been called
exactly expected
number of times when the test is complete, then the test will
fail.
If fn
is not provided, an empty function will be used.
fn
<Function> default = () => {}minimum
<Number> default = 1- return <Function>
Returns a function that calls fn
. If the returned function has not been called
at least minimum
number of times when the test is complete, then the test will
fail.
If fn
is not provided, an empty function will be used.
msg
<String> default = 'function should not have been called'- return <Function>
Returns a function that triggers an AssertionError
if it is invoked. msg
is used as the error message for the AssertionError
.
Returns true
if the exit code exitCode
and/or signal name signal
represent the exit code and/or signal name of a node process that aborted, false
otherwise.
Indicates whether 'opensslCli' is supported.
Platform normalizes timeout.
Path to the test socket.
- <Number> default =
12346
A port number for tests to use if one is needed.
msg
<String>
Logs '1..0 # Skipped: ' + msg
- return <String>
Deletes the 'tmp' dir and recreates it
Path to the 'root' directory. either /
or c:\\
(windows)
msg
<String>
Logs '1..0 # Skipped: ' + msg
and exits with exit code 0
.
Platform normalizes the pwd
command.
Synchronous version of spawnPwd
.
The realpath of the 'tmp' directory.
- return <String>
Name of the temp directory used by tests.
The Countdown
module provides a simple countdown mechanism for tests that
require a particular action to be taken after a given number of completed
tasks (for instance, shutting down an HTTP server after a specific number of
requests).
const Countdown = require('../common/countdown');
function doSomething() {
console.log('.');
}
const countdown = new Countdown(2, doSomething);
countdown.dec();
countdown.dec();
limit
{number}callback
{function}
Creates a new Countdown
instance.
Decrements the Countdown
counter.
Specifies the remaining number of times Countdown.prototype.dec()
must be
called before the callback is invoked.
The common/duplexpair
module exports a single function makeDuplexPair
,
which returns an object { clientSide, serverSide }
where each side is a
Duplex
stream connected to the other side.
There is no difference between client or server side beyond their names.
The common/fixtures
module provides convenience methods for working with
files in the test/fixtures
directory.
- [<String>]
The absolute path to the test/fixtures/
directory.
...args
[<String>]
Returns the result of path.join(fixtures.fixturesDir, ...args)
.
args
[<String>] | [<Array>]
Returns the result of
fs.readFileSync(path.join(fixtures.fixturesDir, ...args), 'enc')
.
arg
[<String>]
Returns the result of
fs.readFileSync(path.join(fixtures.fixturesDir, 'keys', arg), 'enc')
.
The wpt.js module is a port of parts of W3C testharness.js for testing the Node.js WHATWG URL API implementation with tests from W3C Web Platform Tests.