Skip to content

Allow monaco-editor to work propertly with Jest - #109833

Merged
Alexandru Dima (alexdima) merged 2 commits into
microsoft:masterfrom
fleon:patch-1
Nov 3, 2020
Merged

Allow monaco-editor to work propertly with Jest#109833
Alexandru Dima (alexdima) merged 2 commits into
microsoft:masterfrom
fleon:patch-1

Conversation

@fleon

@fleon Himanshu Kapoor (fleon) commented Nov 2, 2020

Copy link
Copy Markdown
Contributor

In Node.js environments where Jest is run, global is already an existing variable. Using const to redeclare it causes an error and therefore makes it impossible to run any monaco-editor related tests with Jest. Changing this line from const to var doesn't cause this issue.

We use monaco-editor in GitLab, and in order to upgrade it to the latest version and make it work with Jest, the only solution was to patch it using patch-package. The patch solution doesn't scale so well.

Here's a bit more info: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/46436#note_438312326

In Node.js environments where Jest is run, `global` is already an existing
variable. Using `const` to redeclare it causes an error and therefore makes it
impossible to run any `monaco-editor` related tests to run with Jest. Changing
this line from `const` to `var` doesn't cause this issue.
@fleon

Copy link
Copy Markdown
Contributor Author

Alternatively, it would also be worthwhile calling this variable something other than global, if using var isn't recommended by linters. There are only 5 occurences in this file, and nowhere else in this repository, so that should be also a good alternative.

@fleon Himanshu Kapoor (fleon) changed the title Use var instead of const for the global variable Allow monaco-editor to work propertly with Jest Nov 2, 2020
@alexdima
Alexandru Dima (alexdima) merged commit e934668 into microsoft:master Nov 3, 2020
@fleon

Copy link
Copy Markdown
Contributor Author

Alexandru Dima (@alexdima) Thanks for merging this. Any potential timelines for the release of this fix?

@github-actions github-actions Bot locked and limited conversation to collaborators Dec 18, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants