MCPcopy Index your code
hub / github.com/codeaashu/claude-code / testGrowthBook

Function testGrowthBook

scripts/test-services.ts:28–58  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

26}
27
28async function testGrowthBook() {
29 console.log('\n--- GrowthBook (Feature Flags) ---')
30 try {
31 const gb = await import('../src/services/analytics/growthbook.js')
32
33 // Test cached feature value returns default when GrowthBook is unavailable
34 const boolResult = gb.getFeatureValue_CACHED_MAY_BE_STALE('nonexistent_feature', false)
35 if (boolResult === false) {
36 pass('getFeatureValue_CACHED_MAY_BE_STALE (bool)', 'returns default false')
37 } else {
38 fail('getFeatureValue_CACHED_MAY_BE_STALE (bool)', `expected false, got ${boolResult}`)
39 }
40
41 const strResult = gb.getFeatureValue_CACHED_MAY_BE_STALE('nonexistent_str', 'default_val')
42 if (strResult === 'default_val') {
43 pass('getFeatureValue_CACHED_MAY_BE_STALE (str)', 'returns default string')
44 } else {
45 fail('getFeatureValue_CACHED_MAY_BE_STALE (str)', `expected "default_val", got "${strResult}"`)
46 }
47
48 // Test Statsig gate check returns false
49 const gateResult = gb.checkStatsigFeatureGate_CACHED_MAY_BE_STALE('nonexistent_gate')
50 if (gateResult === false) {
51 pass('checkStatsigFeatureGate_CACHED_MAY_BE_STALE', 'returns false for unknown gate')
52 } else {
53 fail('checkStatsigFeatureGate_CACHED_MAY_BE_STALE', `expected false, got ${gateResult}`)
54 }
55 } catch (err: any) {
56 fail('GrowthBook import', err.message)
57 }
58}
59
60async function testAnalyticsSink() {
61 console.log('\n--- Analytics Sink ---')

Callers 1

mainFunction · 0.85

Calls 2

passFunction · 0.85
failFunction · 0.85

Tested by

no test coverage detected