aboutsummaryrefslogtreecommitdiff
path: root/node_modules/ava/lib/run-status.js
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2019-03-27 21:01:33 +0100
committerFlorian Dold <florian.dold@gmail.com>2019-03-27 21:01:33 +0100
commitcc97a4dd2a967e1c2273bd5f4c5f49a5bf2e2585 (patch)
tree92c5d88706a6ffc654d1b133618d357890e7096b /node_modules/ava/lib/run-status.js
parent3771b4d6b67b34c130f3a9a1a15f42deefdb2eda (diff)
remove node_modules
Diffstat (limited to 'node_modules/ava/lib/run-status.js')
-rw-r--r--node_modules/ava/lib/run-status.js136
1 files changed, 0 insertions, 136 deletions
diff --git a/node_modules/ava/lib/run-status.js b/node_modules/ava/lib/run-status.js
deleted file mode 100644
index 461ab8f90..000000000
--- a/node_modules/ava/lib/run-status.js
+++ /dev/null
@@ -1,136 +0,0 @@
-'use strict';
-const EventEmitter = require('events');
-const chalk = require('chalk');
-const flatten = require('arr-flatten');
-const figures = require('figures');
-const autoBind = require('auto-bind');
-const prefixTitle = require('./prefix-title');
-
-function sum(arr, key) {
- let result = 0;
-
- arr.forEach(item => {
- result += item[key];
- });
-
- return result;
-}
-
-class RunStatus extends EventEmitter {
- constructor(opts) {
- super();
-
- opts = opts || {};
- this.prefixTitles = opts.prefixTitles !== false;
- this.hasExclusive = Boolean(opts.runOnlyExclusive);
- this.base = opts.base || '';
- this.rejectionCount = 0;
- this.exceptionCount = 0;
- this.passCount = 0;
- this.knownFailureCount = 0;
- this.skipCount = 0;
- this.todoCount = 0;
- this.failCount = 0;
- this.fileCount = 0;
- this.testCount = 0;
- this.remainingCount = 0;
- this.previousFailCount = 0;
- this.knownFailures = [];
- this.errors = [];
- this.stats = [];
- this.tests = [];
- this.failFastEnabled = opts.failFast || false;
- this.updateSnapshots = opts.updateSnapshots || false;
-
- autoBind(this);
- }
-
- observeFork(emitter) {
- emitter
- .on('teardown', this.handleTeardown)
- .on('stats', this.handleStats)
- .on('test', this.handleTest)
- .on('unhandledRejections', this.handleRejections)
- .on('uncaughtException', this.handleExceptions)
- .on('stdout', this.handleOutput.bind(this, 'stdout'))
- .on('stderr', this.handleOutput.bind(this, 'stderr'));
- }
-
- handleRejections(data) {
- this.rejectionCount += data.rejections.length;
-
- data.rejections.forEach(err => {
- err.type = 'rejection';
- err.file = data.file;
- this.emit('error', err, this);
- this.errors.push(err);
- });
- }
-
- handleExceptions(data) {
- this.exceptionCount++;
- const err = data.exception;
- err.type = 'exception';
- err.file = data.file;
- this.emit('error', err, this);
- this.errors.push(err);
- }
-
- handleTeardown(data) {
- this.emit('dependencies', data.file, data.dependencies, this);
- this.emit('touchedFiles', data.touchedFiles);
- }
-
- handleStats(stats) {
- this.emit('stats', stats, this);
-
- if (stats.hasExclusive) {
- this.hasExclusive = true;
- }
-
- this.testCount += stats.testCount;
- }
-
- handleTest(test) {
- test.title = this.prefixTitle(test.file) + test.title;
-
- if (test.error) {
- this.errors.push(test);
- }
-
- if (test.failing && !test.error) {
- this.knownFailures.push(test);
- }
-
- this.emit('test', test, this);
- }
-
- prefixTitle(file) {
- if (!this.prefixTitles) {
- return '';
- }
-
- const separator = ' ' + chalk.gray.dim(figures.pointerSmall) + ' ';
-
- return prefixTitle(file, this.base, separator);
- }
-
- handleOutput(channel, data) {
- this.emit(channel, data, this);
- }
-
- processResults(results) {
- // Assemble stats from all tests
- this.stats = results.map(result => result.stats);
- this.tests = results.map(result => result.tests);
- this.tests = flatten(this.tests);
- this.passCount = sum(this.stats, 'passCount');
- this.knownFailureCount = sum(this.stats, 'knownFailureCount');
- this.skipCount = sum(this.stats, 'skipCount');
- this.todoCount = sum(this.stats, 'todoCount');
- this.failCount = sum(this.stats, 'failCount');
- this.remainingCount = this.testCount - this.passCount - this.failCount - this.skipCount - this.todoCount - this.knownFailureCount;
- }
-}
-
-module.exports = RunStatus;