Skip to content
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

Closed
rkanjani opened this issue Sep 21, 2021 · 5 comments
Closed
Labels
pending:feedback This issue is blocked by necessary feedback. resolution:expired This issue was closed due to lack of feedback. type:bug This issue reports a buggy (incorrect) behavior.

Comments

@rkanjani
Copy link

📝 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.

  1. Run tests where jsdom is used in jest
  2. CKEditor throws 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.

@rkanjani rkanjani added the type:bug This issue reports a buggy (incorrect) behavior. label Sep 21, 2021
@FilipTokarski
Copy link
Member

Hi, thanks for the report.
Seems like related/duplicate of ckeditor/ckeditor5-react#219. Please check ckeditor/ckeditor5-react#225 for more information on this topic.

@FilipTokarski FilipTokarski added the pending:feedback This issue is blocked by necessary feedback. label Sep 22, 2021
@JefreyHildebrandt
Copy link

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 jestSetup.js file which set up the environment before the tests are run. Just makes it so utils/src/version.js never throws the error since global.CKEDITOR_VERSION is never set.

@CKEditorBot
Copy link
Collaborator

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.

@CKEditorBot
Copy link
Collaborator

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.

@CKEditorBot
Copy link
Collaborator

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

@CKEditorBot CKEditorBot added resolution:expired This issue was closed due to lack of feedback. and removed status:stale labels Jan 15, 2024
@CKEditorBot CKEditorBot closed this as not planned Won't fix, can't repro, duplicate, stale Jan 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pending:feedback This issue is blocked by necessary feedback. resolution:expired This issue was closed due to lack of feedback. type:bug This issue reports a buggy (incorrect) behavior.
Projects
None yet
Development

No branches or pull requests

4 participants