-
-
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
Update CKEditor 34 -> 35: SyntaxError: Identifier 'global' has already been declared #12971
Comments
We are having the same issue when running our Jest Tests with CKEditor 35. |
@carlartz I tried do debug it more, it seems like Jest itself does not like the -let global;
+let globalVar;
// In some environments window and document API might not be available.
try {
- global = { window, document };
+ globalVar = { window, document };
}
catch (e) {
// It's not possible to mock a window object to simulate lack of a window object without writing extremely convoluted code.
/* istanbul ignore next */
// Let's cast it to not change module's API.
// We only handle this so loading editor in environments without window and document doesn't fail.
// For better DX we shouldn't introduce mixed types and require developers to check the type manually.
// This module should not be used on purpose in any environment outside browser.
- globalVar = { window: {}, document: {} };
+ globalVar = { window: {}, document: {} };
}
-export default global;
+export default globalVar; Does this also fix it in your case? |
Same Issue with Jest when upgrading to CKEditor 35. Keeping an eye here. Following the thread. |
@otto10 can you test if the rename would also fix it in your case? |
This should work, we renamed the variable locally and our tests ran successfully. Would this impact CKEditor running in our application? |
@carlartz Thx for testing. As |
cc: @arkflpc |
Internal (utils): Changes `global` variable name to avoid syntax error. Closes #12971. Thanks to @alexander-schranz!
Apologies to everyone – I forgot about this issue. Fortunately, @mremiszewski and @arkflpc corrected my mistake :) Sorry it took so long! |
BTW, I wonder what's the root cause of this problem? Why does Jest have a problem with that variable? I'm a bit afraid that we fixed this particular issue but we'll hit the same problem elsewhere later on too. |
@Reinmar jest defines a global const called Its something like this: function jest(global) {
// ckeditor
let global = 2;
}
jest(); It is very similar to that you can not do |
📝 Provide detailed reproduction steps (if any)
I run into the follwoing issue:
When running our tests with Jest after updating CKEditor 34 -> 35.
✔️ Expected result
What is the expected result of the above steps?
Tests should not fail.
❌ Actual result
What is the actual result of the above steps?
❓ Possible solution
If you have ideas, you can list them here. Otherwise, you can delete this section.
📃 Other details
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: