Security News
RubyGems.org Adds New Maintainer Role
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
@tapjs/core
Advanced tools
@tapjs/core is a core library for the Test Anything Protocol (TAP) framework, which is used for writing and running tests in JavaScript. It provides a set of tools and utilities to create, manage, and execute tests, making it easier to ensure code quality and reliability.
Basic Test Creation
This feature allows you to create basic tests using the TAP framework. The code sample demonstrates a simple test that checks if 1 + 1 equals 2.
const t = require('@tapjs/core');
t.test('basic test', t => {
t.equal(1 + 1, 2, '1 + 1 should equal 2');
t.end();
});
Asynchronous Testing
This feature supports asynchronous testing, allowing you to test functions that return promises or use async/await. The code sample shows how to test an asynchronous function.
const t = require('@tapjs/core');
t.test('async test', async t => {
const result = await someAsyncFunction();
t.equal(result, expectedValue, 'Async function should return expected value');
t.end();
});
Nested Tests
This feature allows you to create nested tests, which can help organize and structure your test cases better. The code sample demonstrates a parent test containing a child test.
const t = require('@tapjs/core');
t.test('parent test', t => {
t.test('child test', t => {
t.equal(2 * 2, 4, '2 * 2 should equal 4');
t.end();
});
t.end();
});
Mocha is a feature-rich JavaScript test framework running on Node.js and in the browser, making asynchronous testing simple and fun. It provides a variety of interfaces for writing tests, including BDD, TDD, and exports-style. Compared to @tapjs/core, Mocha offers more flexibility in terms of test interfaces and has a larger ecosystem of plugins and integrations.
Jest is a delightful JavaScript testing framework with a focus on simplicity. It works out of the box for most JavaScript projects and provides a rich API for writing tests. Jest includes built-in mocking, assertion, and coverage tools. Compared to @tapjs/core, Jest is more opinionated and comes with more built-in features, making it easier to get started with testing.
AVA is a test runner for Node.js with a concise API, detailed error output, and process isolation. It runs tests concurrently, which can lead to faster test execution. Compared to @tapjs/core, AVA emphasizes simplicity and performance, making it a good choice for projects with a large number of tests.
@tapjs/core
This is the pluggable core of node-tap.
The TestBase
class has the basic flow-control aspects of a tap
Test
object, but only the t.pass()
and t.fail()
assertions.
All other assertions and features are added via plugins.
Full documentation available in the typedocs.
Base
This is the base class of all sorts of test objects. It inherits from minipass.
TestBase
This provides the core flow control and TAP
generation
facilities. The Test
class inherits from this.
Spawn
A child test class representing a child process that emits TAP
on its standard output.
Worker
A child test class representing a worker thread that emits TAP
on its standard output.
Stdin
A child test class representing TAP
parsed from standard input.
TapFile
A child test class representing a file containing TAP
data.
Counts
An object used to count pass, fail, todo, skip, total, and completed tests.
Lists
An object containing lists of test results.
TestPoint
An object representing a single ok
/not ok
test point.
Minimal
A very minimal Test class with no plugins, which can be used in tap internal tests.
It is essentially just the TestBase class, but automatically starting in the constructor, and with a .test() method so that it can be used somewhat like a "normal" Test instance.
The reason that this method does not live on TestBase itself is that it would make it more awkward to define on the Test class, with all its plugins and extensions.
Only useful if you want a Test without any plugins, for some reason.
proc
, argv
, cwd
, env
Captured values of process
, process.argv
, process.cwd()
,
and process.env
at the start of the process, in case they
change later on or are not available for some other reason.
tapDir
The string path to the location of @tapjs/core
.
mainScript(defaultName = 'TAP'): string
The path to the main module that node ran.
TapPlugin<PluginValue, OptionsValue>
The type of a plugin function which returns PluginValue
and
optionally which takes OptionsValue
as options.
Extra
The extra info passed to assertions.
Extended by BaseOpts, TestBaseOpts, and ultimately TestOpts, since any subtest is also an assertion, and can take all the same assertion options.
FAQs
pluggable core of node-tap
The npm package @tapjs/core receives a total of 117,511 weekly downloads. As such, @tapjs/core popularity was classified as popular.
We found that @tapjs/core demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.
Security News
Research
Socket's threat research team has detected five malicious npm packages targeting Roblox developers, deploying malware to steal credentials and personal data.