Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
yet another unit test assertion and test runner - small, simple, no dependencies
• Why • What • How • License •
This originated as an attempt to have assertions that are less verbose because assert.notDeepStrictEqual
is ugly.
const ct = require('cotest')
ct('1. primitives - comparison', function(t) {
t('==', 2, 2)
t('!==', 3, 4, 'should be unequal')
t('<', 1, 2)
t('!', null, 'should be falsy')
t.skip('>=', 55, 0, 'TODO')
})
ct('2. object - comparison', function(t) {
t('!{===}', [], 'str', 'should be notDeepStrictEqual')
t('{==}', [2], 2, 'should be deepEqual')
})
ct('3. async', function(t, end) {
setTimeout(end, 0)
t('!==', 3, 4)
t('!{==}', 3, 4)
})
ct.skip('4. skip', function(t) {
// all tests defined here will be skipped
})
==
, !==
, ===
, !===
, <
, <=
, >
, >=
)!
, !!
){==}
: deepEqual!{==}
: notDeepEqual{===}
: strictDeepEqual!{===}
: notStrictDeepEqualthrows
for assert.throws, !throws
for doesNotThrowst.skip()
t.only()
In node, from the project root folder type npm i -D cotest
to install.
cotest file1 directory1 directory2 file2 ...
cotest(titleString[, testFunction [, message]])
cotest.skip(titleString[, testFunction [, message]])
cotest.only(titleString, testFunction [, message])
if no test function is provided, the test will be marked as skipped
assert(operator, valueToTest, referenceValue[, additional message])
assert.skip(operator, valueToTest, referenceValue[, additional message])
Test are normally automatically completed after the test function is executed.
Example: cotest('syncTest', function(assert) { /*assertions*/ })
To change this behaviour, add a callback to the test function. This calback must be called to end the test.
Example: cotest('asyncTest', function(assert, done) { /*assertions*/; done()})
An error message can be passed to the done
function.
Example: cotest('asyncTest', function(assert, done) { if (true) done() else done('failed') })
If a callback is declared but not called, the test fails after 1000ms.
To change the default duration: cotest.timeout = 1500
var co = require('cotest')
co('async test, call the function argument to end', function(t, done) {
t('<', Math.abs(error), 0.001)
setTimeout(done, 0)
})
co('sync test - no function argument needed', function(t) {
t('==', 1+1, 2)
t('!', null)
t('{==}', [1, 2], [1, 2])
}, 'Any Truthy Value as 3rd argument will only run flagges tests')
co('sync test - no function argument needed', function(t) {
t('==', 1+1, 2)
t('{==}', [1, 2], [1, 2])
})
package.json
"scripts": {
"test": "cotest mytestdirectory",
"test_file": "cotest mytestdirectory/mytestfile"
}
In any of the test files are flagged as priority, only these tests will run.
FAQs
unit test assertion and test runner using comparison operators
The npm package cotest receives a total of 1 weekly downloads. As such, cotest popularity was classified as not popular.
We found that cotest 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.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.