surmon-china/ngx-quill-editor

Testing wih Jest fails.

1ik opened this issue · 1 comments

1ik commented

The following block of code is causing a failure when I am using Jest with jest-angular-preset plugin.

styleUrls: [
'./quillEditor.component.css',
'../quill/dist/quill.core.css',
'../quill/dist/quill.snow.css',
'../quill/dist/quill.bubble.css'
],

The details of the error is,

 FAIL  src/app/app.component.spec.ts (5.944s)
  AppComponent
    ✕ should create the app (96ms)

  ● AppComponent › should create the app

    SyntaxError: The string did not match the expected pattern.

      at XMLHttpRequest.open [as __zone_symbol__open] (node_modules/jest-preset-angular/node_modules/jsdom/lib/jsdom/living/xmlhttprequest.js:475:15)
      at Array.map (native)

  ● AppComponent › should create the app

    SyntaxError: The string did not match the expected pattern.

      at XMLHttpRequest.open [as __zone_symbol__open] (node_modules/jest-preset-angular/node_modules/jsdom/lib/jsdom/living/xmlhttprequest.js:475:15)
      at Array.map (native)

Test Suites: 1 failed, 1 total
Tests:       1 failed, 1 total
Snapshots:   0 total
Time:        7.915s
Ran all test suites.

However, the error can be easily fixed if it's changed to inline like the following,

styleUrls: [
    './quillEditor.component.css', '../quill/dist/quill.core.css', '../quill/dist/quill.snow.css', '../quill/dist/quill.bubble.css'
  ],

I know this is jest-angular-preset's plugins regex that fails to parse the line breaks but if you think that little change in code won't hurt I can create a PR :).

I have the same problem but I have just once style in my array...

styleUrls: ['./accueil.component.scss']