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

180
Views
Karma fails to load test file: "Failed to fetch dynamically imported module"

I'm trying to test my LitElement components with Karma but importing PDF.JS is causing the test file not to be loaded.

Example of the LitElement component file

import * as pdfjsLib from 'pdfjs-dist/build/pdf.js';
import * as pdfjsWorker from 'pdfjs-dist/build/pdf.worker.entry.js';
import * as pdfjsSandbox from 'pdfjs-dist/build/pdf.sandbox.js';
import * as pdfjsViewer from 'pdfjs-dist/web/pdf_viewer.js';
import pdfjsViewerCss from 'pdfjs-dist/web/pdf_viewer.css';

export class UiDocReviewContext extends ScopedElementsMixin(LitElement) {
  static get properties() {
    return {
        ....

Example of the Karma test file

import '../ui-doc-review-context.js';

describe('feat-upload', async () => {
  beforeEach(async () => {
    await fixture(html`<ui-doc-review-context
      .data=${{}}
      .pageNum=${1}
      .box=${{}}
    ></ui-doc-review-context>`);
  });
})

The issue
Karma gives the following error:

Chrome Headless 100.0.4896.127 (Mac OS 10.15.7) ERROR: 'Error loading test file: /packages/ui-doc-review-context/test/ui-doc-review-context.test.js'
Chrome Headless 100.0.4896.127 (Mac OS 10.15.7) ERROR: 'TypeError: Failed to fetch dynamically imported module: http://localhost:9876/base/packages/ui-doc-review-context/test/ui-doc-review-context.test.js?c2a0b72b2b28b1f3a57be6918056fed53cfcd90c'

In the console logs I get this:

Failed to load module script: Expected a JavaScript module script but the server responded with a MIME type of "text/css". Strict MIME type checking is enforced for module scripts per HTML spec.
context.js:265 Error loading test file: /packages/ui-doc-review-context/test/ui-doc-review-context.test.js
context.js:265 TypeError: Failed to fetch dynamically imported module: http://localhost:9876/base/packages/ui-doc-review-context/test/ui-doc-review-context.test.js?c2a0b72b2b28b1f3a57be6918056fed53cfcd90c
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!