-
Notifications
You must be signed in to change notification settings - Fork 100
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
'duplicated modules' error when running tests in Jest #219
Comments
Hi @aliceriot, I am sorry for the late response. We're in the middle of the testing phase/release process. We'll plan to release the next version of CKEditor 5 on Wed, Mar 3rd. After the release, I'll be able to take a look at the issue and give you more attention. |
@aliceriot, I've checked the issue using the code from the provided repository. Unfortunately, I don't understand why the error occurs. I checked the It looks like Jest has some issues when transforming CKEditor sources. If you will comment out the code ( throw new CKEditorError(
'ckeditor-duplicated-modules',
null
); Jest will end with another error:
If it is possible in your project, I'd suggesting changing the test runner. E.g. Karma + Webpack. |
hey @pomek, thanks for following up about this. I was worried that we'd have to switch away from jest...it's such a nice test runner. I may take a little more time to try and see if I can get to the bottom of what's going on, if I find anything useful I'll let you know. These issues seem possibly to be something to do with the combination of Jest and React btw. I wrote some tests here for a custom Markdown plugin which we wrote: mitodl/ocw-studio#99 To use markdown in our project we need to be able to add support for extended markdown syntax, so I wrote a little pluggable API where plugins can define new markdown syntax. Anyhow, in testing this it I didn't have any problems with running some tests in Jest. So I'll try to investigate a little bit if perhaps the issue is enzyme or something. |
scratch that, was too optimistic! |
I may be wrong here, but one of the issues with running tests that I had in the past was that if there are multiple input JS files, and each of them is compiled separately and then they are all loaded into one process, that means that the piece of code that checks the In Karma, we worked around this by having a single input file (generated on the fly), that aggregates all other files. However, resolving this issue, would be just the first step of many. The bigger problem is that Jest does not use a real browser, but JSDOM. I described this issue here: #225. |
For anyone who may be experiencing a similar issue: I had the "duplicated modules" error today after installing Mentions.
because I want to get updates and fixes for that version, BUT after running out of ideas (and checking my yarn.lock file) I just used the specific version like this:
And it worked! It may not be the solution for this specific issue, but that was the solution for me. |
Hello! I'm running into an issue that is cropping up only when my React-based CKEditor setup is running in Jest. The same component runs without issue on a basic test page in my application.
A bit about the setup:
<CKEditor>
react component from this package to create an editor component to use elsewhere in my application.The issue I'm seeing is only when running a very basic test in Jest. I'm using
enzyme
as part of my testing setup, and I have one test which basically tests whether the component can mount without errors. When the test runs I get this error:The code for this is all open source. You can see the branch where I've been working on these tests here: https://github.com/mitodl/ocw-studio/compare/ap/ckeditor-add-tests
A few key things (I think):
I've seen a few other issues on this repo with similar error messages, but after trying some of the fixes mentioned in those issues I haven't been able to resolve the issue. Any idea what might be going on? I thought perhaps something with multiple tests running, but it's only a single test. I'm also not depending on a pre-built distribution of CKEditor, but writing a custom class extending
@ckeditor/ckeditor5-classic-editor
. Anyhow, I'm sort of stumped!Thanks for any help you can offer, and lmk if more info would be helpful. The project I'm working on is open source - it's a django project but for diagnostic purposes it should be possible to clone and run JS tests and so on without messing with any of that stuff.
The text was updated successfully, but these errors were encountered: