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

156
Views
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 answers
Answer question

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 Report

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 Report

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 Report
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!