Creating a wrapper for the assertEquals is helpful and straightforward. The trick that I didn't understand was that Javascript doesn't truly support an equals
method or even a toString
method that I was used to with Java.
To print the details of a variable the following is a pretty decent way to go about it:
if (typeof x === "object" && x !== null) {
print (JSON.stringify(x));
}
else {
print (String(x));
}
Console.log could be used instead of print if GJS is not being used. JSON stringify turns the object into its JSON representation (as a String). It isn't accurate for the sake of type checking, but if that is not your concern, this works pretty well.