Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/workflows/server-node.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,14 @@ jobs:
- name: Install contract test service dependencies
run: yarn workspace node-server-sdk-contract-tests install --no-immutable
- name: Build the test service
run: yarn contract-test-service-build
run: yarn workspace node-server-sdk-contract-tests build
- name: Launch the test service in the background
run: yarn contract-test-service 2>&1 &
run: yarn workspace node-server-sdk-contract-tests start 2>&1 &
- name: Clone and run contract tests from feat/fdv2 branch
run: |
mkdir -p /tmp/sdk-test-harness
git clone https://github.com/launchdarkly/sdk-test-harness.git /tmp/sdk-test-harness
cp ./contract-tests/testharness-suppressions-fdv2.txt /tmp/sdk-test-harness/testharness-suppressions-fdv2.txt
cp ./packages/sdk/server-node/contract-tests/testharness-suppressions-fdv2.txt /tmp/sdk-test-harness/testharness-suppressions-fdv2.txt
cd /tmp/sdk-test-harness
git checkout feat/fdv2
go build -o test-harness .
Expand All @@ -52,4 +52,4 @@ jobs:
with:
test_service_port: 8000
token: ${{ secrets.GITHUB_TOKEN }}
extra_params: '--skip-from=./contract-tests/testharness-suppressions.txt -stop-service-at-end'
extra_params: '--skip-from=./packages/sdk/server-node/contract-tests/testharness-suppressions.txt -stop-service-at-end'
17 changes: 10 additions & 7 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,6 @@ Unit tests should be implemented in a `__tests__` folder in the root of the pack

Each package has its own testing requirements and tests should be only ran for single projects.

To run the SDK contract test suite (see [`contract-tests/README.md`](./contract-tests/README.md)):
The SDK contract test suite will run the Node.js Server version of the SDK.

```bash
yarn run contract-tests
```

Tests cases should be written using `it` and should read as a sentence including the `it`:
```TypeScript
it('does not load flags prior to start', async () => {/* test code */}
Expand All @@ -69,6 +62,16 @@ describe('given a mock filesystem and memory feature store', { /* tests */})
These then combined to create an understandable test name:
`given a mock filesystem and memory feature store > it does not load flags prior to start`

### Contract tests

Contract tests are standardized tests that can be ran against all of our SDKs.
For more information [see here](https://github.com/launchdarkly/sdk-test-harness).

Note that not all packages in this monorepo have implemented contract tests. The ones that
have contract tests should have a `contract-test` directory at the root directory of their project.
For example, see the node server sdk contract test in
[`packages/sdk/server-node/contract-tests`](./packages/sdk/server-node/contract-tests/).

---
For docs on our module publishing process, see [our publishing doc](contributing/publishing.md)

Expand Down
7 changes: 0 additions & 7 deletions contract-tests/tsconfig.ref.json

This file was deleted.

5 changes: 1 addition & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"packages/shared/sdk-server-edge",
"packages/shared/akamai-edgeworker-sdk",
"packages/sdk/server-node",
"packages/sdk/server-node/contract-tests",
"packages/sdk/cloudflare",
"packages/sdk/cloudflare/example",
"packages/sdk/fastly",
Expand Down Expand Up @@ -40,7 +41,6 @@
"packages/sdk/server-ai/examples/tracked-chat",
"packages/sdk/server-ai/examples/vercel-ai",
"packages/telemetry/browser-telemetry",
"contract-tests",
"packages/sdk/combined-browser",
"packages/sdk/shopify-oxygen",
"packages/sdk/shopify-oxygen/contract-tests",
Expand All @@ -57,10 +57,7 @@
"lint:fix": "yarn run lint -- --fix",
"test": "echo Please run tests for individual packages.",
"coverage": "npm run test -- --coverage",
"contract-test-service-build": "yarn workspaces foreach -pR --topological-dev --from 'node-server-sdk-contract-tests' run build",
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Orphaned contract-test-harness script is now unused

Low Severity

The contract-test-harness script remains in package.json but is no longer used anywhere. It was previously invoked by the contract-tests script which has been removed. The script is not referenced in any GitHub workflows or other scripts, making it dead code that could confuse future developers.

Fix in Cursor Fix in Web

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there can still be some uses for this as reference to run the test harness

"contract-test-service": "yarn workspace node-server-sdk-contract-tests start",
"contract-test-harness": "curl -s https://raw.githubusercontent.com/launchdarkly/sdk-test-harness/master/downloader/run.sh \\ | VERSION=v2 PARAMS=\"-url http://localhost:8000 -debug -stop-service-at-end $TEST_HARNESS_PARAMS\" sh",
"contract-tests": "yarn contract-test-service-build && yarn contract-test-service & yarn contract-test-harness",
"prettier": "npx prettier --write \"**/*.{js,ts,tsx,json,yaml,yml,md}\" --log-level warn",
"check": "yarn && yarn prettier && yarn lint && tsc && yarn build"
},
Expand Down
21 changes: 21 additions & 0 deletions packages/sdk/server-node/contract-tests/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Node Server SDK Contract Tests

This directory contains the contract test implementation for the LaunchDarkly Node.js Server SDK using the [SDK Test Harness](https://github.com/launchdarkly/sdk-test-harness).

The contract test service is an Express server that exposes a REST API on port 8000. The test harness sends commands to this service, which creates and manages SDK client instances and executes flag evaluations, events, and other operations.

## Running Locally

From the repository root:

```bash
yarn workspace node-server-sdk-contract-tests run build
yarn workspace node-server-sdk-contract-tests run start
```

The service will listen on http://localhost:8000. You can then run the test harness from a separate terminal (see the [SDK Test Harness](https://github.com/launchdarkly/sdk-test-harness) repository for details).

Suppression files for tests that are not yet supported or are known to differ:

- `testharness-suppressions.txt` – used by the default contract test run
- `testharness-suppressions-fdv2.txt` – used when running the harness from the feat/fdv2 branch
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"license": "Apache-2.0",
"private": true,
"dependencies": {
"@launchdarkly/node-server-sdk": "*",
"@launchdarkly/node-server-sdk": "workspace:^",
"body-parser": "^1.19.0",
"express": "^4.17.1",
"got": "14.4.7"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ streaming/fdv2/reconnection state management/saves previously known state
streaming/fdv2/reconnection state management/replaces previously known state
streaming/fdv2/reconnection state management/updates previously known state
streaming/fdv2/ignores model version
streaming/fdv2/can discard partial events on errors
streaming/fdv2/can discard partial events on errors
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"extends":"./tsconfig.json","include":["src/**/*","package.json"],"compilerOptions":{"composite":true}}
2 changes: 1 addition & 1 deletion packages/sdk/server-node/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@
"stripInternal": true,
"moduleResolution": "node"
},
"exclude": ["**/*.test.ts", "dist", "node_modules", "__tests__"]
"exclude": ["**/*.test.ts", "dist", "node_modules", "__tests__", "contract-tests"]
}
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
"path": "./packages/sdk/fastly/tsconfig.ref.json"
},
{
"path": "./contract-tests/tsconfig.ref.json"
"path": "./packages/sdk/server-node/contract-tests/tsconfig.ref.json"
},
{
"path": "./packages/sdk/combined-browser/tsconfig.ref.json"
Expand Down
Loading