Skip to content

Commit 8def607

Browse files
authored
chore: loosen some test assertions, fix e2e matcher (#933)
Signed-off-by: Todd Baert <[email protected]>
1 parent 0bf2df0 commit 8def607

File tree

6 files changed

+89
-137
lines changed

6 files changed

+89
-137
lines changed
+4-12
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,17 @@
11
services:
22
flagd:
3-
build:
4-
context: test-harness
5-
dockerfile: flagd/Dockerfile
3+
image: ghcr.io/open-feature/flagd-testbed:v0.5.4
64
ports:
75
- 8013:8013
86
flagd-unstable:
9-
build:
10-
context: test-harness
11-
dockerfile: flagd/Dockerfile.unstable
7+
image: ghcr.io/open-feature/flagd-testbed-unstable:v0.5.4
128
ports:
139
- 8014:8013
1410
flagd-sync:
15-
build:
16-
context: test-harness
17-
dockerfile: sync/Dockerfile
11+
image: ghcr.io/open-feature/sync-testbed:v0.5.4
1812
ports:
1913
- 9090:9090
2014
flagd-sync-unstable:
21-
build:
22-
context: test-harness
23-
dockerfile: sync/Dockerfile.unstable
15+
image: ghcr.io/open-feature/sync-testbed-unstable:v0.5.4
2416
ports:
2517
- 9091:9090

libs/providers/flagd/src/e2e/step-definitions/flagd-json-evaluator.spec.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ const evaluateStringFlagWithContext: StepsDefinitionCallbackFunction = ({ given,
2424
flagKey = key;
2525
defaultValue = defaultVal;
2626
});
27-
and(/^a context containing a key "(.*)", with value "(.*)"$/, (key: string, value: string) => {
27+
// the below has to match quotes strings ("str") and numbers (3) to test an error input
28+
and(/^a context containing a key "(.*)", with value "?([^"]*)"?$/, (key: string, value: string) => {
2829
evaluationContext[key] = value;
2930
});
3031
then(/^the returned value should be "(.*)"$/, async (expectedValue: string) => {

libs/providers/go-feature-flag/src/lib/go-feature-flag-provider.spec.ts

+6-8
Original file line numberDiff line numberDiff line change
@@ -99,12 +99,11 @@ describe('GoFeatureFlagProvider', () => {
9999
const want = {
100100
errorCode: ErrorCode.PROVIDER_NOT_READY,
101101
flagKey: flagName,
102-
reason: StandardResolutionReasons.UNKNOWN,
103-
value: true,
104-
variant: 'trueVariation',
102+
reason: StandardResolutionReasons.ERROR,
103+
value: false,
105104
flagMetadata: {},
106105
};
107-
expect(res).toEqual(want);
106+
expect(res).toEqual(expect.objectContaining(want));
108107
});
109108
it('unknown error codes should return GENERAL code', async () => {
110109
const flagName = 'random-other-other-flag';
@@ -119,12 +118,11 @@ describe('GoFeatureFlagProvider', () => {
119118
const want = {
120119
errorCode: ErrorCode.GENERAL,
121120
flagKey: flagName,
122-
reason: StandardResolutionReasons.UNKNOWN,
123-
value: true,
124-
variant: 'trueVariation',
121+
reason: StandardResolutionReasons.ERROR,
122+
value: false,
125123
flagMetadata: {},
126124
};
127-
expect(res).toEqual(want);
125+
expect(res).toEqual(expect.objectContaining(want));
128126
});
129127
});
130128
it('should throw an error if we fail in other network errors case', async () => {

libs/providers/launchdarkly-client/src/lib/launchdarkly-client-provider.spec.ts

+44-36
Original file line numberDiff line numberDiff line change
@@ -139,13 +139,15 @@ describe('LaunchDarklyClientProvider', () => {
139139
});
140140

141141
const res = ofClient.getBooleanDetails(testFlagKey, false);
142-
expect(res).toEqual({
143-
flagKey: testFlagKey,
144-
flagMetadata: {},
145-
value: false,
146-
reason: 'ERROR',
147-
errorCode: 'TYPE_MISMATCH',
148-
});
142+
expect(res).toEqual(
143+
expect.objectContaining({
144+
flagKey: testFlagKey,
145+
flagMetadata: {},
146+
value: false,
147+
reason: 'ERROR',
148+
errorCode: 'TYPE_MISMATCH',
149+
}),
150+
);
149151
});
150152
});
151153

@@ -193,13 +195,15 @@ describe('LaunchDarklyClientProvider', () => {
193195
});
194196

195197
const res = ofClient.getNumberDetails(testFlagKey, 0);
196-
expect(res).toEqual({
197-
flagKey: testFlagKey,
198-
flagMetadata: {},
199-
value: 0,
200-
reason: 'ERROR',
201-
errorCode: 'TYPE_MISMATCH',
202-
});
198+
expect(res).toEqual(
199+
expect.objectContaining({
200+
flagKey: testFlagKey,
201+
flagMetadata: {},
202+
value: 0,
203+
reason: 'ERROR',
204+
errorCode: 'TYPE_MISMATCH',
205+
}),
206+
);
203207
});
204208
});
205209

@@ -247,13 +251,15 @@ describe('LaunchDarklyClientProvider', () => {
247251
});
248252

249253
const res = ofClient.getObjectDetails(testFlagKey, {});
250-
expect(res).toEqual({
251-
flagKey: testFlagKey,
252-
flagMetadata: {},
253-
value: {},
254-
reason: 'ERROR',
255-
errorCode: 'TYPE_MISMATCH',
256-
});
254+
expect(res).toEqual(
255+
expect.objectContaining({
256+
flagKey: testFlagKey,
257+
flagMetadata: {},
258+
value: {},
259+
reason: 'ERROR',
260+
errorCode: 'TYPE_MISMATCH',
261+
}),
262+
);
257263
});
258264
});
259265

@@ -301,13 +307,15 @@ describe('LaunchDarklyClientProvider', () => {
301307
});
302308

303309
const res = ofClient.getStringDetails(testFlagKey, 'default');
304-
expect(res).toEqual({
305-
flagKey: testFlagKey,
306-
flagMetadata: {},
307-
value: 'default',
308-
reason: 'ERROR',
309-
errorCode: 'TYPE_MISMATCH',
310-
});
310+
expect(res).toEqual(
311+
expect.objectContaining({
312+
flagKey: testFlagKey,
313+
flagMetadata: {},
314+
value: 'default',
315+
reason: 'ERROR',
316+
errorCode: 'TYPE_MISMATCH',
317+
}),
318+
);
311319
});
312320
});
313321

@@ -328,14 +336,14 @@ describe('LaunchDarklyClientProvider', () => {
328336
});
329337

330338
const res = ofClient.getObjectDetails(testFlagKey, {});
331-
expect(res).toEqual({
332-
flagKey: testFlagKey,
333-
flagMetadata: {},
334-
value: { yes: 'no' },
335-
reason: 'ERROR',
336-
errorCode: ofError,
337-
variant: undefined,
338-
});
339+
expect(res).toEqual(
340+
expect.objectContaining({
341+
flagKey: testFlagKey,
342+
flagMetadata: {},
343+
reason: 'ERROR',
344+
errorCode: ofError,
345+
}),
346+
);
339347
});
340348

341349
it('includes the variant', async () => {

package-lock.json

+32-79
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@
7878
"eslint-plugin-prettier": "^5.0.1",
7979
"fetch-mock-jest": "^1.5.1",
8080
"jest": "^29.4.1",
81-
"jest-cucumber": "4.2.0",
81+
"jest-cucumber": "^4.4.0",
8282
"jest-environment-jsdom": "^29.4.1",
8383
"jest-fetch-mock": "^3.0.3",
8484
"jest-websocket-mock": "^2.4.0",

0 commit comments

Comments
 (0)