Security News
Node.js EOL Versions CVE Dubbed the "Worst CVE of the Year" by Security Experts
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
@jpcx/testts
Advanced tools
an asynchronous, nesting, composable testing framework for TypeScript [zero-dependency]
testts is an asynchronous, nesting, composable testing framework for TypeScript.
testts facilitates composition within the type system:
There are two test registrars, test(descr, body)
and test.throws(...?)?(descr, body)
From anywhere in the test files:
test.deleteStacks(setting=true, passToChildren=true): void
deleteStacks
applies to the test parent and all of its children (unless passToChildren is false).Using the configuration file $PWD/.testts.json
:
{
prioritized: string[]
}
prioritized
In order to achieve nesting, test parents must provide a test
parameter.
test
parameter is not written, test
statements will create siblings instead.Although promises returned by test
statements can reject, a process
listener is used to catch unhandled promises.
See the usage examples for more info
Node.js >=10.0.0
npm i --save-dev @jpcx/testts
npx @jpcx/testts dist/ # recursively runs tests from any nested *.test.js files
# any number of files/folers may be used as arguments
# manually specified files do not need to conform to the *.test.js requirement
# npx @jpcx/testts dist/my.compiled.test.js dist/my.other.compiled_test.js dist/other/
# there is only one setting available: `npx @jpcx/testts -m(--match) [ECMAScript regex]`
# the default match regex is "\\.test\\.js"
import { test } from "@jpcx/testts";
import * as assert from "assert";
import { getSampleDB } from "../";
test("simple test", () => {
assert(true);
// assert(false); // fails test
});
// all tests return promises (their execution is deferred). In the absence of an
// await statement, tests below will be registered even if the above test fails
test("asynchronous test", async () => {
await new Promise((resolve) => setTimeout(resolve, 100));
assert(true);
});
// use a parameter to allow `test` to refer to a parent context
test("nested tests", (test) => {
test("failure fails parent", () => {
assert(true);
});
});
test("dependent testing", async (test) => {
// tests return promises!!
const waitforme = await test("nested tested value", () => "yay");
// TS `typeof waitforme`: 'string'
test("dependent test", () => assert(waitforme === "yay"));
});
test.throws("unspecified throw expected", () => {
throw new Error();
});
test.throws("bad")("error message specified", () => {
throw new Error("bad");
});
test.throws(TypeError)("error constructor specified", () => {
throw new TypeError();
});
test.throws(TypeError, "bad")(
"error constructor and messsage specified",
() => {
throw new TypeError("bad");
}
);
test.throws((e: number) => e === 42)("predicate-based specification", () => {
throw 42;
});
Contribution is welcome! Please make a pull request.
Copyright (C) 2021 Justin Collier <m@jpcx.dev>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the internalied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
FAQs
an asynchronous, nesting, composable testing framework for TypeScript [zero-dependency]
The npm package @jpcx/testts receives a total of 1 weekly downloads. As such, @jpcx/testts popularity was classified as not popular.
We found that @jpcx/testts demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.