You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/getting-started/integrations/angular.md
+49Lines changed: 49 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -696,13 +696,62 @@ There is a known issue related to the localization in Angular 17. Read more in t
696
696
697
697
## Known issues
698
698
699
+
### Module resolution
700
+
699
701
The `moduleResolution` option of the TypeScript configuration determines the algorithm for finding and resolving modules from `node_modules`. In Angular 17, the option is set to `node` by default. This option prevents type declaration for editor translations from being correctly loaded. To fix it, you have several options:
700
702
701
703
* You can set the `moduleResolution` option to `bundler`. It is the recommended setting in TypeScript 5.0+ for applications that use a bundler. And it is a recommended way of fixing this problem. You can check other solutions below for lower TypeScript versions.
702
704
* You can tell the TypeScript compiler to suppress the problem using the `// @ts-expect-error` comment above the imported translations.
703
705
* You can update Angular to version 18, where the `moduleResolution` option is set to `bundler` by default.
704
706
* You can import translations directly from our CDN, like: `import ‘https://cdn.ckeditor.com/ckeditor5/{@var ckeditor5-version}/translations/es.umd.js’;`. This way, the editor will load the translations automatically, so you do not need to pass them manually into the config.
705
707
708
+
### Jest testing
709
+
710
+
You can use Jest as a test runner in Angular apps. Unfortunately, Jest does not use a real browser. Instead, it runs tests in Node.js that uses JSDOM. JSDOM is not a complete DOM implementation, and while it is sufficient for standard apps, it cannot polyfill all the DOM APIs that CKEditor 5 requires.
711
+
712
+
For testing CKEditor 5, it is recommended to use testing frameworks that utilize a real browser and provide a complete DOM implementation. Some popular options include:
713
+
714
+
*[Vitest](https://vitest.dev/)
715
+
*[Playwright](https://playwright.dev/)
716
+
*[Cypress](https://www.cypress.io/)
717
+
718
+
These frameworks offer better support for testing CKEditor 5 and provide a more accurate representation of how the editor behaves in a real browser environment.
719
+
720
+
If this is not possible and you still want to use Jest, you can mock some of the required APIs. Below is an example of how to mock some of the APIs used by CKEditor 5:
721
+
722
+
```javascript
723
+
beforeAll( () => {
724
+
window.scrollTo=jest.fn();
725
+
726
+
window.ResizeObserver=classResizeObserver {
727
+
observe() {}
728
+
unobserve() {}
729
+
disconnect() {}
730
+
};
731
+
732
+
for ( constkeyof [ 'InputEvent', 'KeyboardEvent' ] ) {
733
+
window[ key ].prototype.getTargetRanges= () => {
734
+
constrange=newStaticRange( {
735
+
startContainer:document.body.querySelector( '.ck-editor__editable p' ),
736
+
startOffset:0,
737
+
endContainer:document.body.querySelector( '.ck-editor__editable p' ),
738
+
endOffset:0
739
+
} );
740
+
741
+
return [ range ];
742
+
};
743
+
}
744
+
745
+
Range.prototype.getClientRects= () => ( {
746
+
item: () =>null,
747
+
length:0,
748
+
[ Symbol.iterator ]:function* () {}
749
+
} );
750
+
} );
751
+
```
752
+
753
+
These mocks should be placed before the tests that use CKEditor 5. They are imperfect and may not cover all the cases, but they should be sufficient for basic initialization and rendering editor. Keep in mind that they are not a replacement for proper browser testing.
754
+
706
755
## Contributing and reporting issues
707
756
708
757
The source code of the CKEditor 5 rich text editor component for Angular is available on GitHub in [https://github.com/ckeditor/ckeditor5-angular](https://github.com/ckeditor/ckeditor5-angular).
Copy file name to clipboardExpand all lines: docs/getting-started/integrations/react.md
+100Lines changed: 100 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -288,6 +288,106 @@ export default App;
288
288
289
289
For more information, please refer to the {@link getting-started/setup/ui-language Setting the UI language} guide.
290
290
291
+
### Jest testing
292
+
293
+
Jest is the default test runner used by many React apps. Unfortunately, Jest does not use a real browser. Instead, it runs tests in Node.js that uses JSDOM. JSDOM is not a complete DOM implementation, and while it is sufficient for standard apps, it cannot polyfill all the DOM APIs that CKEditor 5 requires.
294
+
295
+
For testing CKEditor 5, it is recommended to use testing frameworks that utilize a real browser and provide a complete DOM implementation. Some popular options include:
296
+
297
+
* [Vitest](https://vitest.dev/)
298
+
* [Playwright](https://playwright.dev/)
299
+
* [Cypress](https://www.cypress.io/)
300
+
301
+
These frameworks offer better support for testing CKEditor 5 and provide a more accurate representation of how the editor behaves in a real browser environment.
302
+
303
+
If this is not possible and you still want to use Jest, you can mock some of the required APIs. Below is an example of how to mock some of the APIs used by CKEditor 5:
The mocks presented above only test two basic scenarios, and more will likely need to be added, which may change with each version of the editor.
390
+
291
391
## Contributing and reporting issues
292
392
293
393
The source code of rich text editor component for React is available on GitHub in [https://github.com/ckeditor/ckeditor5-react](https://github.com/ckeditor/ckeditor5-react).
For more information, refer to the {@link getting-started/setup/ui-language Setting the UI language} guide.
478
478
479
+
### Jest testing
480
+
481
+
You can use Jest as a test runner in Vue apps. Unfortunately, Jest does not use a real browser. Instead, it runs tests in Node.js that uses JSDOM. JSDOM is not a complete DOM implementation, and while it is sufficient for standard apps, it cannot polyfill all the DOM APIs that CKEditor 5 requires.
482
+
483
+
For testing CKEditor 5, it is recommended to use testing frameworks that utilize a real browser and provide a complete DOM implementation. Some popular options include:
484
+
485
+
*[Vitest](https://vitest.dev/)
486
+
*[Playwright](https://playwright.dev/)
487
+
*[Cypress](https://www.cypress.io/)
488
+
489
+
These frameworks offer better support for testing CKEditor 5 and provide a more accurate representation of how the editor behaves in a real browser environment.
490
+
491
+
If this is not possible and you still want to use Jest, you can mock some of the required APIs. Below is an example of how to mock some of the APIs used by CKEditor 5:
492
+
493
+
```javascript
494
+
beforeAll( () => {
495
+
window.scrollTo=jest.fn();
496
+
497
+
window.ResizeObserver=classResizeObserver {
498
+
observe() {}
499
+
unobserve() {}
500
+
disconnect() {}
501
+
};
502
+
503
+
for (constkeyof ['InputEvent', 'KeyboardEvent']) {
These mocks should be placed before the tests that use CKEditor 5. They are imperfect and may not cover all the cases, but they should be sufficient for basic initialization and rendering editor. Remember that they are not a replacement for proper browser testing.
525
+
479
526
## Contributing and reporting issues
480
527
481
528
The source code of this component is available on GitHub in [https://github.com/ckeditor/ckeditor5-vue](https://github.com/ckeditor/ckeditor5-vue).
0 commit comments