I'm writing a bit of JS for a group project and I had to write unit tests, so I modified all of my functions to be exported. That is, function foo() {} is now export function foo() {}.
I can import these functions and they work for my unit tests, but now they do nothing for the pages they were intended for, as if I have to import them in the same script before using them. Here is an example function that used to work but does not:
/*
Name: showLogin
Description: shows login box and hides sign up,
exports for unit tests.
Parameters:
showLogs - determines whether to print logs to console
*/
//
export function showLogin( showLogs = false )
{
// check valid refs
if ( checkRefs() )
{
// show login and hide signup
login.classList.remove("hidden");
signup.classList.add("hidden");
// operation success
return true;
}
// one or more refs are invalid
return false;
}
I would greatly appreciate any guidance on this. Thanks!
I tried modifying my JS functions to be exported so that I could test them but they no longer work on the pages they were intended for. They work fine where imported.