1 | 'use strict';
|
2 |
|
3 | Object.defineProperty(exports, '__esModule', {
|
4 | value: true
|
5 | });
|
6 | exports.default = void 0;
|
7 |
|
8 | function _jestWatcher() {
|
9 | const data = require('jest-watcher');
|
10 |
|
11 | _jestWatcher = function () {
|
12 | return data;
|
13 | };
|
14 |
|
15 | return data;
|
16 | }
|
17 |
|
18 | function _defineProperty(obj, key, value) {
|
19 | if (key in obj) {
|
20 | Object.defineProperty(obj, key, {
|
21 | value: value,
|
22 | enumerable: true,
|
23 | configurable: true,
|
24 | writable: true
|
25 | });
|
26 | } else {
|
27 | obj[key] = value;
|
28 | }
|
29 | return obj;
|
30 | }
|
31 |
|
32 | class UpdateSnapshotsPlugin extends _jestWatcher().BaseWatchPlugin {
|
33 | constructor(options) {
|
34 | super(options);
|
35 |
|
36 | _defineProperty(this, '_hasSnapshotFailure', void 0);
|
37 |
|
38 | _defineProperty(this, 'isInternal', void 0);
|
39 |
|
40 | this.isInternal = true;
|
41 | this._hasSnapshotFailure = false;
|
42 | }
|
43 |
|
44 | run(_globalConfig, updateConfigAndRun) {
|
45 | updateConfigAndRun({
|
46 | updateSnapshot: 'all'
|
47 | });
|
48 | return Promise.resolve(false);
|
49 | }
|
50 |
|
51 | apply(hooks) {
|
52 | hooks.onTestRunComplete(results => {
|
53 | this._hasSnapshotFailure = results.snapshot.failure;
|
54 | });
|
55 | }
|
56 |
|
57 | getUsageInfo() {
|
58 | if (this._hasSnapshotFailure) {
|
59 | return {
|
60 | key: 'u',
|
61 | prompt: 'update failing snapshots'
|
62 | };
|
63 | }
|
64 |
|
65 | return null;
|
66 | }
|
67 | }
|
68 |
|
69 | var _default = UpdateSnapshotsPlugin;
|
70 | exports.default = _default;
|