surmon-china / ngx-quill-editor

🍡@quilljs editor component for @angular
https://github.surmon.me/ngx-quill-editor
MIT License
232 stars 54 forks source link

Testing wih Jest fails. #30

Open 1ik opened 7 years ago

1ik commented 7 years ago

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

https://github.com/surmon-china/ngx-quill-editor/blob/512310bf02f5003d885f9ef9711c325605f3c7f5/quillEditor.component.ts#L20-L25

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 :).

clementGilardy commented 6 years ago

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

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