Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

180
Views
Exported JS Functions Require Imported?

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.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!