How to test?
There are a couple ways to test your module:
You can use node to test your scripts, to install node head over to their official install page.
To test your script, run node in your command line program:
> node {PATH TO FILE}
For example:
> node /Users/Test/Downloads/example.js
To log any constants or errors, you can for example use:
console.log('Raw output:', response);
> node /Users/Test/Downloads/example.js
Raw output: example response
const value = 10;
if (value > 20) {
console.log("Value is greater than 20.");
} else {
console.error("Error: Value is not greater than 20.");
}
> node /Users/Test/Downloads/example.js
Error: Value is not greater than 20.
To add an example input (testing regex or fetching for example), use:
function search(html){
// Some code
}
search(`html or something idc`);
// WARNING: Use backticks for multi line inputs!
async function search(keyword){
const response = await fetch(`https://google.com/${keyword}`)
}
search(`I hate my life`);
Last updated