-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
Testing project using jest & jsdom throws ckeditor-duplicated-modules error #10571
Comments
Hi, thanks for the report. |
Bit late to this thread, but I just ran into this issue. I was able to get my tests running by putting: Object.defineProperty(global, 'CKEDITOR_VERSION', {
set: function(val) {
if(global.CKEDITOR_VERSION) {
global.CKEDITOR_VERSION = '';
}
}
}); in my |
There has been no activity on this issue for the past year. We've marked it as stale and will close it in 30 days. We understand it may be relevant, so if you're interested in the solution, leave a comment or reaction under this issue. |
There has been no activity on this issue for the past year. 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. |
We've closed your issue due to inactivity over the last year. We understand that the issue may still be relevant. If so, feel free to open a new one (and link this issue to it). |
📝 Provide detailed reproduction steps (if any)
When running Jest unit tests for a project which imports CKEditor 5, the tests throw a ckeditor-duplicated-modules error. This is caused by an underlying JSDOM issue where it loads the CKEditor5 build script twice which causes
ckeditor5-utils/src/version.js
to execute twice and throw an error.ckeditor-duplicated-modules
✔️ Expected result
No error should be thrown, there should be a better determination of version conflict and shouldn't result in breaking of test scenarios when there is no real runtime issue.
❌ Actual result
Error is thrown and tests cannot be fixed or mocked to avoid it.
❓ Possible solution
Two solutions here, both would reside in ckeditor5-utils/src/version.js
One would be to check the version to ensure it's not the same as the one currently loading. That's when we should be throwing an error, not when the same script is loaded twice.
Second would be to just avoid throwing an error entirely when in a test environment. This one is trickier and would vary based on which test runner is being used and the environment in which it's being tested.
I'd suggest moving forward with option one, for which I can push a quick PR for.
If you'd like to see this fixed sooner, add a 👍 reaction to this post.
The text was updated successfully, but these errors were encountered: