@@ -4,31 +4,30 @@ import { ConfidenceServerProviderLocal } from './ConfidenceServerProviderLocal';
44import { readFileSync } from 'node:fs' ;
55import { WasmResolver } from './WasmResolver' ;
66
7- const {
8- JS_E2E_CONFIDENCE_API_CLIENT_ID ,
9- JS_E2E_CONFIDENCE_API_CLIENT_SECRET ,
10- } = requireEnv ( 'JS_E2E_CONFIDENCE_API_CLIENT_ID' , 'JS_E2E_CONFIDENCE_API_CLIENT_SECRET' ) ;
7+ const { JS_E2E_CONFIDENCE_API_CLIENT_ID , JS_E2E_CONFIDENCE_API_CLIENT_SECRET } = requireEnv (
8+ ' JS_E2E_CONFIDENCE_API_CLIENT_ID' ,
9+ ' JS_E2E_CONFIDENCE_API_CLIENT_SECRET' ,
10+ ) ;
1111
1212const moduleBytes = readFileSync ( __dirname + '/../../../wasm/confidence_resolver.wasm' ) ;
1313const module = new WebAssembly . Module ( moduleBytes ) ;
1414const resolver = new WasmResolver ( module ) ;
1515const confidenceProvider = new ConfidenceServerProviderLocal ( resolver , {
1616 flagClientSecret : 'RxDVTrXvc6op1XxiQ4OaR31dKbJ39aYV' ,
1717 apiClientId : JS_E2E_CONFIDENCE_API_CLIENT_ID ,
18- apiClientSecret : JS_E2E_CONFIDENCE_API_CLIENT_SECRET
18+ apiClientSecret : JS_E2E_CONFIDENCE_API_CLIENT_SECRET ,
1919} ) ;
2020
2121describe ( 'ConfidenceServerProvider E2E tests' , ( ) => {
22- beforeAll ( async ( ) => {
23-
22+ beforeAll ( async ( ) => {
2423 await OpenFeature . setProviderAndWait ( confidenceProvider ) ;
2524 OpenFeature . setContext ( {
2625 targetingKey : 'test-a' , // control
2726 sticky : false ,
2827 } ) ;
2928 } ) ;
3029
31- afterAll ( ( ) => OpenFeature . close ( ) )
30+ afterAll ( ( ) => OpenFeature . close ( ) ) ;
3231
3332 it ( 'should resolve a boolean e2e' , async ( ) => {
3433 const client = OpenFeature . getClient ( ) ;
@@ -88,24 +87,26 @@ describe('ConfidenceServerProvider E2E tests', () => {
8887
8988 it ( 'should resolve a flag with a sticky resolve' , async ( ) => {
9089 const client = OpenFeature . getClient ( ) ;
91- const result = await client . getNumberDetails ( 'web-sdk-e2e-flag.double' , - 1 , { targetingKey : 'test-a' , sticky : true } ) ;
92-
90+ const result = await client . getNumberDetails ( 'web-sdk-e2e-flag.double' , - 1 , {
91+ targetingKey : 'test-a' ,
92+ sticky : true ,
93+ } ) ;
94+
9395 // The flag has a running experiment with a sticky assignment. The intake is paused but we should still get the sticky assignment.
9496 // If this test breaks it could mean that the experiment was removed or that the bigtable materialization was cleaned out.
9597 expect ( result . value ) . toBe ( 99.99 ) ;
9698 expect ( result . variant ) . toBe ( 'flags/web-sdk-e2e-flag/variants/sticky' ) ;
9799 expect ( result . reason ) . toBe ( 'MATCH' ) ;
98-
99100 } ) ;
100101} ) ;
101102
102- function requireEnv < const N extends string [ ] > ( ...names :N ) : Record < N [ number ] , string > {
103+ function requireEnv < const N extends string [ ] > ( ...names : N ) : Record < N [ number ] , string > {
103104 return names . reduce ( ( acc , name ) => {
104105 const value = process . env [ name ] ;
105- if ( ! value ) throw new Error ( `Missing environment variable ${ name } ` )
106+ if ( ! value ) throw new Error ( `Missing environment variable ${ name } ` ) ;
106107 return {
107108 ...acc ,
108- [ name ] : value
109+ [ name ] : value ,
109110 } ;
110- } , { } ) as Record < N [ number ] , string > ;
111- }
111+ } , { } ) as Record < N [ number ] , string > ;
112+ }
0 commit comments