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

92
Views
Use jest to test a not exported object in an imported script with webpack 5

The title may seems a bit confusing, let me explain.

I'm using an opensource library pico which has a not exported object "pico", so I put ?raw keyword to import it in my frontend project with webpack 5.

import "./lib/pico.js?raw";

And it works properly on my frontend page.

--

Then when I want to unit test it by jest, I found jest-raw-loader by this post, but the pico seems won't be imported by using this library.

The ?raw on webpack seems more similar as script-loader library.

And jest-raw-loader seems more similar as raw-loader on older versions.

Although webpack official doc suggest to replace raw-loader with ?raw, but they seem different in my case.

I know I can simply edit this pico.js file to export this object. But what if next time I have a far larger library need to be managed? Is there any other way to import this kind of "not exported" object?

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!