UNPKG

1.46 kBJavaScriptView Raw
1'use strict';
2
3Object.defineProperty(exports, '__esModule', {
4 value: true
5});
6exports.default = void 0;
7
8function _defineProperty(obj, key, value) {
9 if (key in obj) {
10 Object.defineProperty(obj, key, {
11 value: value,
12 enumerable: true,
13 configurable: true,
14 writable: true
15 });
16 } else {
17 obj[key] = value;
18 }
19 return obj;
20}
21
22/**
23 * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
24 *
25 * This source code is licensed under the MIT license found in the
26 * LICENSE file in the root directory of this source tree.
27 */
28class FailedTestsCache {
29 constructor() {
30 _defineProperty(this, '_enabledTestsMap', void 0);
31 }
32
33 filterTests(tests) {
34 const enabledTestsMap = this._enabledTestsMap;
35
36 if (!enabledTestsMap) {
37 return tests;
38 }
39
40 return tests.filter(testResult => enabledTestsMap[testResult.path]);
41 }
42
43 setTestResults(testResults) {
44 this._enabledTestsMap = (testResults || [])
45 .filter(testResult => testResult.numFailingTests)
46 .reduce((suiteMap, testResult) => {
47 suiteMap[testResult.testFilePath] = testResult.testResults
48 .filter(test => test.status === 'failed')
49 .reduce((testMap, test) => {
50 testMap[test.fullName] = true;
51 return testMap;
52 }, {});
53 return suiteMap;
54 }, {});
55 this._enabledTestsMap = Object.freeze(this._enabledTestsMap);
56 }
57}
58
59exports.default = FailedTestsCache;