ckeditor5 icon indicating copy to clipboard operation
ckeditor5 copied to clipboard

Jest - CKEditorError: ckeditor-duplicated-modules

Open DuIIDa opened this issue 1 year ago • 6 comments

I had this problem when running tests(Jest) after migrating from ckeditor4 to ckeditor5. image

package.json

"dependencies": { ... "@ckeditor/ckeditor5-react": "^8.0.0", "ckeditor5": "^42.0.0", ... } "jest": { "resetMocks": false, "collectCoverageFrom": [ "/*.{js,jsx,ts,tsx}", "!/integration-tests/", "!/node_modules/", "!/vendor/", "!src/old/", "!src/stories/**" ], "watchPathIgnorePatterns": [ "\integration-tests\" ], "transformIgnorePatterns": [ "!node_modules/" ], "moduleNameMapper": { "\.(css|less|scss|sass)$": "identity-obj-proxy" } },

My imports:

import { Bold, Essentials, Italic, Mention, Paragraph, Undo, Underline, Strikethrough, RemoveFormat, List, BlockQuote, Link, Table, TableToolbar, Heading, } from 'ckeditor5'; import ClassicEditor from '@ckeditor/ckeditor5-editor-classic/src/classiceditor'; import { CKEditor } from '@ckeditor/ckeditor5-react'; // eslint-disable-next-line import/no-unresolved import 'ckeditor5/ckeditor5.css';

I also tried importing ClassicEditor from ckeditor5.

DuIIDa avatar Jul 03 '24 14:07 DuIIDa

Hi! ClassicEditor should be pulled from ckeditor5 as well. What error did you see then?

Witoso avatar Jul 03 '24 14:07 Witoso

Hi! When import directly from ckeditor5 I get the same error. Imports: import { ClassicEditor, Bold, Essentials, Italic, Mention, Paragraph, Undo, Underline, Strikethrough, RemoveFormat, List, BlockQuote, Link, Table, TableToolbar, Heading, } from 'ckeditor5'; import { CKEditor } from '@ckeditor/ckeditor5-react';

image

DuIIDa avatar Jul 03 '24 14:07 DuIIDa

Which version of @ckeditor/ckeditor5-react and ckeditor5 packages do you use? Are you sure that both are installed in the latest available versions?

Second thing to check: You should have no imports from @ckeditor/* packages expect the react one. In other words, the only imports should happen from @ckeditor/ckeditor5-react and ckeditor5.

Reinmar avatar Jul 03 '24 21:07 Reinmar

I tihs version: image

I found a solution for myself. But I'm not sure it's correct Inside the test: jest.mock('File with CKEditor');

DuIIDa avatar Jul 04 '24 07:07 DuIIDa

Based on the snippets that you provided, all seems to be correct. I have no idea why you get the dup-modules error. But it's a one that can be triggered by things that are hard to spot.

Would you be able to compile a small sample project where this issue is reproducible?

Reinmar avatar Jul 08 '24 21:07 Reinmar

The issue lacks the feedback we asked for two weeks. Hence, we've marked it as stale and will close it in 30 days. We understand it may still be relevant, so if you're interested in the solution, leave a comment or reaction under this issue.

CKEditorBot avatar Jul 23 '24 03:07 CKEditorBot

We've closed your issue due to inactivity. We understand that the issue may still be relevant. If so, feel free to open a new one (and link this issue to it).

CKEditorBot avatar Aug 23 '24 01:08 CKEditorBot