Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

188
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda