@@ -4,30 +4,29 @@ 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 } ) ;
2827 } ) ;
2928
30- afterAll ( ( ) => OpenFeature . close ( ) )
29+ afterAll ( ( ) => OpenFeature . close ( ) ) ;
3130
3231 it ( 'should resolve a boolean e2e' , async ( ) => {
3332 const client = OpenFeature . getClient ( ) ;
@@ -87,24 +86,26 @@ describe('ConfidenceServerProvider E2E tests', () => {
8786
8887 it ( 'should resolve a flag with a sticky resolve' , async ( ) => {
8988 const client = OpenFeature . getClient ( ) ;
90- const result = await client . getNumberDetails ( 'web-sdk-e2e-flag.double' , - 1 , { targetingKey : 'test-a' , sticky : true } ) ;
91-
89+ const result = await client . getNumberDetails ( 'web-sdk-e2e-flag.double' , - 1 , {
90+ targetingKey : 'test-a' ,
91+ sticky : true ,
92+ } ) ;
93+
9294 // The flag has a running experiment with a sticky assignment. The intake is paused but we should still get the sticky assignment.
9395 // If this test breaks it could mean that the experiment was removed or that the bigtable materialization was cleaned out.
9496 expect ( result . value ) . toBe ( 99.99 ) ;
9597 expect ( result . variant ) . toBe ( 'flags/web-sdk-e2e-flag/variants/sticky' ) ;
9698 expect ( result . reason ) . toBe ( 'MATCH' ) ;
97-
9899 } ) ;
99100} ) ;
100101
101- function requireEnv < const N extends string [ ] > ( ...names :N ) : Record < N [ number ] , string > {
102+ function requireEnv < const N extends string [ ] > ( ...names : N ) : Record < N [ number ] , string > {
102103 return names . reduce ( ( acc , name ) => {
103104 const value = process . env [ name ] ;
104- if ( ! value ) throw new Error ( `Missing environment variable ${ name } ` )
105+ if ( ! value ) throw new Error ( `Missing environment variable ${ name } ` ) ;
105106 return {
106107 ...acc ,
107- [ name ] : value
108+ [ name ] : value ,
108109 } ;
109- } , { } ) as Record < N [ number ] , string > ;
110- }
110+ } , { } ) as Record < N [ number ] , string > ;
111+ }
0 commit comments