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

164
Vistas
Imported variable undefined access imported constant from callback function

Using jest-puppeteer to get the below 'page' object. That works fine.

My imported constant is coming back as undefined when in the evaluate function. I'm unsure why, given it works right outside the function in the parent scope just fine...

const CONSTANTS = require('../../../constants/Config')
const DICTIONARY = require('../../../constants/Dictionary')

describe('Check that reevaluate review section', () => {
    // Blah blah //
    var apiCall = CONSTANTS.NODE_ENDPOINT + "/api" + '/1234'  // outputs correctly

    test("reevaluate options include 'Sunset'", async () => {
    // Blah blah //
        console.log('DICTIONARY.SUNSET :>> ', DICTIONARY.SUNSET);  // outputs correctly
        const element_is_visible = await page.evaluate(() => {
            console.log('DICTIONARY.SUNSET :>> ', DICTIONARY.SUNSET);  // says "DICTIONARY is undefined"
    // Blah blah //
        });
        expect(element_is_visible).toBe(true)
    })

});

Dictionary.js

export const PENDING = "Pending"
export const PENDING_BY_QUEUE = "Pending"
export const SUNSET = "Sunset"
export const DUPLICATE_STATUS_OPTION = "Duplicate"
export const WITHDRAW_STATUS_OPTION = "Withdraw"
export const RETIRED_STATUS_OPTION = "Retired"

I suspect this problem might have something to do with the mixing of ES6 imports and nodejs imports... but I'm not sure why.

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