Upgrade Ava to v4
This commit is contained in:
parent
9a40cc5274
commit
ce89f1b611
1153 changed files with 27264 additions and 95308 deletions
472
node_modules/ava/lib/reporters/default.js
generated
vendored
472
node_modules/ava/lib/reporters/default.js
generated
vendored
|
|
@ -1,25 +1,24 @@
|
|||
'use strict';
|
||||
const os = require('os');
|
||||
const path = require('path');
|
||||
const stream = require('stream');
|
||||
import os from 'node:os';
|
||||
import path from 'node:path';
|
||||
import stream from 'node:stream';
|
||||
import {fileURLToPath} from 'node:url';
|
||||
|
||||
const cliCursor = require('cli-cursor');
|
||||
const figures = require('figures');
|
||||
const indentString = require('indent-string');
|
||||
const ora = require('ora');
|
||||
const plur = require('plur');
|
||||
const prettyMs = require('pretty-ms');
|
||||
const trimOffNewlines = require('trim-off-newlines');
|
||||
import figures from 'figures';
|
||||
import indentString from 'indent-string';
|
||||
import plur from 'plur';
|
||||
import prettyMs from 'pretty-ms';
|
||||
import StackUtils from 'stack-utils';
|
||||
|
||||
const chalk = require('../chalk').get();
|
||||
const codeExcerpt = require('../code-excerpt');
|
||||
const beautifyStack = require('./beautify-stack');
|
||||
const colors = require('./colors');
|
||||
const formatSerializedError = require('./format-serialized-error');
|
||||
const improperUsageMessages = require('./improper-usage-messages');
|
||||
const prefixTitle = require('./prefix-title');
|
||||
import {chalk} from '../chalk.js';
|
||||
import codeExcerpt from '../code-excerpt.js';
|
||||
|
||||
const nodeInternals = require('stack-utils').nodeInternals();
|
||||
import beautifyStack from './beautify-stack.js';
|
||||
import colors from './colors.js';
|
||||
import formatSerializedError from './format-serialized-error.js';
|
||||
import improperUsageMessage from './improper-usage-messages.js';
|
||||
import prefixTitle from './prefix-title.js';
|
||||
|
||||
const nodeInternals = StackUtils.nodeInternals();
|
||||
|
||||
class LineWriter extends stream.Writable {
|
||||
constructor(dest) {
|
||||
|
|
@ -52,129 +51,48 @@ class LineWriter extends stream.Writable {
|
|||
}
|
||||
}
|
||||
|
||||
class LineWriterWithSpinner extends LineWriter {
|
||||
constructor(dest, spinner) {
|
||||
super(dest);
|
||||
|
||||
this.lastSpinnerText = '';
|
||||
this.spinner = spinner;
|
||||
}
|
||||
|
||||
_write(chunk, _, callback) {
|
||||
this.spinner.clear();
|
||||
this._writeWithSpinner(chunk.toString('utf8'));
|
||||
|
||||
callback();
|
||||
}
|
||||
|
||||
_writev(pieces, callback) {
|
||||
// Discard the current spinner output. Any lines that were meant to be
|
||||
// preserved should be rewritten.
|
||||
this.spinner.clear();
|
||||
|
||||
const last = pieces.pop();
|
||||
for (const piece of pieces) {
|
||||
this.dest.write(piece.chunk);
|
||||
}
|
||||
|
||||
this._writeWithSpinner(last.chunk.toString('utf8'));
|
||||
callback();
|
||||
}
|
||||
|
||||
_writeWithSpinner(string) {
|
||||
if (!this.spinner.isSpinning) {
|
||||
this.dest.write(string);
|
||||
return;
|
||||
}
|
||||
|
||||
this.lastSpinnerText = string;
|
||||
// Ignore whitespace at the end of the chunk. We're continiously rewriting
|
||||
// the last line through the spinner. Also be careful to remove the indent
|
||||
// as the spinner adds its own.
|
||||
this.spinner.text = string.trimEnd().slice(2);
|
||||
this.spinner.render();
|
||||
}
|
||||
}
|
||||
|
||||
function manageCorking(stream) {
|
||||
let corked = false;
|
||||
const cork = () => {
|
||||
corked = true;
|
||||
stream.cork();
|
||||
};
|
||||
|
||||
const uncork = () => {
|
||||
corked = false;
|
||||
stream.uncork();
|
||||
};
|
||||
|
||||
return {
|
||||
decorateFlushingWriter(fn) {
|
||||
decorateWriter(fn) {
|
||||
return function (...args) {
|
||||
if (corked) {
|
||||
stream.uncork();
|
||||
}
|
||||
|
||||
stream.cork();
|
||||
try {
|
||||
return fn.apply(this, args);
|
||||
} finally {
|
||||
if (corked) {
|
||||
stream.cork();
|
||||
}
|
||||
stream.uncork();
|
||||
}
|
||||
};
|
||||
},
|
||||
|
||||
decorateWriter(fn) {
|
||||
return function (...args) {
|
||||
cork();
|
||||
try {
|
||||
return fn.apply(this, args);
|
||||
} finally {
|
||||
uncork();
|
||||
}
|
||||
};
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
class Reporter {
|
||||
export default class Reporter {
|
||||
constructor({
|
||||
verbose,
|
||||
extensions,
|
||||
reportStream,
|
||||
stdStream,
|
||||
projectDir,
|
||||
watching,
|
||||
spinner,
|
||||
durationThreshold
|
||||
durationThreshold,
|
||||
}) {
|
||||
this.verbose = verbose;
|
||||
this.extensions = extensions;
|
||||
this.reportStream = reportStream;
|
||||
this.stdStream = stdStream;
|
||||
this.watching = watching;
|
||||
this.relativeFile = file => path.relative(projectDir, file);
|
||||
this.relativeFile = file => {
|
||||
if (file.startsWith('file://')) {
|
||||
file = fileURLToPath(file);
|
||||
}
|
||||
|
||||
const {decorateWriter, decorateFlushingWriter} = manageCorking(this.reportStream);
|
||||
return path.relative(projectDir, file);
|
||||
};
|
||||
|
||||
const {decorateWriter} = manageCorking(this.reportStream);
|
||||
this.consumeStateChange = decorateWriter(this.consumeStateChange);
|
||||
this.endRun = decorateWriter(this.endRun);
|
||||
|
||||
if (this.verbose) {
|
||||
this.durationThreshold = durationThreshold || 100;
|
||||
this.spinner = null;
|
||||
this.clearSpinner = () => {};
|
||||
this.lineWriter = new LineWriter(this.reportStream);
|
||||
} else {
|
||||
this.spinner = ora({
|
||||
isEnabled: true,
|
||||
color: spinner ? spinner.color : 'gray',
|
||||
discardStdin: !watching,
|
||||
hideCursor: false,
|
||||
spinner: spinner || (process.platform === 'win32' ? 'line' : 'dots'),
|
||||
stream: reportStream
|
||||
});
|
||||
this.clearSpinner = decorateFlushingWriter(this.spinner.clear.bind(this.spinner));
|
||||
this.lineWriter = new LineWriterWithSpinner(this.reportStream, this.spinner);
|
||||
}
|
||||
this.durationThreshold = durationThreshold || 100;
|
||||
this.lineWriter = new LineWriter(this.reportStream);
|
||||
|
||||
this.reset();
|
||||
}
|
||||
|
|
@ -198,7 +116,6 @@ class Reporter {
|
|||
this.sharedWorkerErrors = [];
|
||||
this.uncaughtExceptions = [];
|
||||
this.unhandledRejections = [];
|
||||
this.unsavedSnapshots = [];
|
||||
|
||||
this.previousFailures = 0;
|
||||
|
||||
|
|
@ -221,9 +138,10 @@ class Reporter {
|
|||
this.matching = plan.matching;
|
||||
this.previousFailures = plan.previousFailures;
|
||||
this.emptyParallelRun = plan.status.emptyParallelRun;
|
||||
this.selectionInsights = plan.status.selectionInsights;
|
||||
|
||||
if (this.watching || plan.files.length > 1) {
|
||||
this.prefixTitle = (testFile, title) => prefixTitle(plan.filePathPrefix, testFile, title);
|
||||
this.prefixTitle = (testFile, title) => prefixTitle(this.extensions, plan.filePathPrefix, testFile, title);
|
||||
}
|
||||
|
||||
this.removePreviousListener = plan.status.on('stateChange', evt => {
|
||||
|
|
@ -234,13 +152,7 @@ class Reporter {
|
|||
this.lineWriter.write(chalk.gray.dim('\u2500'.repeat(this.lineWriter.columns)) + os.EOL);
|
||||
}
|
||||
|
||||
if (this.spinner === null) {
|
||||
this.lineWriter.writeLine();
|
||||
} else {
|
||||
cliCursor.hide(this.reportStream);
|
||||
this.lineWriter.writeLine();
|
||||
this.spinner.start();
|
||||
}
|
||||
this.lineWriter.writeLine();
|
||||
}
|
||||
|
||||
consumeStateChange(event) { // eslint-disable-line complexity
|
||||
|
|
@ -296,12 +208,10 @@ class Reporter {
|
|||
this.write(colors.error(`${figures.cross} Internal error`));
|
||||
}
|
||||
|
||||
if (this.verbose) {
|
||||
this.lineWriter.writeLine(colors.stack(event.err.summary));
|
||||
this.lineWriter.writeLine(colors.errorStack(event.err.stack));
|
||||
this.lineWriter.writeLine();
|
||||
this.lineWriter.writeLine();
|
||||
}
|
||||
this.lineWriter.writeLine(colors.stack(event.err.summary));
|
||||
this.lineWriter.writeLine(colors.errorStack(event.err.stack));
|
||||
this.lineWriter.writeLine();
|
||||
this.lineWriter.writeLine();
|
||||
|
||||
break;
|
||||
}
|
||||
|
|
@ -321,7 +231,7 @@ class Reporter {
|
|||
}
|
||||
|
||||
case 'hook-finished': {
|
||||
if (this.verbose && event.logs.length > 0) {
|
||||
if (true && event.logs.length > 0) {
|
||||
this.lineWriter.writeLine(` ${this.prefixTitle(event.testFile, event.title)}`);
|
||||
this.writeLogs(event);
|
||||
}
|
||||
|
|
@ -330,12 +240,10 @@ class Reporter {
|
|||
}
|
||||
|
||||
case 'selected-test': {
|
||||
if (this.verbose) {
|
||||
if (event.skip) {
|
||||
this.lineWriter.writeLine(colors.skip(`- ${this.prefixTitle(event.testFile, event.title)}`));
|
||||
} else if (event.todo) {
|
||||
this.lineWriter.writeLine(colors.todo(`- ${this.prefixTitle(event.testFile, event.title)}`));
|
||||
}
|
||||
if (event.skip) {
|
||||
this.lineWriter.writeLine(colors.skip(`- ${this.prefixTitle(event.testFile, event.title)}`));
|
||||
} else if (event.todo) {
|
||||
this.lineWriter.writeLine(colors.todo(`- ${this.prefixTitle(event.testFile, event.title)}`));
|
||||
}
|
||||
|
||||
break;
|
||||
|
|
@ -344,29 +252,21 @@ class Reporter {
|
|||
case 'shared-worker-error': {
|
||||
this.sharedWorkerErrors.push(event);
|
||||
|
||||
if (this.verbose) {
|
||||
this.lineWriter.ensureEmptyLine();
|
||||
this.lineWriter.writeLine(colors.error(`${figures.cross} Error in shared worker`));
|
||||
this.lineWriter.writeLine();
|
||||
this.writeErr(event);
|
||||
}
|
||||
this.lineWriter.ensureEmptyLine();
|
||||
this.lineWriter.writeLine(colors.error(`${figures.cross} Error in shared worker`));
|
||||
this.lineWriter.writeLine();
|
||||
this.writeErr(event);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case 'snapshot-error':
|
||||
this.unsavedSnapshots.push(event);
|
||||
break;
|
||||
|
||||
case 'uncaught-exception': {
|
||||
this.uncaughtExceptions.push(event);
|
||||
|
||||
if (this.verbose) {
|
||||
this.lineWriter.ensureEmptyLine();
|
||||
this.lineWriter.writeLine(colors.title(`Uncaught exception in ${this.relativeFile(event.testFile)}`));
|
||||
this.lineWriter.writeLine();
|
||||
this.writeErr(event);
|
||||
}
|
||||
this.lineWriter.ensureEmptyLine();
|
||||
this.lineWriter.writeLine(colors.title(`Uncaught exception in ${this.relativeFile(event.testFile)}`));
|
||||
this.lineWriter.writeLine();
|
||||
this.writeErr(event);
|
||||
|
||||
break;
|
||||
}
|
||||
|
|
@ -374,12 +274,10 @@ class Reporter {
|
|||
case 'unhandled-rejection': {
|
||||
this.unhandledRejections.push(event);
|
||||
|
||||
if (this.verbose) {
|
||||
this.lineWriter.ensureEmptyLine();
|
||||
this.lineWriter.writeLine(colors.title(`Unhandled rejection in ${this.relativeFile(event.testFile)}`));
|
||||
this.lineWriter.writeLine();
|
||||
this.writeErr(event);
|
||||
}
|
||||
this.lineWriter.ensureEmptyLine();
|
||||
this.lineWriter.writeLine(colors.title(`Unhandled rejection in ${this.relativeFile(event.testFile)}`));
|
||||
this.lineWriter.writeLine();
|
||||
this.writeErr(event);
|
||||
|
||||
break;
|
||||
}
|
||||
|
|
@ -389,8 +287,12 @@ class Reporter {
|
|||
this.filesWithoutDeclaredTests.add(event.testFile);
|
||||
}
|
||||
|
||||
if (this.verbose && !this.filesWithMissingAvaImports.has(event.testFile)) {
|
||||
if (event.nonZeroExitCode) {
|
||||
if (!this.filesWithMissingAvaImports.has(event.testFile)) {
|
||||
if (event.err) {
|
||||
this.lineWriter.writeLine(colors.error(`${figures.cross} ${this.relativeFile(event.testFile)} exited due to an error:`));
|
||||
this.lineWriter.writeLine();
|
||||
this.writeErr(event);
|
||||
} else if (event.nonZeroExitCode) {
|
||||
this.lineWriter.writeLine(colors.error(`${figures.cross} ${this.relativeFile(event.testFile)} exited with a non-zero exit code: ${event.nonZeroExitCode}`));
|
||||
} else {
|
||||
this.lineWriter.writeLine(colors.error(`${figures.cross} ${this.relativeFile(event.testFile)} exited due to ${event.signal}`));
|
||||
|
|
@ -410,7 +312,7 @@ class Reporter {
|
|||
this.filesWithoutMatchedLineNumbers.add(event.testFile);
|
||||
|
||||
this.lineWriter.writeLine(colors.error(`${figures.cross} Line numbers for ${this.relativeFile(event.testFile)} did not match any tests`));
|
||||
} else if (this.verbose && !this.failFastEnabled && fileStats.remainingTests > 0) {
|
||||
} else if (true && !this.failFastEnabled && fileStats.remainingTests > 0) {
|
||||
this.lineWriter.writeLine(colors.error(`${figures.cross} ${fileStats.remainingTests} ${plur('test', fileStats.remainingTests)} remaining in ${this.relativeFile(event.testFile)}`));
|
||||
}
|
||||
}
|
||||
|
|
@ -419,9 +321,6 @@ class Reporter {
|
|||
}
|
||||
|
||||
case 'worker-stderr': {
|
||||
// Forcibly clear the spinner, writing the chunk corrupts the TTY.
|
||||
this.clearSpinner();
|
||||
|
||||
this.stdStream.write(event.chunk);
|
||||
// If the chunk does not end with a linebreak, *forcibly* write one to
|
||||
// ensure it remains visible in the TTY.
|
||||
|
|
@ -433,17 +332,10 @@ class Reporter {
|
|||
this.reportStream.write(os.EOL);
|
||||
}
|
||||
|
||||
if (this.spinner !== null) {
|
||||
this.lineWriter.write(this.lineWriter.lastSpinnerText);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case 'worker-stdout': {
|
||||
// Forcibly clear the spinner, writing the chunk corrupts the TTY.
|
||||
this.clearSpinner();
|
||||
|
||||
this.stdStream.write(event.chunk);
|
||||
// If the chunk does not end with a linebreak, *forcibly* write one to
|
||||
// ensure it remains visible in the TTY.
|
||||
|
|
@ -454,10 +346,6 @@ class Reporter {
|
|||
if (event.chunk[event.chunk.length - 1] !== 0x0A) {
|
||||
this.reportStream.write(os.EOL);
|
||||
}
|
||||
|
||||
if (this.spinner !== null) {
|
||||
this.lineWriter.write(this.lineWriter.lastSpinnerText);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -478,11 +366,7 @@ class Reporter {
|
|||
}
|
||||
|
||||
write(string) {
|
||||
if (this.verbose) {
|
||||
this.lineWriter.writeLine(string);
|
||||
} else {
|
||||
this.writeWithCounts(string);
|
||||
}
|
||||
this.lineWriter.writeLine(string);
|
||||
}
|
||||
|
||||
writeWithCounts(string) {
|
||||
|
|
@ -529,7 +413,7 @@ class Reporter {
|
|||
|
||||
writeErr(event) {
|
||||
if (event.err.name === 'TSError' && event.err.object && event.err.object.diagnosticText) {
|
||||
this.lineWriter.writeLine(colors.errorStack(trimOffNewlines(event.err.object.diagnosticText)));
|
||||
this.lineWriter.writeLine(colors.errorStack(event.err.object.diagnosticText));
|
||||
this.lineWriter.writeLine();
|
||||
return;
|
||||
}
|
||||
|
|
@ -556,13 +440,13 @@ class Reporter {
|
|||
this.lineWriter.writeLine();
|
||||
}
|
||||
|
||||
const message = improperUsageMessages.forError(event.err);
|
||||
const message = improperUsageMessage(event.err);
|
||||
if (message) {
|
||||
this.lineWriter.writeLine(message);
|
||||
this.lineWriter.writeLine();
|
||||
}
|
||||
} else if (event.err.nonErrorObject) {
|
||||
this.lineWriter.writeLine(trimOffNewlines(event.err.formatted));
|
||||
this.lineWriter.writeLine(event.err.formatted);
|
||||
this.lineWriter.writeLine();
|
||||
} else {
|
||||
this.lineWriter.writeLine(event.err.summary);
|
||||
|
|
@ -618,27 +502,15 @@ class Reporter {
|
|||
|
||||
writeTestSummary(event) {
|
||||
if (event.type === 'hook-failed' || event.type === 'test-failed') {
|
||||
if (this.verbose) {
|
||||
this.write(`${colors.error(figures.cross)} ${this.prefixTitle(event.testFile, event.title)} ${colors.error(event.err.message)}`);
|
||||
} else {
|
||||
this.write(this.prefixTitle(event.testFile, event.title));
|
||||
}
|
||||
this.write(`${colors.error(figures.cross)} ${this.prefixTitle(event.testFile, event.title)} ${colors.error(event.err.message)}`);
|
||||
} else if (event.knownFailing) {
|
||||
if (this.verbose) {
|
||||
this.write(`${colors.error(figures.tick)} ${colors.error(this.prefixTitle(event.testFile, event.title))}`);
|
||||
} else {
|
||||
this.write(colors.error(this.prefixTitle(event.testFile, event.title)));
|
||||
}
|
||||
} else if (this.verbose) {
|
||||
this.write(`${colors.error(figures.tick)} ${colors.error(this.prefixTitle(event.testFile, event.title))}`);
|
||||
} else {
|
||||
const duration = event.duration > this.durationThreshold ? colors.duration(' (' + prettyMs(event.duration) + ')') : '';
|
||||
this.write(`${colors.pass(figures.tick)} ${this.prefixTitle(event.testFile, event.title)}${duration}`);
|
||||
} else {
|
||||
this.write(this.prefixTitle(event.testFile, event.title));
|
||||
}
|
||||
|
||||
if (this.verbose) {
|
||||
this.writeLogs(event);
|
||||
}
|
||||
this.writeLogs(event);
|
||||
}
|
||||
|
||||
writeFailure(event) {
|
||||
|
|
@ -652,19 +524,38 @@ class Reporter {
|
|||
|
||||
endRun() {// eslint-disable-line complexity
|
||||
let firstLinePostfix = this.watching ? ` ${chalk.gray.dim(`[${new Date().toLocaleTimeString('en-US', {hour12: false})}]`)}` : '';
|
||||
let wroteSomething = false;
|
||||
|
||||
if (!this.verbose) {
|
||||
this.spinner.stop();
|
||||
cliCursor.show(this.reportStream);
|
||||
} else if (this.emptyParallelRun) {
|
||||
if (this.emptyParallelRun) {
|
||||
this.lineWriter.writeLine('No files tested in this parallel run');
|
||||
this.lineWriter.writeLine();
|
||||
return;
|
||||
}
|
||||
|
||||
if (!this.stats) {
|
||||
this.lineWriter.writeLine(colors.error(`${figures.cross} Couldn’t find any files to test` + firstLinePostfix));
|
||||
if (this.selectionInsights.ignoredFilterPatternFiles.length > 0) {
|
||||
this.write(colors.information(`${figures.warning} Paths for additional test files were disregarded:`));
|
||||
this.lineWriter.writeLine();
|
||||
for (const pattern of this.selectionInsights.ignoredFilterPatternFiles) {
|
||||
this.lineWriter.writeLine(chalk.magenta(`* ${pattern}`));
|
||||
}
|
||||
|
||||
this.lineWriter.writeLine();
|
||||
this.write(colors.information('Files starting with underscores are never treated as test files.'));
|
||||
this.write(colors.information('Files handled by @ava/typescript can only be selected if your configuration already selects them.'));
|
||||
this.lineWriter.writeLine();
|
||||
}
|
||||
|
||||
if (this.selectionInsights.selectionCount === 0) {
|
||||
if (this.selectionInsights.testFileCount === 0) {
|
||||
this.lineWriter.writeLine(colors.error(`${figures.cross} Couldn’t find any files to test` + firstLinePostfix));
|
||||
} else {
|
||||
const {testFileCount: count} = this.selectionInsights;
|
||||
this.lineWriter.writeLine(colors.error(`${figures.cross} Based on your configuration, ${count} test ${plur('file was', 'files were', count)} found, but did not match the CLI arguments:` + firstLinePostfix));
|
||||
this.lineWriter.writeLine();
|
||||
for (const {pattern} of this.selectionInsights.filter) {
|
||||
this.lineWriter.writeLine(colors.error(`* ${pattern}`));
|
||||
}
|
||||
}
|
||||
|
||||
this.lineWriter.writeLine();
|
||||
return;
|
||||
}
|
||||
|
|
@ -675,53 +566,8 @@ class Reporter {
|
|||
return;
|
||||
}
|
||||
|
||||
if (this.verbose) {
|
||||
this.lineWriter.writeLine(colors.log(figures.line));
|
||||
this.lineWriter.writeLine();
|
||||
} else {
|
||||
if (this.filesWithMissingAvaImports.size > 0) {
|
||||
for (const testFile of this.filesWithMissingAvaImports) {
|
||||
this.lineWriter.writeLine(colors.error(`${figures.cross} No tests found in ${this.relativeFile(testFile)}, make sure to import "ava" at the top of your test file`) + firstLinePostfix);
|
||||
firstLinePostfix = '';
|
||||
wroteSomething = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (this.filesWithoutDeclaredTests.size > 0) {
|
||||
for (const testFile of this.filesWithoutDeclaredTests) {
|
||||
if (!this.filesWithMissingAvaImports.has(testFile)) {
|
||||
this.lineWriter.writeLine(colors.error(`${figures.cross} No tests found in ${this.relativeFile(testFile)}`) + firstLinePostfix);
|
||||
firstLinePostfix = '';
|
||||
wroteSomething = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (this.lineNumberErrors.length > 0) {
|
||||
for (const event of this.lineNumberErrors) {
|
||||
this.lineWriter.writeLine(colors.information(`${figures.warning} Could not parse ${this.relativeFile(event.testFile)} for line number selection` + firstLinePostfix));
|
||||
firstLinePostfix = '';
|
||||
wroteSomething = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (this.filesWithoutMatchedLineNumbers.size > 0) {
|
||||
for (const testFile of this.filesWithoutMatchedLineNumbers) {
|
||||
if (!this.filesWithMissingAvaImports.has(testFile) && !this.filesWithoutDeclaredTests.has(testFile)) {
|
||||
this.lineWriter.writeLine(colors.error(`${figures.cross} Line numbers for ${this.relativeFile(testFile)} did not match any tests`) + firstLinePostfix);
|
||||
firstLinePostfix = '';
|
||||
wroteSomething = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (wroteSomething) {
|
||||
this.lineWriter.writeLine();
|
||||
this.lineWriter.writeLine(colors.log(figures.line));
|
||||
this.lineWriter.writeLine();
|
||||
wroteSomething = false;
|
||||
}
|
||||
}
|
||||
this.lineWriter.writeLine(colors.log(figures.line));
|
||||
this.lineWriter.writeLine();
|
||||
|
||||
if (this.failures.length > 0) {
|
||||
const writeTrailingLines = this.internalErrors.length > 0 || this.sharedWorkerErrors.length > 0 || this.uncaughtExceptions.length > 0 || this.unhandledRejections.length > 0;
|
||||
|
|
@ -732,106 +578,13 @@ class Reporter {
|
|||
if (event !== lastFailure) {
|
||||
this.lineWriter.writeLine();
|
||||
this.lineWriter.writeLine();
|
||||
} else if (!this.verbose && writeTrailingLines) {
|
||||
} else if (!true && writeTrailingLines) {
|
||||
this.lineWriter.writeLine();
|
||||
this.lineWriter.writeLine();
|
||||
}
|
||||
|
||||
wroteSomething = true;
|
||||
}
|
||||
|
||||
if (this.verbose) {
|
||||
this.lineWriter.writeLine(colors.log(figures.line));
|
||||
this.lineWriter.writeLine();
|
||||
}
|
||||
}
|
||||
|
||||
if (!this.verbose) {
|
||||
if (this.internalErrors.length > 0) {
|
||||
const writeTrailingLines = this.sharedWorkerErrors.length > 0 || this.uncaughtExceptions.length > 0 || this.unhandledRejections.length > 0;
|
||||
|
||||
const last = this.internalErrors[this.internalErrors.length - 1];
|
||||
for (const event of this.internalErrors) {
|
||||
if (event.testFile) {
|
||||
this.lineWriter.writeLine(colors.error(`${figures.cross} Internal error when running ${this.relativeFile(event.testFile)}`));
|
||||
} else {
|
||||
this.lineWriter.writeLine(colors.error(`${figures.cross} Internal error`));
|
||||
}
|
||||
|
||||
this.lineWriter.writeLine(colors.stack(event.err.summary));
|
||||
this.lineWriter.writeLine(colors.errorStack(event.err.stack));
|
||||
if (event !== last || writeTrailingLines) {
|
||||
this.lineWriter.writeLine();
|
||||
this.lineWriter.writeLine();
|
||||
this.lineWriter.writeLine();
|
||||
}
|
||||
|
||||
wroteSomething = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (this.sharedWorkerErrors.length > 0) {
|
||||
const writeTrailingLines = this.uncaughtExceptions.length > 0 || this.unhandledRejections.length > 0;
|
||||
|
||||
const last = this.sharedWorkerErrors[this.sharedWorkerErrors.length - 1];
|
||||
for (const evt of this.sharedWorkerErrors) {
|
||||
this.lineWriter.writeLine(colors.error(`${figures.cross} Error in shared worker`));
|
||||
this.lineWriter.writeLine();
|
||||
this.writeErr(evt.err);
|
||||
if (evt !== last || writeTrailingLines) {
|
||||
this.lineWriter.writeLine();
|
||||
this.lineWriter.writeLine();
|
||||
}
|
||||
|
||||
wroteSomething = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (this.uncaughtExceptions.length > 0) {
|
||||
const writeTrailingLines = this.unhandledRejections.length > 0;
|
||||
|
||||
const last = this.uncaughtExceptions[this.uncaughtExceptions.length - 1];
|
||||
for (const event of this.uncaughtExceptions) {
|
||||
this.lineWriter.writeLine(colors.title(`Uncaught exception in ${this.relativeFile(event.testFile)}`));
|
||||
this.lineWriter.writeLine();
|
||||
this.writeErr(event);
|
||||
if (event !== last || writeTrailingLines) {
|
||||
this.lineWriter.writeLine();
|
||||
this.lineWriter.writeLine();
|
||||
}
|
||||
|
||||
wroteSomething = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (this.unhandledRejections.length > 0) {
|
||||
const last = this.unhandledRejections[this.unhandledRejections.length - 1];
|
||||
for (const event of this.unhandledRejections) {
|
||||
this.lineWriter.writeLine(colors.title(`Unhandled rejection in ${this.relativeFile(event.testFile)}`));
|
||||
this.lineWriter.writeLine();
|
||||
this.writeErr(event);
|
||||
if (event !== last) {
|
||||
this.lineWriter.writeLine();
|
||||
this.lineWriter.writeLine();
|
||||
}
|
||||
|
||||
wroteSomething = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (wroteSomething) {
|
||||
this.lineWriter.writeLine(colors.log(figures.line));
|
||||
this.lineWriter.writeLine();
|
||||
}
|
||||
}
|
||||
|
||||
if (this.unsavedSnapshots.length > 0) {
|
||||
this.lineWriter.writeLine(colors.title('Could not update snapshots for the following test files:'));
|
||||
this.lineWriter.writeLine();
|
||||
for (const event of this.unsavedSnapshots) {
|
||||
this.lineWriter.writeLine(`${figures.warning} ${this.relativeFile(event.testFile)}`);
|
||||
}
|
||||
|
||||
this.lineWriter.writeLine(colors.log(figures.line));
|
||||
this.lineWriter.writeLine();
|
||||
}
|
||||
|
||||
|
|
@ -853,16 +606,14 @@ class Reporter {
|
|||
}
|
||||
|
||||
this.lineWriter.writeLine(colors.information(`\`--fail-fast\` is on. ${remaining}.`));
|
||||
if (this.verbose) {
|
||||
this.lineWriter.writeLine();
|
||||
}
|
||||
this.lineWriter.writeLine();
|
||||
}
|
||||
|
||||
if (this.verbose && this.stats.parallelRuns) {
|
||||
if (this.stats.parallelRuns) {
|
||||
const {
|
||||
currentFileCount,
|
||||
currentIndex,
|
||||
totalRuns
|
||||
totalRuns,
|
||||
} = this.stats.parallelRuns;
|
||||
this.lineWriter.writeLine(colors.information(`Ran ${currentFileCount} test ${plur('file', currentFileCount)} out of ${this.stats.files} for job ${currentIndex + 1} of ${totalRuns}`));
|
||||
this.lineWriter.writeLine();
|
||||
|
|
@ -879,11 +630,11 @@ class Reporter {
|
|||
}
|
||||
|
||||
if (
|
||||
this.stats.failedHooks === 0 &&
|
||||
this.stats.failedTests === 0 &&
|
||||
this.stats.passedTests > 0
|
||||
this.stats.failedHooks === 0
|
||||
&& this.stats.failedTests === 0
|
||||
&& this.stats.passedTests > 0
|
||||
) {
|
||||
this.lineWriter.writeLine(colors.pass(`${this.stats.passedTests} ${plur('test', this.stats.passedTests)} passed`) + firstLinePostfix
|
||||
this.lineWriter.writeLine(colors.pass(`${this.stats.passedTests} ${plur('test', this.stats.passedTests)} passed`) + firstLinePostfix,
|
||||
);
|
||||
firstLinePostfix = '';
|
||||
}
|
||||
|
|
@ -917,4 +668,3 @@ class Reporter {
|
|||
}
|
||||
}
|
||||
}
|
||||
module.exports = Reporter;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue