Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

182
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda