{"id":19935082,"url":"https://github.com/optimizely/js-stub-pattern","last_synced_at":"2025-05-03T12:30:59.671Z","repository":{"id":185502882,"uuid":"629627910","full_name":"optimizely/js-stub-pattern","owner":"optimizely","description":"This repo shows Optimizely's recommended pattern for stub-based development for code that relies on a decision from an Optimizely SDK","archived":true,"fork":false,"pushed_at":"2023-04-20T19:58:15.000Z","size":8,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-03-01T12:17:14.912Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/optimizely.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2023-04-18T17:41:26.000Z","updated_at":"2024-01-26T15:06:18.000Z","dependencies_parsed_at":null,"dependency_job_id":"fcab6b47-6d6c-4614-a7bc-95dbde692891","html_url":"https://github.com/optimizely/js-stub-pattern","commit_stats":null,"previous_names":["optimizely/js-stub-pattern"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/optimizely%2Fjs-stub-pattern","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/optimizely%2Fjs-stub-pattern/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/optimizely%2Fjs-stub-pattern/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/optimizely%2Fjs-stub-pattern/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/optimizely","download_url":"https://codeload.github.com/optimizely/js-stub-pattern/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252190666,"owners_count":21708922,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-12T23:18:43.763Z","updated_at":"2025-05-03T12:30:59.368Z","avatar_url":"https://github.com/optimizely.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Two Patterns for Forcing Decisions in Lower Environments\n\nThis repo shows two recommended patterns for forcing decisions in lower environment(s).\n\n## Install\n\n```bash\nnpm install\n```\n\n## Option 1 – Stubs\n\nOption 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.\n\n### Run\n\n```bash\nnode lib/option1.js\n```\n\n## Run Option 2 – Forced Decisons\n\nOption 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.\n\n### Run\n\n```bash\nnode lib/option2.js\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foptimizely%2Fjs-stub-pattern","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Foptimizely%2Fjs-stub-pattern","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foptimizely%2Fjs-stub-pattern/lists"}