
Research
Security News
Malicious PyPI Package Exploits Deezer API for Coordinated Music Piracy
Socket researchers uncovered a malicious PyPI package exploiting Deezer’s API to enable coordinated music piracy through API abuse and C2 server control.
FAst and smaRT TESTing
.. for those who want to enjoy simple and emoji-augmented tests without having to learn the whole ecosystem of a rich test library.
FarTest is an obvious, colorful and enjoyable test library for small applications. It does not do cool stuff like code coverage, but you'll learn to use in no time.
npm install --save-dev fartest
FarTest simplest API export one main function :
function start(testName?: string, testFunction: ({
test?: (condition: boolean, description?: string) => void,
same?: (a: any, b: any, description?: string) => void,
stage?: (name: string) => void,
}) => void): void
The testName
parameter is optional but strongly recommanded if you run multiple tests.
The testFunction
parameter is a function that can take four function arguments :
test(condition: boolean, description?: string)
- a general assertion checking. If condition
is true
then the assertion has succeeded, otherwise it failed.same(a: any, b: any, name?: string)
- check if two values are the same. When a
and b
are objects, execute a deep comparison. Values can be of any type : numbers, strings, arrays, maps, sets, ...different(a: any, b: any, name?: string)
- opposite of same
; check if two values are strictly unequal.stage(name: string)
- use it to group unit tests together.And that's the whole API.
Let's create a new test file (can be in Typescript or in pure JS) :
import start from 'fartest'
// the name of the function (MyAwesomeTest) is the name of the test
// and is optional
start('My test', async function({stage, test, same, different}) {
stage('Basic tests')
test(1 == "1", "String and integer loose comparison")
// will fail
test(1 === "1", "String and integer strict comparison")
// will fail as well
same(1, "1", "String and integer strict comparison (using same)")
stage('Comparing objects')
// deep comparison is done
same({x: 1, y: 2}, {x: 1, y: 2}, "Deep object comparison")
// the object type is also checked
different(['foo'], {0: 'foo'}, "Array is not an object")
})
Then run it using node
or a tool like esrun if your file is written in Typescript or in modern JS.
Any invalid code will be caught and printed as a critical error.
start('Bold test', async function({stage, test}) {
stage('It gotta works!!')
undefined.x == 12
})
Because your main test functions is declared as async
you can just use await
anywhere you need it.
You can run multiple tests at once, in which case they all will be executed simultaneously - the fastest tests will display their results first.
// test 1
start('Slow test', async function({stage, test}) {
stage('Basic tests')
// let's wait 1 second
await new Promise(resolve => setTimeout(resolve, 1000))
test(1 == "1", "String and integer loose comparison")
})
// test 2
start('Instant test', async function({stage, test}) {
stage('Basic tests')
test(1 == "1", "String and integer loose comparison")
})
Congratulations, you've learned a new test library in less that 5 minutes!
What are you waiting for?
Enjoy testing 😌
FAQs
A minimal, colorful and enjoyable test library for small applications
The npm package fartest receives a total of 0 weekly downloads. As such, fartest popularity was classified as not popular.
We found that fartest 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 researchers uncovered a malicious PyPI package exploiting Deezer’s API to enable coordinated music piracy through API abuse and C2 server control.
Research
The Socket Research Team discovered a malicious npm package, '@ton-wallet/create', stealing cryptocurrency wallet keys from developers and users in the TON ecosystem.
Security News
Newly introduced telemetry in devenv 1.4 sparked a backlash over privacy concerns, leading to the removal of its AI-powered feature after strong community pushback.