forked from jestjs/jest
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMockStdinWatchPlugin.js
More file actions
36 lines (32 loc) · 946 Bytes
/
MockStdinWatchPlugin.js
File metadata and controls
36 lines (32 loc) · 946 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
/**
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*/
'use strict';
class MockStdinWatchPlugin {
constructor({stdin, config}) {
this._stdin = stdin;
if (typeof this._stdin.setRawMode !== 'function') {
this._stdin.setRawMode = function() {};
}
this._config = config;
}
apply(jestHooks) {
jestHooks.onTestRunComplete(() => {
const {keys} = this._config.input.shift();
keys.forEach(key => this._stdin.emit('data', key));
});
}
}
/**
* Tried re-writing this in typescript but the tests just failed
*
* I've tried exporting them the following way
* 1. "module.exports = MockStdinWatchPlugin"
* 2. "exports = MockStdinWatchPlugin"
* 3. "export default = MockStdinWatchPlugin" (in Progress)
*/
module.exports = MockStdinWatchPlugin;