|
1 | 1 | import * as fs from 'fs';
|
2 | 2 |
|
3 |
| -import { AttributeType, VariationType } from '../src'; |
4 |
| -import { IAssignmentDetails } from '../src/client/eppo-client'; |
| 3 | +import { isEqual } from 'lodash'; |
| 4 | + |
| 5 | +import { AttributeType, ContextAttributes, IAssignmentDetails, VariationType } from '../src'; |
5 | 6 | import { IFlagEvaluationDetails } from '../src/flag-evaluation-details-builder';
|
6 | 7 | import { IBanditParametersResponse, IUniversalFlagConfigResponse } from '../src/http-client';
|
7 |
| -import { ContextAttributes } from '../src/types'; |
8 | 8 |
|
9 | 9 | export const TEST_DATA_DIR = './test/data/ufc/';
|
10 | 10 | export const ASSIGNMENT_TEST_DATA_DIR = TEST_DATA_DIR + 'tests/';
|
@@ -125,16 +125,17 @@ export function validateTestAssignments(
|
125 | 125 | flag: string,
|
126 | 126 | ) {
|
127 | 127 | for (const { subject, assignment } of assignments) {
|
128 |
| - if (typeof assignment !== 'object') { |
129 |
| - // the expect works well for objects, but this comparison does not |
130 |
| - if (assignment !== subject.assignment) { |
131 |
| - throw new Error( |
132 |
| - `subject ${ |
133 |
| - subject.subjectKey |
134 |
| - } was assigned ${assignment?.toString()} when expected ${subject.assignment?.toString()} for flag ${flag}`, |
135 |
| - ); |
136 |
| - } |
| 128 | + if (!isEqual(assignment, subject.assignment)) { |
| 129 | + // More friendly error message |
| 130 | + console.error( |
| 131 | + `subject ${subject.subjectKey} was assigned ${JSON.stringify( |
| 132 | + assignment, |
| 133 | + undefined, |
| 134 | + 2, |
| 135 | + )} when expected ${JSON.stringify(subject.assignment, undefined, 2)} for flag ${flag}`, |
| 136 | + ); |
137 | 137 | }
|
138 |
| - expect(subject.assignment).toEqual(assignment); |
| 138 | + |
| 139 | + expect(assignment).toEqual(subject.assignment); |
139 | 140 | }
|
140 | 141 | }
|
0 commit comments