1 | 'use strict';
|
2 |
|
3 | Object.defineProperty(exports, '__esModule', {
|
4 | value: true
|
5 | });
|
6 | exports.default = void 0;
|
7 |
|
8 | function _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 |
|
24 |
|
25 |
|
26 |
|
27 |
|
28 | class 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 | updateConfig(globalConfig) {
|
59 | if (!this._enabledTestsMap) {
|
60 | return globalConfig;
|
61 | }
|
62 |
|
63 | const newConfig = {...globalConfig};
|
64 | newConfig.enabledTestsMap = this._enabledTestsMap;
|
65 | return Object.freeze(newConfig);
|
66 | }
|
67 | }
|
68 |
|
69 | exports.default = FailedTestsCache;
|