@bigbinary/neeto-playwright-reporter 1.5.2 → 1.5.3

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.
package/index.js CHANGED
@@ -789,10 +789,233 @@ function _includes(a, list) {
789
789
  return _indexOf(list, a, 0) >= 0;
790
790
  }
791
791
 
792
+ function _map(fn, functor) {
793
+ var idx = 0;
794
+ var len = functor.length;
795
+ var result = Array(len);
796
+
797
+ while (idx < len) {
798
+ result[idx] = fn(functor[idx]);
799
+ idx += 1;
800
+ }
801
+
802
+ return result;
803
+ }
804
+
805
+ function _arrayReduce(reducer, acc, list) {
806
+ var index = 0;
807
+ var length = list.length;
808
+
809
+ while (index < length) {
810
+ acc = reducer(acc, list[index]);
811
+ index += 1;
812
+ }
813
+
814
+ return acc;
815
+ }
816
+
792
817
  function _isObject(x) {
793
818
  return Object.prototype.toString.call(x) === '[object Object]';
794
819
  }
795
820
 
821
+ var XMap =
822
+ /*#__PURE__*/
823
+ function () {
824
+ function XMap(f, xf) {
825
+ this.xf = xf;
826
+ this.f = f;
827
+ }
828
+
829
+ XMap.prototype['@@transducer/init'] = _xfBase.init;
830
+ XMap.prototype['@@transducer/result'] = _xfBase.result;
831
+
832
+ XMap.prototype['@@transducer/step'] = function (result, input) {
833
+ return this.xf['@@transducer/step'](result, this.f(input));
834
+ };
835
+
836
+ return XMap;
837
+ }();
838
+
839
+ var _xmap = function _xmap(f) {
840
+ return function (xf) {
841
+ return new XMap(f, xf);
842
+ };
843
+ };
844
+
845
+ /**
846
+ * Takes a function and
847
+ * a [functor](https://github.com/fantasyland/fantasy-land#functor),
848
+ * applies the function to each of the functor's values, and returns
849
+ * a functor of the same shape.
850
+ *
851
+ * Ramda provides suitable `map` implementations for `Array` and `Object`,
852
+ * so this function may be applied to `[1, 2, 3]` or `{x: 1, y: 2, z: 3}`.
853
+ *
854
+ * Dispatches to the `map` method of the second argument, if present.
855
+ *
856
+ * Acts as a transducer if a transformer is given in list position.
857
+ *
858
+ * Also treats functions as functors and will compose them together.
859
+ *
860
+ * @func
861
+ * @memberOf R
862
+ * @since v0.1.0
863
+ * @category List
864
+ * @sig Functor f => (a -> b) -> f a -> f b
865
+ * @param {Function} fn The function to be called on every element of the input `list`.
866
+ * @param {Array} list The list to be iterated over.
867
+ * @return {Array} The new list.
868
+ * @see R.transduce, R.addIndex, R.pluck, R.project
869
+ * @example
870
+ *
871
+ * const double = x => x * 2;
872
+ *
873
+ * R.map(double, [1, 2, 3]); //=> [2, 4, 6]
874
+ *
875
+ * R.map(double, {x: 1, y: 2, z: 3}); //=> {x: 2, y: 4, z: 6}
876
+ * @symb R.map(f, [a, b]) = [f(a), f(b)]
877
+ * @symb R.map(f, { x: a, y: b }) = { x: f(a), y: f(b) }
878
+ * @symb R.map(f, functor_o) = functor_o.map(f)
879
+ */
880
+
881
+ var map =
882
+ /*#__PURE__*/
883
+ _curry2(
884
+ /*#__PURE__*/
885
+ _dispatchable(['fantasy-land/map', 'map'], _xmap, function map(fn, functor) {
886
+ switch (Object.prototype.toString.call(functor)) {
887
+ case '[object Function]':
888
+ return curryN(functor.length, function () {
889
+ return fn.call(this, functor.apply(this, arguments));
890
+ });
891
+
892
+ case '[object Object]':
893
+ return _arrayReduce(function (acc, key) {
894
+ acc[key] = fn(functor[key]);
895
+ return acc;
896
+ }, {}, keys(functor));
897
+
898
+ default:
899
+ return _map(fn, functor);
900
+ }
901
+ }));
902
+
903
+ /**
904
+ * Determine if the passed argument is an integer.
905
+ *
906
+ * @private
907
+ * @param {*} n
908
+ * @category Type
909
+ * @return {Boolean}
910
+ */
911
+ var _isInteger = Number.isInteger || function _isInteger(n) {
912
+ return n << 0 === n;
913
+ };
914
+
915
+ function _isString(x) {
916
+ return Object.prototype.toString.call(x) === '[object String]';
917
+ }
918
+
919
+ /**
920
+ * Returns the nth element of the given list or string. If n is negative the
921
+ * element at index length + n is returned.
922
+ *
923
+ * @func
924
+ * @memberOf R
925
+ * @since v0.1.0
926
+ * @category List
927
+ * @sig Number -> [a] -> a | Undefined
928
+ * @sig Number -> String -> String
929
+ * @param {Number} offset
930
+ * @param {*} list
931
+ * @return {*}
932
+ * @example
933
+ *
934
+ * const list = ['foo', 'bar', 'baz', 'quux'];
935
+ * R.nth(1, list); //=> 'bar'
936
+ * R.nth(-1, list); //=> 'quux'
937
+ * R.nth(-99, list); //=> undefined
938
+ *
939
+ * R.nth(2, 'abc'); //=> 'c'
940
+ * R.nth(3, 'abc'); //=> ''
941
+ * @symb R.nth(-1, [a, b, c]) = c
942
+ * @symb R.nth(0, [a, b, c]) = a
943
+ * @symb R.nth(1, [a, b, c]) = b
944
+ */
945
+
946
+ var nth =
947
+ /*#__PURE__*/
948
+ _curry2(function nth(offset, list) {
949
+ var idx = offset < 0 ? list.length + offset : offset;
950
+ return _isString(list) ? list.charAt(idx) : list[idx];
951
+ });
952
+
953
+ /**
954
+ * Returns a function that when supplied an object returns the indicated
955
+ * property of that object, if it exists.
956
+ *
957
+ * @func
958
+ * @memberOf R
959
+ * @since v0.1.0
960
+ * @category Object
961
+ * @typedefn Idx = String | Int | Symbol
962
+ * @sig Idx -> {s: a} -> a | Undefined
963
+ * @param {String|Number} p The property name or array index
964
+ * @param {Object} obj The object to query
965
+ * @return {*} The value at `obj.p`.
966
+ * @see R.path, R.props, R.pluck, R.project, R.nth
967
+ * @example
968
+ *
969
+ * R.prop('x', {x: 100}); //=> 100
970
+ * R.prop('x', {}); //=> undefined
971
+ * R.prop(0, [100]); //=> 100
972
+ * R.compose(R.inc, R.prop('x'))({ x: 3 }) //=> 4
973
+ */
974
+
975
+ var prop =
976
+ /*#__PURE__*/
977
+ _curry2(function prop(p, obj) {
978
+ if (obj == null) {
979
+ return;
980
+ }
981
+
982
+ return _isInteger(p) ? nth(p, obj) : obj[p];
983
+ });
984
+
985
+ /**
986
+ * Returns a new list by plucking the same named property off all objects in
987
+ * the list supplied.
988
+ *
989
+ * `pluck` will work on
990
+ * any [functor](https://github.com/fantasyland/fantasy-land#functor) in
991
+ * addition to arrays, as it is equivalent to `R.map(R.prop(k), f)`.
992
+ *
993
+ * @func
994
+ * @memberOf R
995
+ * @since v0.1.0
996
+ * @category List
997
+ * @sig Functor f => k -> f {k: v} -> f v
998
+ * @param {Number|String} key The key name to pluck off of each object.
999
+ * @param {Array} f The array or functor to consider.
1000
+ * @return {Array} The list of values for the given key.
1001
+ * @see R.project, R.prop, R.props
1002
+ * @example
1003
+ *
1004
+ * var getAges = R.pluck('age');
1005
+ * getAges([{name: 'fred', age: 29}, {name: 'wilma', age: 27}]); //=> [29, 27]
1006
+ *
1007
+ * R.pluck(0, [[1, 2], [3, 4]]); //=> [1, 3]
1008
+ * R.pluck('val', {a: {val: 3}, b: {val: 5}}); //=> {a: 3, b: 5}
1009
+ * @symb R.pluck('x', [{x: 1, y: 2}, {x: 3, y: 4}, {x: 5, y: 6}]) = [1, 3, 5]
1010
+ * @symb R.pluck(0, [[1, 2], [3, 4], [5, 6]]) = [1, 3, 5]
1011
+ */
1012
+
1013
+ var pluck =
1014
+ /*#__PURE__*/
1015
+ _curry2(function pluck(p, list) {
1016
+ return map(prop(p), list);
1017
+ });
1018
+
796
1019
  /**
797
1020
  * Checks if the input value is `null` or `undefined`.
798
1021
  *
@@ -21206,6 +21429,10 @@ const onBegin = async (self, config, rootSuite) => {
21206
21429
  let attempts = {};
21207
21430
  self.totalTestCount = rootSuite.allTests().length;
21208
21431
  self.rootDir = config.rootDir;
21432
+ if (self.totalTestCount === 0) {
21433
+ consoleLogFormatted.error(ERRORS.onBegin.noTestsToReport);
21434
+ return;
21435
+ }
21209
21436
  try {
21210
21437
  const runDetails = {
21211
21438
  commitId: getCurrentCommitSha(),
@@ -21219,10 +21446,6 @@ const onBegin = async (self, config, rootSuite) => {
21219
21446
  };
21220
21447
  await runsApi.create(runDetails);
21221
21448
  self.hasRunStarted = true;
21222
- if (self.totalTestCount === 0) {
21223
- consoleLogFormatted.error(ERRORS.onBegin.noTestsToReport);
21224
- return;
21225
- }
21226
21449
  ({ data: attempts } = await testEntitiesApi.create(self.ciBuildId, {
21227
21450
  testEntities: getInitializerData(config, rootSuite),
21228
21451
  shard: currentShard,
@@ -21279,7 +21502,7 @@ const onTestBegin = async (self, test, { retry }) => {
21279
21502
  const { title, repeatEachIndex } = test;
21280
21503
  const { rootDir, currentShard, ciBuildId } = self;
21281
21504
  const { historyId } = getTestData(test, rootDir);
21282
- const startedAt = new Date();
21505
+ const startedAt = new Date().toString();
21283
21506
  const attemptIndex = joinHyphenCase(retry, repeatEachIndex);
21284
21507
  self.unreportedAttemptCount++;
21285
21508
  consoleLogFormatted.invertBackground(MESSAGES.onTestBegin.startingTest(title, historyId));
@@ -21287,7 +21510,7 @@ const onTestBegin = async (self, test, { retry }) => {
21287
21510
  await waitUntilCondition(() => { var _a, _b; return (_b = (_a = self.attempts) === null || _a === void 0 ? void 0 : _a[historyId]) === null || _b === void 0 ? void 0 : _b[FIRST_ATTEMPT_INDEX]; });
21288
21511
  const attemptsPayload = {
21289
21512
  status: "running",
21290
- startedAt: startedAt.toString(),
21513
+ startedAt,
21291
21514
  shard: currentShard,
21292
21515
  repeatEachIndex,
21293
21516
  };
@@ -21295,7 +21518,7 @@ const onTestBegin = async (self, test, { retry }) => {
21295
21518
  await attemptsApi.update(ciBuildId, historyId, self.attempts[historyId][FIRST_ATTEMPT_INDEX], attemptsPayload);
21296
21519
  }
21297
21520
  else {
21298
- const { data: { attemptId: attemptId }, } = await attemptsApi.create(ciBuildId, historyId, attemptsPayload);
21521
+ const { data: { attemptId }, } = await attemptsApi.create(ciBuildId, historyId, attemptsPayload);
21299
21522
  self.attempts = mergeDeepRight(self.attempts, {
21300
21523
  [historyId]: { [attemptIndex]: attemptId },
21301
21524
  });
@@ -22686,15 +22909,22 @@ const onTestEnd = async (self, testCase, { status, duration, errors, error, retr
22686
22909
  errorSnippet: error && generateErrorReport(error),
22687
22910
  };
22688
22911
  consoleLogFormatted.underline(title);
22689
- const bars = await Promise.all(attachments.map(async ({ name, path, body, contentType }) => {
22912
+ const files = attachments
22913
+ .map(({ name, path, body, contentType }) => {
22690
22914
  if (VALID_ASSET_TYPES.includes(name)) {
22691
22915
  const buffer = path ? readFileSync(path) : body;
22692
22916
  const fileName = generateFileName(path, name, contentType);
22693
22917
  const { file, ...metadata } = getFileData(buffer, contentType, fileName);
22694
- const { data: { signedId, directUpload: directUploadMetaData }, } = await getDirectUploadURL(metadata);
22695
- testResult[`${name}s`].push(signedId);
22696
- return uploadToS3(file, directUploadMetaData, `${title} - ${name}`);
22918
+ return { file, metadata, name };
22697
22919
  }
22920
+ })
22921
+ .filter((fileData) => fileData !== undefined);
22922
+ const payload = { metadata: pluck("metadata", files) };
22923
+ const { data: directUploadResponses } = await getDirectUploadURL(payload);
22924
+ const bars = await Promise.all(directUploadResponses.map(async ({ signedId, directUpload }, index) => {
22925
+ var _a, _b;
22926
+ testResult[`${(_a = files[index]) === null || _a === void 0 ? void 0 : _a.name}s`].push(signedId);
22927
+ return uploadToS3(files[index].file, directUpload, `${title} - ${(_b = files[index]) === null || _b === void 0 ? void 0 : _b.name}`);
22698
22928
  }));
22699
22929
  self.progressBars.push(...bars);
22700
22930
  await waitUntilCondition(() => self.attempts[historyId][attemptIndex]);