Skip to content

Commit

Permalink
fix: Ensure browser contract tests run during top-level build. (#589)
Browse files Browse the repository at this point in the history
  • Loading branch information
kinyoklion authored Sep 23, 2024
1 parent 7131e69 commit 7dfb14d
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 15 deletions.
3 changes: 2 additions & 1 deletion packages/sdk/browser/contract-tests/entity/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
"type": "module",
"description": "Contract test service implementation for @launchdarkly/js-client-sdk",
"scripts": {
"start": "vite --open=true",
"start": "tsc --noEmit && vite --open=true",
"build": "tsc --noEmit && vite build",
"lint": "eslint ./src",
"prettier": "prettier --write '**/*.@(js|ts|tsx|json|css)' --ignore-path ../../../../.prettierignore"
},
Expand Down
16 changes: 4 additions & 12 deletions packages/sdk/browser/contract-tests/entity/src/ClientEntity.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
import {
AutoEnvAttributes,
init,
LDClient,
LDLogger,
LDOptions,
} from '@launchdarkly/js-client-sdk';
import { init, LDClient, LDLogger, LDOptions } from '@launchdarkly/js-client-sdk';

import { CommandParams, CommandType, ValueType } from './CommandParams';
import { CreateInstanceParams, SDKConfigParams } from './ConfigParams';
Expand Down Expand Up @@ -72,6 +66,8 @@ function makeSdkConfig(options: SDKConfigParams, tag: string) {
};
}

cf.fetchGoals = false;

return cf;
}

Expand Down Expand Up @@ -205,11 +201,7 @@ export async function newSdkClientEntity(options: CreateInstanceParams) {
options.configuration.clientSide?.initialUser ||
options.configuration.clientSide?.initialContext ||
makeDefaultInitialContext();
const client = init(
options.configuration.credential || 'unknown-env-id',
AutoEnvAttributes.Disabled, // TODO: Determine capability.
sdkConfig,
);
const client = init(options.configuration.credential || 'unknown-env-id', sdkConfig);
let failed = false;
try {
await Promise.race([
Expand Down
5 changes: 3 additions & 2 deletions packages/sdk/browser/src/BrowserClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
LDContext,
Platform,
} from '@launchdarkly/js-client-sdk-common';
import { LDIdentifyOptions } from '@launchdarkly/js-client-sdk-common/dist/api/LDIdentifyOptions';

import GoalManager from './goals/GoalManager';
import { Goal, isClick } from './goals/Goals';
Expand Down Expand Up @@ -135,8 +136,8 @@ export class BrowserClient extends LDClientImpl {
};
}

override async identify(context: LDContext): Promise<void> {
await super.identify(context);
override async identify(context: LDContext, identifyOptions?: LDIdentifyOptions): Promise<void> {
await super.identify(context, identifyOptions);
this.goalManager?.startTracking();
}
}

0 comments on commit 7dfb14d

Please sign in to comment.