UNPKG

1.21 kBJavaScriptView Raw
1'use strict';
2
3Object.defineProperty(exports, '__esModule', {
4 value: true
5});
6exports.default = void 0;
7/**
8 * Copyright (c) Meta Platforms, Inc. and affiliates.
9 *
10 * This source code is licensed under the MIT license found in the
11 * LICENSE file in the root directory of this source tree.
12 */
13
14class FailedTestsCache {
15 _enabledTestsMap;
16 filterTests(tests) {
17 const enabledTestsMap = this._enabledTestsMap;
18 if (!enabledTestsMap) {
19 return tests;
20 }
21 return tests.filter(testResult => enabledTestsMap[testResult.path]);
22 }
23 setTestResults(testResults) {
24 this._enabledTestsMap = (testResults || []).reduce(
25 (suiteMap, testResult) => {
26 if (!testResult.numFailingTests) {
27 return suiteMap;
28 }
29 suiteMap[testResult.testFilePath] = testResult.testResults.reduce(
30 (testMap, test) => {
31 if (test.status !== 'failed') {
32 return testMap;
33 }
34 testMap[test.fullName] = true;
35 return testMap;
36 },
37 {}
38 );
39 return suiteMap;
40 },
41 {}
42 );
43 this._enabledTestsMap = Object.freeze(this._enabledTestsMap);
44 }
45}
46exports.default = FailedTestsCache;