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

155
Visualizações
Jest Test Error: browserType.launch: setImmediate is not defined. While using Playwright

I am getting an error while testing with jest in my Javascript code.

The Error:

FAIL src/test/testPlaywright.test.jsx (5.779 s) × Creating a Snapshot of interacting with playwright (149 ms)

● Creating a Snapshot of interacting with playwright

browserType.launch: setImmediate is not defined

  4 |     for(const browserType of [chromium, firefox, webkit]){
  5 |         console.log("Testing");
> 6 |         const browser = await browserType.launch({headless: false});
    |                                           ^
  7 |         const page = await browser.newPage();
  8 |         await page.setDefaultNavigationTimeout(1000000);
  9 |         await page.goto('https://app.wien.gv.at/navigation/', { waitUntil: 'networkidle' });

  at Object.<anonymous> (src/test/testPlaywright.test.jsx:6:43)

Test Suites: 1 failed, 1 total Tests: 1 failed, 1 total Snapshots: 0 total Time: 8.517 s Ran all test suites related to changed files.

The Code:

import { chromium, webkit, firefox } from "playwright";

test('Creating a Snapshot of interacting with playwright',async()=>{
    for(const browserType of [chromium, firefox, webkit]){
        console.log("Testing");
        const browser = await browserType.launch({headless: false});
        const page = await browser.newPage();
        await page.setDefaultNavigationTimeout(1000000); 
        await page.goto('https://app.wien.gv.at/navigation/', { waitUntil: 'networkidle' });

        await page.click("(//mat-icon[text()='keyboard_arrow_down'])[1]")
        await page.click("#mat-select-0")
        await page.click('//span[@class="mat-option-text"][contains(.,"Veranstaltungszentrum")]')
        await page.click("//mat-icon[text()='keyboard_arrow_up']")
        
        await page.click("(//mat-icon[text()='keyboard_arrow_down'])[2]")
        await page.click("#mat-select-3")
        await page.click('//span[@class="mat-option-text"][contains(.,"Kapelle Krankenhaus Hietzing")]')

        await page.waitForTimeout(2000);

        await page.screenshot({path:'image-'+browserType.name()+'.png'});
        
        await browser.close();
    }
})
about 4 years ago · Juan Pablo Isaza
3 Respostas
Responde à pergunta

0

The Problem is the setImmediate function.

I just added the polyfill.js in my test class : import 'core-js'; after that setImmediate was defined again and works now as intended.

about 4 years ago · Juan Pablo Isaza Relatório

0

I suspect your jest.config.js contains

testEnvironment: 'jsdom'

you can try remove this setting or

 testEnvironment: 'node'

I hope you have good luck.

about 4 years ago · Juan Pablo Isaza Relatório

0

The solution that worked well for me, in react-native environment, was the following

  1. run on the terminal:
yarn add -D core-js
  1. and add inside of the jest.config.js file, or the config file configured on the jest parameter setupFiles the following import
import 'core-js';
about 4 years ago · Juan Pablo Isaza Relatório
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