0

I updated my app to angular 15 (15.2.0) but I got an error when I run karma test with npm run test :

enter image description here

The error is caused by Error: Automatic publicPath is not supported in this browser. It only occurs when I run test, that works well when I build my project or I serve it.

I notice that this error appears only when I have stylePreprocessorOptions on my test builder options :

"test": {
  "builder": "@angular-devkit/build-angular:karma",
  "options": {
    "main": "packages/mypackage/src/test.ts",
    "tsConfig": "packages/mypackage/tsconfig.spec.json",
    "karmaConfig": "packages/mypackage/karma.conf.js",

    // This option
    "stylePreprocessorOptions": {
      "includePaths": ["./node_modules/@mystylepackage"]
    }

  }
},

Complement:

  • no specific webpack config file
  • webpack version 5.75.0 (version installed with angular 15)
  • karma packages versions:
    "karma": "^6.4.0",
    "karma-chrome-launcher": "^3.1.1",
    "karma-coverage": "^2.2.0",
    "karma-firefox-launcher": "^2.1.2",
    "karma-jasmine": "^5.1.0",
    "karma-jasmine-html-reporter": "^2.0.0",

I have no idea why, could you help me please ?

EDIT:

The error is from a home dependency with a wrong webpack config. After updating this dependency, it works well.

  • 1
    Does this answer your question? [Webpack5 Automatic publicPath is not supported in this browser](https://stackoverflow.com/questions/64294706/webpack5-automatic-publicpath-is-not-supported-in-this-browser) –  Mar 07 '23 at 16:39
  • No, I tried to set up this, but I have no webpack config file because angular manages this. The error only occurs when I run test, that works well when I build my project or I serve it. – Baptiste Borel Mar 08 '23 at 08:16
  • I found why... The error is from a home dependency with a wrong webpack config. After updating this dependency, it works well. – Baptiste Borel Mar 14 '23 at 14:23
  • You should answer your own question with the details of the fix in case someone else runs into a similar issue :) –  Mar 14 '23 at 14:48

0 Answers0