web 3d图形渲染器
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

107 lines
2.6 KiB

  1. 'use strict';
  2. Object.defineProperty(exports, '__esModule', {
  3. value: true
  4. });
  5. exports.default = void 0;
  6. function _chalk() {
  7. const data = _interopRequireDefault(require('chalk'));
  8. _chalk = function () {
  9. return data;
  10. };
  11. return data;
  12. }
  13. function _terminalLink() {
  14. const data = _interopRequireDefault(require('terminal-link'));
  15. _terminalLink = function () {
  16. return data;
  17. };
  18. return data;
  19. }
  20. function _jestUtil() {
  21. const data = require('jest-util');
  22. _jestUtil = function () {
  23. return data;
  24. };
  25. return data;
  26. }
  27. var _utils = require('./utils');
  28. function _interopRequireDefault(obj) {
  29. return obj && obj.__esModule ? obj : {default: obj};
  30. }
  31. /**
  32. * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
  33. *
  34. * This source code is licensed under the MIT license found in the
  35. * LICENSE file in the root directory of this source tree.
  36. */
  37. const LONG_TEST_COLOR = _chalk().default.reset.bold.bgRed; // Explicitly reset for these messages since they can get written out in the
  38. // middle of error logging
  39. const FAIL_TEXT = 'FAIL';
  40. const PASS_TEXT = 'PASS';
  41. const FAIL = _chalk().default.supportsColor
  42. ? _chalk().default.reset.inverse.bold.red(` ${FAIL_TEXT} `)
  43. : FAIL_TEXT;
  44. const PASS = _chalk().default.supportsColor
  45. ? _chalk().default.reset.inverse.bold.green(` ${PASS_TEXT} `)
  46. : PASS_TEXT;
  47. var _default = (result, globalConfig, projectConfig) => {
  48. var _result$perfStats;
  49. const testPath = result.testFilePath;
  50. const formattedTestPath = (0, _utils.formatTestPath)(
  51. projectConfig ? projectConfig : globalConfig,
  52. testPath
  53. );
  54. const fileLink = (0, _terminalLink().default)(
  55. formattedTestPath,
  56. `file://${testPath}`,
  57. {
  58. fallback: () => formattedTestPath
  59. }
  60. );
  61. const status =
  62. result.numFailingTests > 0 || result.testExecError ? FAIL : PASS;
  63. const testDetail = [];
  64. if (
  65. (_result$perfStats = result.perfStats) === null ||
  66. _result$perfStats === void 0
  67. ? void 0
  68. : _result$perfStats.slow
  69. ) {
  70. const runTime = result.perfStats.runtime / 1000;
  71. testDetail.push(LONG_TEST_COLOR((0, _jestUtil().formatTime)(runTime, 0)));
  72. }
  73. if (result.memoryUsage) {
  74. const toMB = bytes => Math.floor(bytes / 1024 / 1024);
  75. testDetail.push(`${toMB(result.memoryUsage)} MB heap size`);
  76. }
  77. const projectDisplayName =
  78. projectConfig && projectConfig.displayName
  79. ? (0, _utils.printDisplayName)(projectConfig) + ' '
  80. : '';
  81. return (
  82. `${status} ${projectDisplayName}${fileLink}` +
  83. (testDetail.length ? ` (${testDetail.join(', ')})` : '')
  84. );
  85. };
  86. exports.default = _default;