Innovenergy_trunk/frontend/node_modules/testcafe/lib/live/logger/index.js

75 lines
9.2 KiB
JavaScript

"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const log_1 = __importDefault(require("../../cli/log"));
class Logger {
constructor() {
this.watching = true;
this.MESSAGES = {
intro: `Live mode is enabled.
TestCafe now watches source files and reruns
the tests once the changes are saved.
You can use the following keys in the terminal:
'Ctrl+S' - stops the test run;
'Ctrl+R' - restarts the test run;
'Ctrl+W' - enables/disables watching files;
'Ctrl+C' - quits live mode and closes the browsers.
`,
sourceChanged: 'The sources have changed. A test run is starting...',
testRunStarting: 'A test run is starting...',
testRunStopping: 'The test run is stopping...',
testRunFinishedWatching: 'Make changes to the source files or press Ctrl+R to restart the test run.',
testRunFinishedNotWatching: 'Press Ctrl+R to restart the test run.',
fileWatchingEnabled: 'TestCafe is watching the source files. Save the changes to run tests.',
fileWatchingDisabled: 'TestCafe is not watching the source files.',
nothingToStop: 'There are no tests running at the moment.',
testCafeStopping: 'Stopping TestCafe live mode...',
watchingFiles: 'Watching the following files:',
};
}
_write(msg, prefix = '\n') {
log_1.default.write(`${prefix}${msg}`);
}
writeIntroMessage(files) {
this._write(this.MESSAGES.intro);
if (!Array.isArray(files))
return;
this._write(this.MESSAGES.watchingFiles);
files.forEach(file => {
this._write(file, ' ');
});
}
writeRunTestsMessage(sourcesChanged) {
const statusMessage = sourcesChanged ? this.MESSAGES.sourceChanged : this.MESSAGES.testRunStarting;
this._write(statusMessage);
}
writeTestsFinishedMessage() {
const statusMessage = this.watching ? this.MESSAGES.testRunFinishedWatching : this.MESSAGES.testRunFinishedNotWatching;
this._write(statusMessage);
}
writeStopRunningMessage() {
this._write(this.MESSAGES.testRunStopping);
}
writeNothingToStopMessage() {
this._write(this.MESSAGES.nothingToStop);
}
writeToggleWatchingMessage(enable) {
this.watching = enable;
const statusMessage = enable ? this.MESSAGES.fileWatchingEnabled : this.MESSAGES.fileWatchingDisabled;
this._write(statusMessage);
}
writeExitMessage() {
this._write(this.MESSAGES.testCafeStopping);
}
err(err) {
/* eslint-disable no-console */
console.log(err);
/* eslint-enable no-console */
}
}
exports.default = Logger;
module.exports = exports.default;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi9zcmMvbGl2ZS9sb2dnZXIvaW5kZXguanMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7QUFBQSx3REFBZ0M7QUFFaEMsTUFBcUIsTUFBTTtJQUN2QjtRQUNJLElBQUksQ0FBQyxRQUFRLEdBQUcsSUFBSSxDQUFDO1FBRXJCLElBQUksQ0FBQyxRQUFRLEdBQUc7WUFDWixLQUFLLEVBQUU7Ozs7Ozs7OztDQVNsQjtZQUVXLGFBQWEsRUFBZSxxREFBcUQ7WUFDakYsZUFBZSxFQUFhLDJCQUEyQjtZQUN2RCxlQUFlLEVBQWEsNkJBQTZCO1lBQ3pELHVCQUF1QixFQUFLLDJFQUEyRTtZQUN2RywwQkFBMEIsRUFBRSx1Q0FBdUM7WUFDbkUsbUJBQW1CLEVBQVMsdUVBQXVFO1lBQ25HLG9CQUFvQixFQUFRLDRDQUE0QztZQUN4RSxhQUFhLEVBQWUsMkNBQTJDO1lBQ3ZFLGdCQUFnQixFQUFZLGdDQUFnQztZQUM1RCxhQUFhLEVBQWUsK0JBQStCO1NBQzlELENBQUM7SUFDTixDQUFDO0lBRUQsTUFBTSxDQUFFLEdBQUcsRUFBRSxNQUFNLEdBQUcsSUFBSTtRQUN0QixhQUFHLENBQUMsS0FBSyxDQUFDLEdBQUcsTUFBTSxHQUFHLEdBQUcsRUFBRSxDQUFDLENBQUM7SUFDakMsQ0FBQztJQUVELGlCQUFpQixDQUFFLEtBQUs7UUFDcEIsSUFBSSxDQUFDLE1BQU0sQ0FBQy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