mardi 7 janvier 2020

Karma tests with Chrome Headless: System is not defined

In my project, I'm using the @open-wc stack to create a library of web components. I recently uploaded my dependencies and now I run into this error.

$ karma start --single-run --browsers ChromeHeadlessNoSandbox --auto-watch=false

START:
[...]
07 01 2020 09:50:09.260:INFO [karma-server]: Karma v4.4.1 server started at http://0.0.0.0:9876/
07 01 2020 09:50:09.261:INFO [launcher]: Launching browsers ChromeHeadlessNoSandbox with concurrency unlimited
07 01 2020 09:50:09.266:INFO [launcher]: Starting browser ChromeHeadless
07 01 2020 09:50:10.024:INFO [HeadlessChrome 79.0.3945 (Windows 10.0.0)]: Connected on socket UNLeNQSCDUFm-oqCAAAA with id 55668370
HeadlessChrome 79.0.3945 (Windows 10.0.0) ERROR
  Uncaught ReferenceError: System is not defined
  at http://localhost:9876/context.html:55:5

  ReferenceError: System is not defined
      at loadEntries (http://localhost:9876/context.html:55:5)
      at http://localhost:9876/context.html:58:3
      at http://localhost:9876/context.html:59:3

Finished in 0.51 secs / 0 secs @ 09:50:10 GMT+0100 (Central European Standard Time)

SUMMARY:
√ 0 tests completed
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

I ran Karma in watch mode and went to my devtools to inspect where the error could be coming from and the code sample looks like this.

(function() {  var polyfills = [];

  function loadEntries() {
    System.import('./inline-module-0.js?source=%2Fcontext.html');
  }

  loadEntries()
})();

Aucun commentaire:

Enregistrer un commentaire