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

186
Vistas
puppeteer page.evaluate in module.exports

I just try to clean up the code, so I decided to create a new function and import it in main.js. I create new a.js and move everything from "it ( () => {})" to this file and here starts my problem. Page.evaluate just don't work, I try to console.log, alert something but didn't work. So anyone could help me clean that mess?

PS When we put code from a.js to main.js everything is fine.

main.js:

    const puppeteer = require('puppeteer');
    const pti = require('puppeteer-to-istanbul');
    const a= require('./a');
    describe("test", async () => { (...)
    it ('a.js', async ()=>{
            await a(page);

a.js


    const a = async (page) => {
        const 1= '#1'
    
        await page.waitForSelector(1, {visible: true}) 
        await page.click(1)
        await page.evaluate(async () => {
            let value = "Z"
            let clientPicker = document.querySelector('button[data-id="ctl00_CPH_Content__V_BPS_BankiProdukt__Q__Miejscowosc"]');
            clientPicker.click();
            let listOption = clientPicker.parentNode.querySelectorAll('li a > span')
            Array.from(listOption).find(item => item.innerText == value).click()
          }); (...) 
    }
    module.exports = a;

SOLVED: I had to add /* istanbul ignore next */

await page.evaluate(/* istanbul ignore next */ () => {
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