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:

Example logging of a constant
console.log('Raw output:', response);
Ouput:
> node /Users/Test/Downloads/example.js
Raw output: example response
Example logging of an error
const value = 10;

if (value > 20) {
    console.log("Value is greater than 20.");
} else {
    console.error("Error: Value is not greater than 20.");
}
Output
> 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:

Example input
function search(html){
// Some code
}

search(`html or something idc`); 
// WARNING: Use backticks for multi line inputs!
Example of an async code
async function search(keyword){
const response = await fetch(`https://google.com/${keyword}`)
}

search(`I hate my life`); 

WARNING:

When testing on PC, you will need to use .json() and .text() methods instead of JSON.parse() and directly applying the value! Only replace those methods when you want to actually test on phone!

Last updated