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

162
Views
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
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!