varsnap 1.8.3 → 1.8.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- export declare const version = "1.8.3";
1
+ export declare const version = "1.8.5";
2
2
  export declare const clientName: string;
3
3
  export interface Config {
4
4
  varsnap: boolean;
@@ -8,8 +8,8 @@ export interface Config {
8
8
  consumerToken?: string;
9
9
  logger?: Logger;
10
10
  }
11
- declare type ConfigKeys = keyof Config;
12
- declare type rawJSONObject = ConsumeSnapResponse | ProduceTrialResponse | TrialGroupRequest | TrialGroupResponse | Record<string, string>;
11
+ type ConfigKeys = keyof Config;
12
+ type rawJSONObject = ConsumeSnapResponse | ProduceTrialResponse | TrialGroupRequest | TrialGroupResponse | Record<string, string>;
13
13
  export interface Logger {
14
14
  debug(s: string): void;
15
15
  log(s: string): void;
@@ -66,8 +66,8 @@ export declare class Consumer {
66
66
  reportLog(snapID: string, inputs: TargetFunctionInput[], prodOutputs: TargetFunctionOutput, localOutputs: TargetFunctionOutput, matches: boolean, trialURL: string | boolean): void;
67
67
  reportTrialGroup(trialGroup: TrialGroupResponse): void;
68
68
  }
69
- export declare type TargetFunctionInput = any;
70
- export declare type TargetFunctionOutput = any;
69
+ export type TargetFunctionInput = any;
70
+ export type TargetFunctionOutput = any;
71
71
  export interface TargetFunction {
72
72
  (...args: TargetFunctionInput[]): TargetFunctionOutput;
73
73
  }
@@ -7,7 +7,7 @@ const produceURL = 'https://www.varsnap.com/api/snap/produce/';
7
7
  const consumeURL = 'https://www.varsnap.com/api/snap/consume/';
8
8
  const produceTrialURL = 'https://www.varsnap.com/api/trial/produce/';
9
9
  const trialGroupURL = 'https://www.varsnap.com/api/trial_group/';
10
- exports.version = '1.8.3';
10
+ exports.version = '1.8.5';
11
11
  exports.clientName = 'javascript.' + exports.version;
12
12
  const defaultConfig = {
13
13
  varsnap: true,
@@ -282,7 +282,6 @@ class Consumer {
282
282
  });
283
283
  trialPromises.push(trialPromise);
284
284
  }
285
- this.reportTrialGroup(trialGroup);
286
285
  return trialPromises;
287
286
  }).then((trialPromises) => {
288
287
  return Promise.all(trialPromises).then((results) => {
@@ -320,6 +319,9 @@ class Consumer {
320
319
  return report;
321
320
  }
322
321
  reportLog(snapID, inputs, prodOutputs, localOutputs, matches, trialURL) {
322
+ if (matches) {
323
+ return;
324
+ }
323
325
  Util.log(this.config, '');
324
326
  Util.log(this.config, 'Testing with Varsnap uuid: ' + snapID);
325
327
  Util.log(this.config, 'Signature: ' + this.signature);
@@ -399,8 +401,9 @@ function getTrialGroup(consumerConfig) {
399
401
  return response;
400
402
  }).catch((error) => {
401
403
  let errorMessage = '';
402
- if (error && error.response && error.response.data && error.response.data.error) {
403
- errorMessage = error.response.data.error;
404
+ if (error && error.response && error.response.data) {
405
+ const response = error.response.data;
406
+ errorMessage = response.error;
404
407
  }
405
408
  else {
406
409
  errorMessage = error.toString();
@@ -427,6 +430,9 @@ function runTests() {
427
430
  const testPromise = consumer.consume(trialGroup);
428
431
  testPromises.push(testPromise);
429
432
  }
433
+ if (consumers.length > 0) {
434
+ consumers[0].reportTrialGroup(trialGroup);
435
+ }
430
436
  return Promise.all(testPromises);
431
437
  }).then((results) => {
432
438
  const allPass = results.every((result) => result);