Skip to content

Utilize jest-environment-jsdom-sixteen for tests

Lukas Eipert requested to merge leipert-jsdom-sixteen into master

What does this MR do?

Utilize jest-environment-jsdom-sixteen for tests

This allows us to utilize the newest version of jsdom (16) in jest. Our current version of jest relies on version 11. The newer version of jsdom brings a lot of features, e.g. Custom Elements which we need for gl_emoji tests.

Other necessary changes in this MR

Update jest snapshots

Apparently a few of our snapshots change because of the implementation changes in jsdom


Fix emitting of events in jest

Some of the internal changes of jsdom seem to have an effect on events. Especially with click events on links. These refactors those events to be triggered by Vue.

In other cases we were manually dispatching events, when it is easier to just trigger an event directly.


Fix focus tests with new jsdom version

If elements are not attached to the DOM, jsdom doesn't update document.activeElement or add :focus pseudo classes.

This fixes tests that are testing focus states.


Add a helper to spy on window.location

The window.location interface is read only in newer versions of jsdom. This breaks our manual mocks / spys on that interface.

With a helper which replaces window.location with a mocked interface we are able to circumvent that problem.

Does this MR meet the acceptance criteria?

Conformity

Availability and Testing

Security

If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:

  • Label as security and @ mention @gitlab-com/gl-security/appsec
  • The MR includes necessary changes to maintain consistency between UI, API, email, or other methods
  • Security reports checked/validated by a reviewer from the AppSec team
Edited by Lukas Eipert

Merge request reports

Loading