summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcia Ramos <marcia@gitlab.com>2019-06-25 15:37:42 +0000
committerMarcia Ramos <marcia@gitlab.com>2019-06-25 15:37:42 +0000
commitbe862af45184b1d9fbede1924d7a8c6395637b29 (patch)
tree1fa1409446b1efa22fc05ad45be6ad00760fe6b8
parent59a53e13969d6cbe9f5e187c450a3a7c20521e98 (diff)
parent1eccad79c1850fd047884406e0906c928533dc42 (diff)
downloadgitlab-ce-be862af45184b1d9fbede1924d7a8c6395637b29.tar.gz
Merge branch 'winh-this-jest-docs' into 'master'
Clarify that this.something is not available in Jest (docs) Closes #24809 See merge request gitlab-org/gitlab-ce!29887
-rw-r--r--doc/development/testing_guide/frontend_testing.md3
1 files changed, 3 insertions, 0 deletions
diff --git a/doc/development/testing_guide/frontend_testing.md b/doc/development/testing_guide/frontend_testing.md
index 3949f61d4d4..fc9b175bc8a 100644
--- a/doc/development/testing_guide/frontend_testing.md
+++ b/doc/development/testing_guide/frontend_testing.md
@@ -32,6 +32,9 @@ we need to solve before being able to use Jest for all our needs.
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).
- `rewire` is not required because Jest supports mocking modules. See also [Manual Mocks](https://jestjs.io/docs/en/manual-mocks).
+- No [context object](https://jasmine.github.io/tutorials/your_first_suite#section-The_%3Ccode%3Ethis%3C/code%3E_keyword) is passed to tests in Jest.
+ This means sharing `this.something` between `beforeEach()` and `it()` for example does not work.
+ Instead you should declare shared variables in the context that they are needed (via `const` / `let`).
- The following will cause tests to fail in Jest:
- Unmocked requests.
- Unhandled Promise rejections.