Skip to content
This repository was archived by the owner on Feb 12, 2019. It is now read-only.

Commit ee5f328

Browse files
Rework
1 parent aa78a7c commit ee5f328

8 files changed

Lines changed: 298 additions & 140 deletions

File tree

README.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,6 @@ TestCafe Live watches files that you pass as the `src` argument and files that a
5757

5858
When the tests are done, browsers stay on the last opened page so you can work with it and explore it by using the browser's developer tools.
5959

60-
See the [VIDEO]().
61-
6260
### Commands
6361

6462
- ctrl+s - stop current run;

lib/controller.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,8 @@ class Controller extends EventEmitter {
103103
this.restarting = true;
104104

105105
this.stop().then(() => {
106+
logger.testsFinished();
107+
106108
this.restarting = false;
107109
this.running = false;
108110

lib/index.js

Lines changed: 26 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,39 @@
11
'use strict';
22

3-
(() => {
4-
const CLIArgumentParser = require('testcafe/lib/cli/argument-parser');
5-
const exitHook = require('async-exit-hook');
6-
const keypress = require('keypress');
7-
const controller = require('./controller');
3+
const CLIArgumentParser = require('testcafe/lib/cli/argument-parser');
4+
const exitHook = require('async-exit-hook');
5+
const keypress = require('keypress');
6+
const controller = require('./controller');
87

9-
const tcArguments = new CLIArgumentParser();
8+
const tcArguments = new CLIArgumentParser();
109

11-
exitHook(cb => {
12-
controller.exit()
13-
.then(cb);
14-
});
10+
exitHook(cb => {
11+
controller.exit()
12+
.then(cb);
13+
});
1514

16-
tcArguments.parse(process.argv)
17-
.then(() => controller.init(tcArguments));
15+
tcArguments.parse(process.argv)
16+
.then(() => controller.init(tcArguments));
1817

1918

20-
// Listen commands
21-
keypress(process.stdin);
19+
// Listen commands
20+
keypress(process.stdin);
2221

23-
process.stdin.on('keypress', function (ch, key) {
24-
if (key && key.ctrl) {
25-
if (key.name === 's')
26-
controller.stop();
22+
process.stdin.on('keypress', function (ch, key) {
23+
if (key && key.ctrl) {
24+
if (key.name === 's')
25+
controller.stop();
2726

28-
else if (key.name === 'r')
29-
controller.restart();
27+
else if (key.name === 'r')
28+
controller.restart();
3029

31-
else if (key.name === 'c')
32-
controller.exit().then(() => process.exit(0));
30+
else if (key.name === 'c')
31+
controller.exit().then(() => process.exit(0));
3332

34-
else if (key.name === 'w')
35-
controller.toggleWatching();
33+
else if (key.name === 'w')
34+
controller.toggleWatching();
3635

37-
}
38-
});
36+
}
37+
});
3938

40-
process.stdin.setRawMode(true);
41-
})();
39+
process.stdin.setRawMode(true);

lib/live-run-ctor-factory.js

Lines changed: 0 additions & 53 deletions
This file was deleted.

lib/logger/updating.js

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,35 @@
11
const querystring = require('querystring');
2-
const BaseLogger = require('./base');
2+
const BaseLogger = require('./base');
33

4-
// HACK: we use own sources for 'log-update-async-hook' to don't use the same
5-
// module with TestCafe. Otherwise it can lead to log updating mutual influence.
6-
const logUpdate = require('../log-update-async-hook');
4+
const logUpdate = require('log-update-async-hook');
5+
6+
// NOTE: clear the cache to don't use the same scope with TestCafe.
7+
// Otherwise it can lead to log updating mutual influence.
8+
delete require.cache[require.resolve('log-update-async-hook')];
79

810

911
const ansiEscapesCodeRe = /%1B%5B(\d*[A-KSTsun]|\d*%3B\d*H)/g;
1012

1113
module.exports = class UpdatingLogger extends BaseLogger {
12-
constructor () {
14+
constructor() {
1315
super();
1416

1517
this.appUpdatedLog = '';
1618
this.currentReport = '';
17-
this.statusMsg = '';
18-
this.writing = false;
19-
this.aborted = false;
20-
this.running = false;
19+
this.statusMsg = '';
20+
this.writing = false;
21+
this.aborted = false;
22+
this.running = false;
2123
}
2224

23-
_onStdoutWrite (msg) {
25+
_onStdoutWrite(msg) {
2426
if (this.writing || !this.testingStarted)
2527
this._write(msg);
2628
else {
2729
const escapedMsg = querystring.escape(msg);
2830

2931
if (msg.indexOf('Error: Test run aborted') > -1) {
30-
this.aborted = true;
32+
this.aborted = true;
3133
this.currentReport = '';
3234
}
3335
else if (ansiEscapesCodeRe.test(escapedMsg) || /DEBUGGER PAUSE:|DEBUGGER PAUSE ON FAILED TEST:/.test(msg))
@@ -39,20 +41,20 @@ module.exports = class UpdatingLogger extends BaseLogger {
3941
}
4042
}
4143

42-
_status (msg) {
44+
_status(msg) {
4345
this.statusMsg = msg;
4446
this._log();
4547
}
4648

47-
_log () {
49+
_log() {
4850
this.writing = true;
4951

5052
logUpdate(this._generateMsg());
5153

5254
this.writing = false;
5355
}
5456

55-
_generateMsg () {
57+
_generateMsg() {
5658
let separator = '\n-----------------------------\n\n';
5759

5860
let appUpdatedLog = this.appUpdatedLog && this.running ? `
@@ -84,13 +86,13 @@ module.exports = class UpdatingLogger extends BaseLogger {
8486
return separator + report + appUpdatedLog + status;
8587
}
8688

87-
runTests (sourcesChanged) {
89+
runTests(sourcesChanged) {
8890
this.currentReport = '';
8991

9092
super.runTests(sourcesChanged);
9193
}
9294

93-
testsFinished () {
95+
testsFinished() {
9496
this.appUpdatedLog = null;
9597

9698
super.testsFinished();

0 commit comments

Comments
 (0)