https://github.com/optimizely/js-stub-pattern
This repo shows Optimizely's recommended pattern for stub-based development for code that relies on a decision from an Optimizely SDK
https://github.com/optimizely/js-stub-pattern
Last synced: 10 months ago
JSON representation
This repo shows Optimizely's recommended pattern for stub-based development for code that relies on a decision from an Optimizely SDK
- Host: GitHub
- URL: https://github.com/optimizely/js-stub-pattern
- Owner: optimizely
- Archived: true
- Created: 2023-04-18T17:41:26.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2023-04-20T19:58:15.000Z (almost 3 years ago)
- Last Synced: 2025-03-01T12:17:14.912Z (about 1 year ago)
- Language: JavaScript
- Homepage:
- Size: 7.81 KB
- Stars: 0
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Two Patterns for Forcing Decisions in Lower Environments
This repo shows two recommended patterns for forcing decisions in lower environment(s).
## Install
```bash
npm install
```
## Option 1 – Stubs
Option 1 operates similar to a stub in a unit test. If the environment is not primary, it essentially reads a committed config file and returns a chosen value instead of calling the real Opti SDK. Notably, this pattern would ignore calls to `setForcedDecision`, as the Opti SDK would not actually be called in lower environments.
### Run
```bash
node lib/option1.js
```
## Run Option 2 – Forced Decisons
Option 2 leverages our existing forced decision method. With this option, a developer would iterate over a committed config file to force decisions. This has the advantage of working well with other calls to `setForcedDecision` in the code.
### Run
```bash
node lib/option2.js
```