globals.js 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.currentConfig = currentConfig;
  6. exports.currentExpectTimeout = currentExpectTimeout;
  7. exports.currentTestInfo = currentTestInfo;
  8. exports.currentlyLoadingFileSuite = currentlyLoadingFileSuite;
  9. exports.isWorkerProcess = isWorkerProcess;
  10. exports.setCurrentConfig = setCurrentConfig;
  11. exports.setCurrentExpectConfigureTimeout = setCurrentExpectConfigureTimeout;
  12. exports.setCurrentTestInfo = setCurrentTestInfo;
  13. exports.setCurrentlyLoadingFileSuite = setCurrentlyLoadingFileSuite;
  14. exports.setIsWorkerProcess = setIsWorkerProcess;
  15. /**
  16. * Copyright Microsoft Corporation. All rights reserved.
  17. *
  18. * Licensed under the Apache License, Version 2.0 (the "License");
  19. * you may not use this file except in compliance with the License.
  20. * You may obtain a copy of the License at
  21. *
  22. * http://www.apache.org/licenses/LICENSE-2.0
  23. *
  24. * Unless required by applicable law or agreed to in writing, software
  25. * distributed under the License is distributed on an "AS IS" BASIS,
  26. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  27. * See the License for the specific language governing permissions and
  28. * limitations under the License.
  29. */
  30. let currentTestInfoValue = null;
  31. function setCurrentTestInfo(testInfo) {
  32. currentTestInfoValue = testInfo;
  33. }
  34. function currentTestInfo() {
  35. return currentTestInfoValue;
  36. }
  37. let currentFileSuite;
  38. function setCurrentlyLoadingFileSuite(suite) {
  39. currentFileSuite = suite;
  40. }
  41. function currentlyLoadingFileSuite() {
  42. return currentFileSuite;
  43. }
  44. let currentExpectConfigureTimeout;
  45. function setCurrentExpectConfigureTimeout(timeout) {
  46. currentExpectConfigureTimeout = timeout;
  47. }
  48. function currentExpectTimeout(options) {
  49. var _testInfo$_projectInt, _testInfo$_projectInt2;
  50. const testInfo = currentTestInfo();
  51. if (options.timeout !== undefined) return options.timeout;
  52. if (currentExpectConfigureTimeout !== undefined) return currentExpectConfigureTimeout;
  53. let defaultExpectTimeout = testInfo === null || testInfo === void 0 ? void 0 : (_testInfo$_projectInt = testInfo._projectInternal) === null || _testInfo$_projectInt === void 0 ? void 0 : (_testInfo$_projectInt2 = _testInfo$_projectInt.expect) === null || _testInfo$_projectInt2 === void 0 ? void 0 : _testInfo$_projectInt2.timeout;
  54. if (typeof defaultExpectTimeout === 'undefined') defaultExpectTimeout = 5000;
  55. return defaultExpectTimeout;
  56. }
  57. let _isWorkerProcess = false;
  58. function setIsWorkerProcess() {
  59. _isWorkerProcess = true;
  60. }
  61. function isWorkerProcess() {
  62. return _isWorkerProcess;
  63. }
  64. let currentConfigValue = null;
  65. function setCurrentConfig(config) {
  66. currentConfigValue = config;
  67. }
  68. function currentConfig() {
  69. return currentConfigValue;
  70. }