summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Bennett <lbennett@gitlab.com>2019-03-20 20:05:27 +0000
committerLuke Bennett <lbennett@gitlab.com>2019-03-20 20:24:05 +0000
commit954199d8504e7738802071834b4fed9e8fe90835 (patch)
tree5e0dd463786322eb2ce31873e8f4c8c048ea5979
parentfbc49fa332fb2302b13a556af02efcc18b3e004d (diff)
downloadgitlab-ce-clientside-feature-flag-test-docs.tar.gz
Add clientside feature flag test docsclientside-feature-flag-test-docs
-rw-r--r--doc/development/feature_flags.md18
1 files changed, 16 insertions, 2 deletions
diff --git a/doc/development/feature_flags.md b/doc/development/feature_flags.md
index 3271f9a7fb3..4d8919596f8 100644
--- a/doc/development/feature_flags.md
+++ b/doc/development/feature_flags.md
@@ -26,8 +26,8 @@ the time, you should execute `/chatops run feature set my_feature_flag 50`.
## Feature flags for user applications
-This document only covers feature flags used in the development of GitLab
-itself. Feature flags in deployed user applications can be found at
+This document only covers feature flags used in the development of GitLab
+itself. Feature flags in deployed user applications can be found at
[Feature Flags](https://docs.gitlab.com/ee/user/project/operations/feature_flags.html)
## Developing with feature flags
@@ -103,6 +103,8 @@ that checking for `gon.features.vim_bindings` would not work.
### Specs
+#### RSpec
+
In the test environment `Feature.enabled?` is stubbed to always respond to `true`,
so we make sure behavior under feature flag doesn't go untested in some non-specific
contexts.
@@ -114,6 +116,18 @@ feature flag. You can stub a feature flag as follows:
stub_feature_flags(my_feature_flag: false)
```
+#### Karma / Jest
+
+You can mock a feature flag by setting the boolean flag property on `gon.features`,
+which is reset `beforeEach` test to an empty object.
+
+```js
+it('works great when newFeature is enabled', () => {
+ Object.assign(gon.features, { newFeature: true });
+ // ...
+});
+```
+
## Enabling a feature flag (in development)
In the rails console (`rails c`), enter the following command to enable your feature flag