diff options
author | Joel Kronqvist <work.joelkronqvist@pm.me> | 2022-03-11 20:46:06 +0200 |
---|---|---|
committer | Joel Kronqvist <work.joelkronqvist@pm.me> | 2022-03-11 20:46:06 +0200 |
commit | 080c5819d87b933816d724a83f3bf4f1686770a7 (patch) | |
tree | 4a2ccc68b27edf7d4cbc586c932cc7542b655e19 /node_modules/@jest/core/build/plugins/FailedTestsInteractive.js | |
parent | 5ac7049a9d30733165cc212dee308163c2a14644 (diff) | |
parent | d003b82235a9329f912522a2f70aa950dfce4998 (diff) | |
download | LYLLRuoka-080c5819d87b933816d724a83f3bf4f1686770a7.tar.gz LYLLRuoka-080c5819d87b933816d724a83f3bf4f1686770a7.zip |
Merge branch 'master' of https://github.com/JoelHMikael/FoodJS
Updating remote changes
Diffstat (limited to 'node_modules/@jest/core/build/plugins/FailedTestsInteractive.js')
-rw-r--r-- | node_modules/@jest/core/build/plugins/FailedTestsInteractive.js | 135 |
1 files changed, 135 insertions, 0 deletions
diff --git a/node_modules/@jest/core/build/plugins/FailedTestsInteractive.js b/node_modules/@jest/core/build/plugins/FailedTestsInteractive.js new file mode 100644 index 0000000..a830abe --- /dev/null +++ b/node_modules/@jest/core/build/plugins/FailedTestsInteractive.js @@ -0,0 +1,135 @@ +'use strict'; + +Object.defineProperty(exports, '__esModule', { + value: true +}); +exports.default = void 0; + +function _jestWatcher() { + const data = require('jest-watcher'); + + _jestWatcher = function () { + return data; + }; + + return data; +} + +var _FailedTestsInteractiveMode = _interopRequireDefault( + require('../FailedTestsInteractiveMode') +); + +function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : {default: obj}; +} + +function _defineProperty(obj, key, value) { + if (key in obj) { + Object.defineProperty(obj, key, { + value: value, + enumerable: true, + configurable: true, + writable: true + }); + } else { + obj[key] = value; + } + return obj; +} + +class FailedTestsInteractivePlugin extends _jestWatcher().BaseWatchPlugin { + constructor(...args) { + super(...args); + + _defineProperty(this, '_failedTestAssertions', void 0); + + _defineProperty( + this, + '_manager', + new _FailedTestsInteractiveMode.default(this._stdout) + ); + } + + apply(hooks) { + hooks.onTestRunComplete(results => { + this._failedTestAssertions = this.getFailedTestAssertions(results); + if (this._manager.isActive()) this._manager.updateWithResults(results); + }); + } + + getUsageInfo() { + var _this$_failedTestAsse; + + if ( + (_this$_failedTestAsse = this._failedTestAssertions) !== null && + _this$_failedTestAsse !== void 0 && + _this$_failedTestAsse.length + ) { + return { + key: 'i', + prompt: 'run failing tests interactively' + }; + } + + return null; + } + + onKey(key) { + if (this._manager.isActive()) { + this._manager.put(key); + } + } + + run(_, updateConfigAndRun) { + return new Promise(resolve => { + if ( + !this._failedTestAssertions || + this._failedTestAssertions.length === 0 + ) { + resolve(); + return; + } + + this._manager.run(this._failedTestAssertions, failure => { + updateConfigAndRun({ + mode: 'watch', + testNamePattern: failure ? `^${failure.fullName}$` : '', + testPathPattern: + (failure === null || failure === void 0 ? void 0 : failure.path) || + '' + }); + + if (!this._manager.isActive()) { + resolve(); + } + }); + }); + } + + getFailedTestAssertions(results) { + const failedTestPaths = []; + + if ( + // skip if no failed tests + results.numFailedTests === 0 || // skip if missing test results + !results.testResults || // skip if unmatched snapshots are present + results.snapshot.unmatched + ) { + return failedTestPaths; + } + + results.testResults.forEach(testResult => { + testResult.testResults.forEach(result => { + if (result.status === 'failed') { + failedTestPaths.push({ + fullName: result.fullName, + path: testResult.testFilePath + }); + } + }); + }); + return failedTestPaths; + } +} + +exports.default = FailedTestsInteractivePlugin; |