[lexical-headless-test] Enhance navigator environment check with object type and structure validation#7626
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
etrepum
left a comment
There was a problem hiding this comment.
How is this a net improvement, if the tests don't run in the configuration where this may have failed? It changes one test, which must have already passed, and seems to make no changes to any runtime code.
If this code is only relevant to tests, it should probably be colocated with the tests rather than placed in shared. We don't have other test utilities in the shared package.
You are right — this change does not introduce any modifications to the runtime code. As you suggested, I will move |
etrepum
left a comment
There was a problem hiding this comment.
I still don't really understand what purpose this serves, because the tests don't run in an environment where this change has any effect, but it is a small change isolated to the tests now.
…ct type and structure validation (#7626)
Lexical version: 0.32.1
[lexical-headless]
[env-utils] Feature: improve navigator detection logic for Node environments
Choose from the following PR Types:
Chore
Description
lexical-headless must guarantee testing in a Node environment, not in jsDom.
To ensure this, the following comment is placed at the top of the file to explicitly run tests in the Node environment:
While testing 'should be headless environment', we verified that both window and document are undefined as expected.
However, navigator was found to be assigned an empty object and identified as an Object, which is unexpected.
To address this, we added logic to check whether navigator is a valid one created by the test environment (i.e., not a fake or placeholder object), ensuring a more accurate environment validation.
Before
Test Failing because

typeof navigatoris returning "object".After
All Test succeeded.
