summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWinnie Hellmann <winnie@gitlab.com>2019-06-25 10:48:02 +0000
committerWinnie Hellmann <winnie@gitlab.com>2019-06-26 10:36:00 +0200
commit00c94bad51ae0cda8b3fd416ee064b4af81935c2 (patch)
tree1d4aac03c306cdf52bade0d0380adbed39f4f579
parent235d87777e611c57a6d7e44b32f863672d3d5bc6 (diff)
downloadgitlab-ce-winh-jsdom-limitations-docs.tar.gz
Document limitations of jsdomwinh-jsdom-limitations-docs
-rw-r--r--doc/development/testing_guide/frontend_testing.md13
1 files changed, 12 insertions, 1 deletions
diff --git a/doc/development/testing_guide/frontend_testing.md b/doc/development/testing_guide/frontend_testing.md
index fc9b175bc8a..f3b661b9d30 100644
--- a/doc/development/testing_guide/frontend_testing.md
+++ b/doc/development/testing_guide/frontend_testing.md
@@ -27,7 +27,7 @@ we need to solve before being able to use Jest for all our needs.
### Differences to Karma
- Jest runs in a Node.js environment, not in a browser. Support for running Jest tests in a browser [is planned](https://gitlab.com/gitlab-org/gitlab-ce/issues/58205).
-- Because Jest runs in a Node.js environment, it uses [jsdom](https://github.com/jsdom/jsdom) by default.
+- Because Jest runs in a Node.js environment, it uses [jsdom](https://github.com/jsdom/jsdom) by default. (see also [limitations](#limitations-of-jsdom) below)
- Jest does not have access to Webpack loaders or aliases.
The aliases used by Jest are defined in its [own config](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/jest.config.js).
- All calls to `setTimeout` and `setInterval` are mocked away. See also [Jest Timer Mocks](https://jestjs.io/docs/en/timer-mocks).
@@ -40,6 +40,17 @@ we need to solve before being able to use Jest for all our needs.
- Unhandled Promise rejections.
- Calls to `console.warn`, including warnings from libraries like Vue.
+### Limitations of jsdom
+
+As mentioned [above](#differences-to-karma), Jest uses jsdom instead of running in a browser.
+This comes with a number of limitations, namely:
+
+- [no scrolling support](https://github.com/jsdom/jsdom/blob/15.1.1/lib/jsdom/browser/Window.js#L623-L625)
+- [no element sizes or positions](https://github.com/jsdom/jsdom/blob/15.1.1/lib/jsdom/living/nodes/Element-impl.js#L334-L371)
+- [no layout engine](https://github.com/jsdom/jsdom/issues/1322) in general
+
+We have [#58205](https://gitlab.com/gitlab-org/gitlab-ce/issues/58205) to add support for running Jest in a browser.
+
### Debugging Jest tests
Running `yarn jest-debug` will run Jest in debug mode, allowing you to debug/inspect as described in the [Jest docs](https://jestjs.io/docs/en/troubleshooting#tests-are-failing-and-you-don-t-know-why).