diff --git a/goldens/api/betterer.api.md b/goldens/api/betterer.api.md index 0535f31f8..bfa6b480b 100644 --- a/goldens/api/betterer.api.md +++ b/goldens/api/betterer.api.md @@ -77,7 +77,7 @@ export interface BettererConfigWatcher { export interface BettererContext { readonly config: BettererConfig; options(optionsOverride: BettererOptionsOverride): Promise; - stop(): Promise; + stop(): Promise; } // @public @@ -426,11 +426,10 @@ export interface BettererRun { } // @public -export interface BettererRunner { - options(optionsOverride: BettererOptionsOverride): Promise; +export interface BettererRunner extends BettererContext { queue(filePaths?: string | BettererFilePaths): Promise; - stop(): Promise; - stop(force: true): Promise; + stop(): Promise; + stop(force?: true): Promise; } // @public diff --git a/goldens/api/render.api.md b/goldens/api/render.api.md index 64f5f40a5..adf5ae0aa 100644 --- a/goldens/api/render.api.md +++ b/goldens/api/render.api.md @@ -12,9 +12,9 @@ import { memo } from 'react'; import { process as process_2 } from 'process'; import { PropsWithChildren } from 'react'; import R from 'react'; +import { default as React_3 } from 'react'; import { render } from 'ink'; import { RenderOptions } from 'ink'; -import { Text as Text_2 } from 'ink'; import { TextProps } from 'ink'; import TI from 'ink-text-input'; import { useApp } from 'ink'; @@ -62,6 +62,8 @@ export { render } export { RenderOptions } +// @internal +const Text_2: React_3.FC; export { Text_2 as Text } // @internal diff --git a/packages/betterer/src/api/betterer.ts b/packages/betterer/src/api/betterer.ts index 349e297c2..c8828ffcf 100644 --- a/packages/betterer/src/api/betterer.ts +++ b/packages/betterer/src/api/betterer.ts @@ -23,7 +23,8 @@ import { watch } from './watch.js'; */ export const betterer = async function betterer(options: BettererOptions = {}): Promise { const runner = await BettererRunnerΩ.create(options); - return await runner.run(); + const contextSummary = await runner.run(); + return contextSummary.lastSuite; }; betterer.merge = merge; diff --git a/packages/betterer/src/context/config.ts b/packages/betterer/src/context/config.ts index 01123ff58..5e2b1af15 100644 --- a/packages/betterer/src/context/config.ts +++ b/packages/betterer/src/context/config.ts @@ -9,6 +9,7 @@ import { validateStringRegExpArray, validateWorkers } from '../config/index.js'; +import { getGlobals } from '../globals.js'; export async function createContextConfig(options: BettererOptionsContext): Promise { const ci = options.ci ?? false; @@ -41,8 +42,9 @@ export async function createContextConfig(options: BettererOptionsContext): Prom }; } -export function overrideContextConfig(config: BettererConfig, optionsOverride: BettererOptionsContextOverride): void { +export function overrideContextConfig(optionsOverride: BettererOptionsContextOverride): void { if (optionsOverride.filters) { + const { config } = getGlobals(); validateStringRegExpArray({ filters: optionsOverride.filters }); config.filters = toRegExps(toArray(optionsOverride.filters)); } diff --git a/packages/betterer/src/context/context-summary.ts b/packages/betterer/src/context/context-summary.ts index 23ec8c758..d3768ff30 100644 --- a/packages/betterer/src/context/context-summary.ts +++ b/packages/betterer/src/context/context-summary.ts @@ -1,13 +1,18 @@ -import { BettererError } from '@betterer/errors'; import type { BettererConfig } from '../config/index.js'; import type { BettererSuiteSummaries, BettererSuiteSummary } from '../suite/index.js'; import type { BettererContextSummary } from './types.js'; +import { BettererError } from '@betterer/errors'; + +import { getGlobals } from '../globals.js'; + export class BettererContextSummaryΩ implements BettererContextSummary { - constructor( - public readonly config: BettererConfig, - public readonly suites: BettererSuiteSummaries - ) {} + public readonly config: BettererConfig; + + constructor(public readonly suites: BettererSuiteSummaries) { + const { config } = getGlobals(); + this.config = config; + } public get lastSuite(): BettererSuiteSummary { const suite = this.suites[this.suites.length - 1]; diff --git a/packages/betterer/src/context/context.ts b/packages/betterer/src/context/context.ts index dd32eb7dd..6fc0f56eb 100644 --- a/packages/betterer/src/context/context.ts +++ b/packages/betterer/src/context/context.ts @@ -1,167 +1,135 @@ -import type { BettererError } from '@betterer/errors'; +import { BettererError } from '@betterer/errors'; import type { BettererConfig, BettererOptionsOverride } from '../config/index.js'; import type { BettererFilePaths } from '../fs/index.js'; import type { BettererReporterΩ } from '../reporters/index.js'; -import type { BettererSuiteSummaries, BettererSuiteSummary, BettererSuiteSummaryΩ } from '../suite/index.js'; -import type { BettererContext, BettererContextStarted, BettererContextSummary } from './types.js'; +import type { + BettererSuite, + BettererSuites, + BettererSuiteSummaries, + BettererSuiteSummary, + BettererSuiteSummaryΩ +} from '../suite/index.js'; +import type { BettererContext, BettererContextSummary } from './types.js'; import { overrideContextConfig } from '../context/index.js'; -import { BettererFileResolverΩ } from '../fs/index.js'; +import type { BettererFileResolverΩ } from '../fs/index.js'; import { overrideReporterConfig } from '../reporters/index.js'; import { overrideWatchConfig } from '../runner/index.js'; import { BettererSuiteΩ } from '../suite/index.js'; -import { defer } from '../utils.js'; -import { BettererContextSummaryΩ } from './context-summary.js'; import { getGlobals } from '../globals.js'; +import { BettererContextSummaryΩ } from './context-summary.js'; export class BettererContextΩ implements BettererContext { public readonly config: BettererConfig; - private _started: BettererContextStarted; + private _suites: BettererSuites = []; private _suiteSummaries: BettererSuiteSummaries = []; constructor() { const { config } = getGlobals(); this.config = config; - this._started = this._start(); + } + + public get lastSuite(): BettererSuite { + const suite = this._suites[this._suites.length - 1]; + if (!suite) { + throw new BettererError(`Context has not started a suite run yet! ❌`); + } + return suite; } public async options(optionsOverride: BettererOptionsOverride): Promise { // Wait for any pending run to finish, and any existing reporter to render: - await this._started.end(); - - const { config } = getGlobals(); + let lastSuiteΩ: BettererSuiteΩ | null = null; + try { + const lastSuite = this.lastSuite; + lastSuiteΩ = lastSuite as BettererSuiteΩ; + await lastSuiteΩ.lifecycle.promise; + } catch { + // It's okay if there's not a pending suite! + } // Override the config: - overrideContextConfig(config, optionsOverride); - await overrideReporterConfig(config, optionsOverride); - overrideWatchConfig(config, optionsOverride); - - // Start everything again, and trigger a new reporter: - this._started = this._start(); - - // eslint-disable-next-line @typescript-eslint/no-misused-promises -- SIGTERM doesn't care about Promises - process.on('SIGTERM', () => this.stop()); - } + overrideContextConfig(optionsOverride); + await overrideReporterConfig(optionsOverride); + overrideWatchConfig(optionsOverride); - public async runOnce(): Promise { - await this.run([], true); + if (lastSuiteΩ) { + // Run the tests again, with all the new options: + void this.run(lastSuiteΩ.filePaths, false); + } } - public async run(specifiedFilePaths: BettererFilePaths, isRunOnce = false): Promise { - try { - const { config, results, versionControl } = getGlobals(); - - await versionControl.api.sync(); - - const { cwd, ci, includes, excludes, reporter } = config; - const reporterΩ = reporter as BettererReporterΩ; - - const resolver = new BettererFileResolverΩ(cwd, versionControl); - resolver.include(...includes); - resolver.exclude(...excludes); - - const hasSpecifiedFiles = specifiedFilePaths.length > 0; - const hasGlobalIncludesExcludes = includes.length || excludes.length; - - let filePaths: BettererFilePaths; - if (hasSpecifiedFiles && hasGlobalIncludesExcludes) { - // Validate specified files based on global `includes`/`excludes and gitignore rules: - filePaths = await resolver.validate(specifiedFilePaths); - } else if (hasSpecifiedFiles) { - // Validate specified files based on gitignore rules: - filePaths = await resolver.validate(specifiedFilePaths); - } else if (hasGlobalIncludesExcludes) { - // Resolve files based on global `includes`/`excludes and gitignore rules: - filePaths = await resolver.files(); - } else { - // When `filePaths` is `[]` the test will use its specific resolver: - filePaths = []; - } - - const suite = await BettererSuiteΩ.create(filePaths); - const suiteLifecycle = defer(); + public async run(specifiedFilePaths: BettererFilePaths, isRunOnce = false): Promise { + const { config, reporter, resolvers, results } = getGlobals(); + const resolver = resolvers.cwd as BettererFileResolverΩ; + + const { includes, excludes } = config; + resolver.include(...includes); + resolver.exclude(...excludes); + + const hasSpecifiedFiles = specifiedFilePaths.length > 0; + const hasGlobalIncludesExcludes = includes.length || excludes.length; + + let filePaths: BettererFilePaths; + if (hasSpecifiedFiles && hasGlobalIncludesExcludes) { + // Validate specified files based on global `includes`/`excludes and gitignore rules: + filePaths = await resolver.validate(specifiedFilePaths); + } else if (hasSpecifiedFiles) { + // Validate specified files based on gitignore rules: + filePaths = await resolver.validate(specifiedFilePaths); + } else if (hasGlobalIncludesExcludes) { + // Resolve files based on global `includes`/`excludes and gitignore rules: + filePaths = await resolver.files(); + } else { + // When `filePaths` is `[]` the test will use its specific resolver: + filePaths = []; + } - // Don't await here! A custom reporter could be awaiting - // the lifecycle promise which is unresolved right now! - const reportSuiteStart = reporterΩ.suiteStart(suite, suiteLifecycle.promise); - try { - const suiteSummary = await suite.run(); + const suiteΩ = await BettererSuiteΩ.create(filePaths); + this._suites.push(suiteΩ); - if (!isRunOnce && !ci) { - const suiteSummaryΩ = suiteSummary as BettererSuiteSummaryΩ; - await results.api.write(suiteSummaryΩ.result); - } + const reporterΩ = reporter as BettererReporterΩ; - this._suiteSummaries = [...this._suiteSummaries, suiteSummary]; + // Don't await here! A custom reporter could be awaiting + // the lifecycle promise which is unresolved right now! + const reportSuiteStart = reporterΩ.suiteStart(suiteΩ, suiteΩ.lifecycle.promise); + try { + const suiteSummary = await suiteΩ.run(); + this._suiteSummaries = [...this._suiteSummaries, suiteSummary]; - // Lifecycle promise is resolved, so it's safe to finally await - // the result of `reporter.suiteStart`: - suiteLifecycle.resolve(suiteSummary); - await reportSuiteStart; + if (!isRunOnce && !config.ci) { + const suiteSummaryΩ = suiteSummary as BettererSuiteSummaryΩ; + await results.api.write(suiteSummaryΩ.result); + } - await reporterΩ.suiteEnd(suiteSummary); - } catch (error) { - // Lifecycle promise is rejected, so it's safe to finally await - // the result of `reporter.suiteStart`: - suiteLifecycle.reject(error as BettererError); - await reportSuiteStart; + // Lifecycle promise is resolved, so it's safe to await + // the result of `reporter.suiteStart`: + suiteΩ.lifecycle.resolve(suiteSummary); + await reportSuiteStart; - await reporterΩ.suiteError(suite, error as BettererError); - } + await reporterΩ.suiteEnd(suiteSummary); + return suiteSummary; } catch (error) { - await this._started.error(error as BettererError); + // Lifecycle promise is rejected, so it's safe to await + // the result of `reporter.suiteStart`: + suiteΩ.lifecycle.reject(error as BettererError); + await reportSuiteStart; + + await reporterΩ.suiteError(suiteΩ, error as BettererError); throw error; } } - public async stop(): Promise { - const { lastSuite } = await this._started.end(); - return lastSuite; - } - - private _start(): BettererContextStarted { - const { config, results, versionControl } = getGlobals(); - - // Update `reporterΩ` here because `this.options()` may have been called: - const reporterΩ = config.reporter as BettererReporterΩ; - - const contextLifecycle = defer(); + public async stop(): Promise { + try { + const lastSuiteΩ = this.lastSuite as BettererSuiteΩ; + await lastSuiteΩ.lifecycle.promise; + } catch { + // + } - // Don't await here! A custom reporter could be awaiting - // the lifecycle promise which is unresolved right now! - const reportContextStart = reporterΩ.contextStart(this, contextLifecycle.promise); - return { - end: async (): Promise => { - const contextSummary = new BettererContextSummaryΩ(config, this._suiteSummaries); - - // Lifecycle promise is resolved, so it's safe to finally await - // the result of `reporter.contextStart`: - contextLifecycle.resolve(contextSummary); - await reportContextStart; - - await reporterΩ.contextEnd(contextSummary); - - const suiteSummaryΩ = contextSummary.lastSuite as BettererSuiteSummaryΩ; - if (!config.ci) { - const didWrite = await results.api.write(suiteSummaryΩ.result); - if (didWrite && config.precommit) { - await versionControl.api.add(config.resultsPath); - } - } - await versionControl.api.writeCache(); - - return contextSummary; - }, - error: async (error: BettererError): Promise => { - // Lifecycle promise is rejected, so it's safe to finally await - // the result of `reporter.contextStart`: - contextLifecycle.reject(error); - await reportContextStart; - - await reporterΩ.contextError(this, error); - } - }; + return new BettererContextSummaryΩ(this._suiteSummaries); } } diff --git a/packages/betterer/src/context/index.ts b/packages/betterer/src/context/index.ts index 05202daef..4ba7f7fd0 100644 --- a/packages/betterer/src/context/index.ts +++ b/packages/betterer/src/context/index.ts @@ -1,6 +1,4 @@ -export { createContextConfig, enableMode, overrideContextConfig } from './config.js'; -export { BettererContextΩ } from './context.js'; -export { +export type { BettererConfigContext, BettererConfigExcludes, BettererConfigFilters, @@ -20,3 +18,7 @@ export { BettererOptionsModeUpdate, BettererOptionsModeWatch } from './types.js'; + +export { createContextConfig, enableMode, overrideContextConfig } from './config.js'; +export { BettererContextSummaryΩ } from './context-summary.js'; +export { BettererContextΩ } from './context.js'; diff --git a/packages/betterer/src/context/types.ts b/packages/betterer/src/context/types.ts index 211b71fc8..d377b3902 100644 --- a/packages/betterer/src/context/types.ts +++ b/packages/betterer/src/context/types.ts @@ -1,5 +1,3 @@ -import type { BettererError } from '@betterer/errors'; - import type { BettererConfig, BettererOptionsOverride } from '../config/index.js'; import type { BettererSuiteSummaries, BettererSuiteSummary } from '../suite/index.js'; @@ -270,15 +268,13 @@ export interface BettererContext { */ options(optionsOverride: BettererOptionsOverride): Promise; /** - * Stop the test run and clean everything up. If tests are running, waits for them to end before - * stopping. + * Stop the runner, but first wait for it to finish running the current suite. + * + * @returns the {@link @betterer/betterer#BettererContextSummary | `BettererContextSummary`} containing + * details of all successful runs. + * @throws the error if something went wrong while stopping everything. */ - stop(): Promise; -} - -export interface BettererContextStarted { - end(): Promise; - error(error: BettererError): Promise; + stop(): Promise; } /** diff --git a/packages/betterer/src/fs/file-resolver.ts b/packages/betterer/src/fs/file-resolver.ts index 881bfe67e..70e84268e 100644 --- a/packages/betterer/src/fs/file-resolver.ts +++ b/packages/betterer/src/fs/file-resolver.ts @@ -1,16 +1,17 @@ +import type { BettererTestMeta } from '../test/index.js'; import type { BettererFileGlobs, BettererFilePath, BettererFilePaths, BettererFilePatterns, - BettererFileResolver, - BettererVersionControlWorker + BettererFileResolver } from './types.js'; -import assert from 'node:assert'; +import { invariantΔ } from '@betterer/errors'; import minimatch from 'minimatch'; import path from 'node:path'; +import { getGlobals } from '../globals.js'; import { flatten, normalisedPath } from '../utils.js'; import { getTmpPath } from './temp.js'; @@ -18,43 +19,48 @@ export class BettererFileResolverΩ implements BettererFileResolver { private _excluded: Array = []; private _included: Array = []; private _includedResolved: Array | null = null; + private _testName: string | null = null; private _validatedFilePaths: Array = []; private _validatedFilePathsMap: Record = {}; - constructor( - private _baseDirectory: string | null = null, - private _versionControl: BettererVersionControlWorker | null = null - ) {} + constructor(private _baseDirectory: string | null = null) {} public get baseDirectory(): string { - assert(this._baseDirectory); + invariantΔ(this._baseDirectory, '`baseDirectory` is only set once the resolver is initialised!'); return this._baseDirectory; } - public get versionControl(): BettererVersionControlWorker { - assert(this._versionControl); - return this._versionControl; + public get initialised(): boolean { + return !!this._baseDirectory; } - public init(directory: string, versionControl: BettererVersionControlWorker | null): void { - this._baseDirectory = directory; - this._versionControl = versionControl; + public get testName(): string { + invariantΔ(this._testName, '`baseDirectory` is only set once the resolver is initialised!'); + return this._testName; } - public isInitialised(): boolean { - return !!this._baseDirectory; + public init(testMeta: BettererTestMeta): void { + const { configPath, name } = testMeta; + this._testName = name; + this._baseDirectory = path.dirname(configPath); } public async validate(filePaths: BettererFilePaths): Promise { // If `include()` was never called, just filter the given list: if (!this._included.length) { - const validFilePaths = await this.versionControl.api.filterIgnored(filePaths); + const { versionControl } = getGlobals(); + const validFilePaths = await versionControl.api.filterIgnored(filePaths); return validFilePaths.filter((filePath) => !this._isExcluded(filePath)); } await this._update(); return filePaths.filter((filePath) => this._validatedFilePathsMap[filePath]); } + public async filterCached(filePaths: BettererFilePaths): Promise { + const { versionControl } = getGlobals(); + return await versionControl.api.filterCached(this.testName, filePaths); + } + public included(filePaths: BettererFilePaths): BettererFilePaths { if (!this._included.length) { return filePaths; @@ -94,8 +100,10 @@ export class BettererFileResolverΩ implements BettererFileResolver { } private async _update(): Promise { + const { versionControl } = getGlobals(); + this._validatedFilePathsMap = {}; - const filePaths = await this.versionControl.api.getFilePaths(); + const filePaths = await versionControl.api.getFilePaths(); const validatedFilePaths: Array = []; filePaths.forEach((filePath) => { const includedAndNotExcluded = this._isIncluded(filePath) && !this._isExcluded(filePath); diff --git a/packages/betterer/src/globals.ts b/packages/betterer/src/globals.ts index 5f7d0f127..7baf6304d 100644 --- a/packages/betterer/src/globals.ts +++ b/packages/betterer/src/globals.ts @@ -1,7 +1,7 @@ import type { BettererOptions } from './api/index.js'; import type { BettererConfig } from './config/types.js'; -import type { BettererVersionControlWorker } from './fs/index.js'; -import type { BettererReporterΩ } from './reporters/index.js'; +import type { BettererFileResolver, BettererVersionControlWorker } from './fs/index.js'; +import type { BettererReporter, BettererReporterΩ } from './reporters/index.js'; import type { BettererResultsWorker } from './results/index.js'; import type { BettererRunWorkerPool } from './run/types.js'; import type { BettererOptionsWatcher } from './runner/index.js'; @@ -11,12 +11,23 @@ import { BettererError, invariantΔ } from '@betterer/errors'; import { importWorkerΔ } from '@betterer/worker'; import { createContextConfig, enableMode } from './context/index.js'; -import { createFSConfig } from './fs/index.js'; +import { BettererFileResolverΩ, createFSConfig } from './fs/index.js'; import { createReporterConfig, loadDefaultReporter } from './reporters/index.js'; import { createRunWorkerPool } from './run/index.js'; import { createWatcherConfig } from './runner/index.js'; +class BettererGlobalResolvers { + public cwd: BettererFileResolver; + + public constructor(config: BettererConfig) { + this.cwd = new BettererFileResolverΩ(config.cwd); + } +} + class BettererGlobals { + public readonly reporter: BettererReporter = this.config.reporter; + public readonly resolvers: BettererGlobalResolvers = new BettererGlobalResolvers(this.config); + constructor( public readonly config: BettererConfig, public readonly results: BettererResultsWorker, diff --git a/packages/betterer/src/reporters/config.ts b/packages/betterer/src/reporters/config.ts index a9f672e9c..71741a098 100644 --- a/packages/betterer/src/reporters/config.ts +++ b/packages/betterer/src/reporters/config.ts @@ -1,4 +1,3 @@ -import type { BettererConfig } from '../config/index.js'; import type { BettererConfigFS } from '../fs/index.js'; import type { BettererConfigReporter, @@ -8,6 +7,7 @@ import type { } from './types.js'; import { toArray, validateBool } from '../config/index.js'; +import { getGlobals, setGlobals } from '../globals.js'; import { loadReporters, loadSilentReporter } from './loader.js'; export async function createReporterConfig( @@ -32,12 +32,11 @@ export async function createReporterConfig( }; } -export async function overrideReporterConfig( - config: BettererConfig, - optionsOverride: BettererOptionsReporterOverride -): Promise { +export async function overrideReporterConfig(optionsOverride: BettererOptionsReporterOverride): Promise { if (optionsOverride.reporters) { + const { config, results, runWorkerPool, testMetaLoader, versionControl } = getGlobals(); const reporters = toArray(optionsOverride.reporters); config.reporter = await loadReporters(reporters, config.cwd); + setGlobals(config, results, runWorkerPool, testMetaLoader, versionControl); } } diff --git a/packages/betterer/src/results/results-summary.ts b/packages/betterer/src/results/results-summary.ts index fe64e4c5f..865c4a354 100644 --- a/packages/betterer/src/results/results-summary.ts +++ b/packages/betterer/src/results/results-summary.ts @@ -1,11 +1,11 @@ import type { BettererFileTestResultΩ, BettererTest } from '../test/index.js'; +import type { BettererFileResolverΩ } from '../fs/index.js'; import type { BettererFileTestResultSummaryDetails, BettererResultsSummary, BettererResultSummaries } from './types.js'; import { BettererError, isBettererErrorΔ } from '@betterer/errors'; -import { BettererFileResolverΩ } from '../fs/index.js'; import { getGlobals } from '../globals.js'; +import { loadTestFactory } from '../run/index.js'; import { isBettererFileTest, isBettererResolverTest, isBettererTest } from '../test/index.js'; -import { loadTestFactory } from '../run/worker-run.js'; export class BettererResultsSummaryΩ implements BettererResultsSummary { public readonly resultSummaries: BettererResultSummaries; @@ -17,8 +17,8 @@ export class BettererResultsSummaryΩ implements BettererResultsSummary { } public static async create(): Promise { - const { config, results, testMetaLoader, versionControl } = getGlobals(); - const { configPaths, cwd, filters, includes, excludes, resultsPath } = config; + const { config, resolvers, results, testMetaLoader, versionControl } = getGlobals(); + const { configPaths, filters, includes, excludes, resultsPath } = config; try { let testsMeta = await testMetaLoader.api.loadTestsMeta(configPaths); @@ -26,11 +26,11 @@ export class BettererResultsSummaryΩ implements BettererResultsSummary { testsMeta = testsMeta.filter((testMeta) => filters.some((filter) => filter.test(testMeta.name))); } - const resolver = new BettererFileResolverΩ(cwd, versionControl); - resolver.include(...includes); - resolver.exclude(...excludes); + const resolverΩ = resolvers.cwd as BettererFileResolverΩ; + resolverΩ.include(...includes); + resolverΩ.exclude(...excludes); - const filePaths = await resolver.files(); + const filePaths = await resolverΩ.files(); const onlyFileTests = includes.length > 0 || excludes.length > 0; diff --git a/packages/betterer/src/results/results.worker.ts b/packages/betterer/src/results/results.worker.ts index 8ca2450cc..f152ea224 100644 --- a/packages/betterer/src/results/results.worker.ts +++ b/packages/betterer/src/results/results.worker.ts @@ -4,6 +4,7 @@ import type { BettererResultsSerialised } from './types.js'; import { invariantΔ } from '@betterer/errors'; import { exposeToMainΔ } from '@betterer/worker'; + import { BettererResultsΩ } from './results.js'; let results: BettererResultsΩ | null = null; @@ -38,9 +39,9 @@ export function hasBaseline(testName: string): boolean { } /** @knipignore part of worker API */ -export function write(result: BettererResultsSerialised): Promise { +export async function write(result: BettererResultsSerialised): Promise { checkInitialised(results); - return results.write(result); + return await results.write(result); } function checkInitialised(results: BettererResultsΩ | null): asserts results is BettererResultsΩ { diff --git a/packages/betterer/src/run/index.ts b/packages/betterer/src/run/index.ts index 277b60160..33dce01c9 100644 --- a/packages/betterer/src/run/index.ts +++ b/packages/betterer/src/run/index.ts @@ -1,6 +1,5 @@ export type { BettererDelta, - BettererReporterRun, BettererRun, BettererRunSummaries, BettererRunSummary, @@ -10,4 +9,5 @@ export type { export { createRunWorkerPool } from './run-worker-pool.js'; export { BettererRunΩ } from './run.js'; -export { BettererWorkerRunΩ } from './worker-run.js'; +export { BettererRunObsoleteΩ } from './run-obsolete.js'; +export { BettererWorkerRunΩ, loadTestFactory } from './worker-run.js'; diff --git a/packages/betterer/src/run/run-obsolete.ts b/packages/betterer/src/run/run-obsolete.ts index 97983d9f0..39300745e 100644 --- a/packages/betterer/src/run/run-obsolete.ts +++ b/packages/betterer/src/run/run-obsolete.ts @@ -1,16 +1,18 @@ import type { BettererResult } from '../results/index.js'; import type { BettererRun, BettererRunSummary } from './types.js'; +import { defer } from '../utils.js'; import { BettererRunSummaryΩ } from './run-summary.js'; export class BettererRunObsoleteΩ implements BettererRun { public readonly expected: BettererResult; + public readonly filePaths = null; public readonly isNew = false; public readonly isObsolete = true; public readonly isOnly = false; public readonly isRemoved: boolean; public readonly isSkipped = false; - public readonly filePaths = null; + public readonly lifecycle = defer(); constructor( public readonly name: string, diff --git a/packages/betterer/src/run/run.ts b/packages/betterer/src/run/run.ts index 17c545606..ddb5574ea 100644 --- a/packages/betterer/src/run/run.ts +++ b/packages/betterer/src/run/run.ts @@ -8,11 +8,13 @@ import type { BettererRun, BettererRunSummary, BettererRunWorkerHandle } from '. import { getTimeΔ } from '@betterer/time'; -import { BettererResultΩ } from '../results/index.js'; import { getGlobals } from '../globals.js'; +import { BettererResultΩ } from '../results/index.js'; +import { defer } from '../utils.js'; import { BettererRunSummaryΩ } from './run-summary.js'; export class BettererRunΩ implements BettererRun { + public readonly lifecycle = defer(); public readonly isNew: boolean; public readonly isObsolete = false; public readonly isOnly: boolean; @@ -40,8 +42,7 @@ export class BettererRunΩ implements BettererRun { } public static async create(testMeta: BettererTestMeta, filePaths: BettererFilePaths): Promise { - const globals = getGlobals(); - const { config, results, runWorkerPool, versionControl } = globals; + const { config, results, runWorkerPool, versionControl } = getGlobals(); const workerHandle = runWorkerPool.getWorkerHandle(); const worker = await workerHandle.claim(); diff --git a/packages/betterer/src/run/types.ts b/packages/betterer/src/run/types.ts index 6cc77fc75..3102f2027 100644 --- a/packages/betterer/src/run/types.ts +++ b/packages/betterer/src/run/types.ts @@ -114,10 +114,6 @@ export interface BettererRun { */ export type BettererRuns = ReadonlyArray; -export type BettererReporterRun = BettererRun & { - lifecycle: Promise; -}; - export interface BettererRunning { done(result: BettererResult): Promise; skipped(): Promise; diff --git a/packages/betterer/src/run/worker-run.ts b/packages/betterer/src/run/worker-run.ts index e4e27c856..7a35e1525 100644 --- a/packages/betterer/src/run/worker-run.ts +++ b/packages/betterer/src/run/worker-run.ts @@ -2,11 +2,11 @@ import type { BettererConfig } from '../config/index.js'; import type { BettererFilePaths, BettererVersionControlWorker } from '../fs/index.js'; import type { BettererResult, BettererResultsWorker } from '../results/index.js'; import type { + BettererTest, BettererTestConfig, - BettererTestMeta, BettererTestFactory, BettererTestMap, - BettererTest + BettererTestMeta } from '../test/index.js'; import type { BettererRunMeta } from './meta/index.js'; import type { BettererRun, BettererRunning, BettererRunningEnd, BettererRunSummary } from './types.js'; @@ -16,11 +16,11 @@ import { BettererError, isBettererErrorΔ } from '@betterer/errors'; import assert from 'node:assert'; import { forceRelativePaths, importDefault } from '../fs/index.js'; +import { getGlobals, setGlobals } from '../globals.js'; import { BettererResultΩ } from '../results/index.js'; import { isBettererResolverTest, isBettererTest } from '../test/index.js'; -import { BettererRunSummaryΩ } from './run-summary.js'; import { isFunction } from '../utils.js'; -import { getGlobals, setGlobals } from '../globals.js'; +import { BettererRunSummaryΩ } from './run-summary.js'; export class BettererWorkerRunΩ implements BettererRun { public readonly isNew: boolean; @@ -106,8 +106,8 @@ export class BettererWorkerRunΩ implements BettererRun { const { resultsPath } = config; if (!this.runMeta.isNew) { - this._baseline = this._deserialise(config.resultsPath, await results.api.getBaseline(this.name)); - this._expected = this._deserialise(config.resultsPath, await results.api.getExpected(this.name)); + this._baseline = this._deserialise(await results.api.getBaseline(this.name)); + this._expected = this._deserialise(await results.api.getExpected(this.name)); } const running = this._run(timestamp); @@ -127,20 +127,22 @@ export class BettererWorkerRunΩ implements BettererRun { this._filePaths = newFilePaths; } - private _deserialise(resultsPath: string, resultJSON: string): BettererResultΩ | null { + private _deserialise(resultJSON: string): BettererResultΩ | null { try { const serialised = JSON.parse(resultJSON) as unknown; const { deserialise } = this.test.serialiser; - return new BettererResultΩ(deserialise(serialised, resultsPath), resultJSON); + const { config } = getGlobals(); + return new BettererResultΩ(deserialise(serialised, config.resultsPath), resultJSON); } catch { return null; } } - private _serialise(resultsPath: string, deserialised: BettererResult): BettererResultΩ | null { + private _serialise(deserialised: BettererResult): BettererResultΩ | null { try { const { serialise } = this.test.serialiser; - return new BettererResultΩ(serialise(deserialised.value, resultsPath), deserialised.printed); + const { config } = getGlobals(); + return new BettererResultΩ(serialise(deserialised.value, config.resultsPath), deserialised.printed); } catch { return null; } @@ -171,12 +173,9 @@ export class BettererWorkerRunΩ implements BettererRun { private async _end(end: BettererRunningEnd): Promise { const { comparison, diff, result, timestamp, isSkipped } = end; const { config, versionControl } = getGlobals(); - const { resultsPath } = config; - - const isWorse = comparison === BettererConstraintResult.worse && !config.update; - const isUpdated = comparison === BettererConstraintResult.worse && config.update; - const { ci } = config; + const isWorse = comparison === BettererConstraintResult.worse; + const isUpdated = isWorse && config.update; const isComplete = !!result && (await this.test.goal(result.value)); const isExpired = timestamp >= this.test.deadline; @@ -185,7 +184,7 @@ export class BettererWorkerRunΩ implements BettererRun { const baselineValue = this.isNew ? null : this.baseline.value; const delta = result ? await this.test.progress(baselineValue, result.value) : null; - if (this.runMeta.needsFilePaths && !ci) { + if (this.runMeta.needsFilePaths && !config.ci) { if (isComplete) { await versionControl.api.clearCache(this.name); } else if (shouldPrint && !isWorse) { @@ -194,9 +193,9 @@ export class BettererWorkerRunΩ implements BettererRun { } // Make sure to use the serialised result so it can be passed back to the main thread: - const serialisedResult = result ? this._serialise(resultsPath, result) : null; - const serialisedBaseline = !this.isNew ? this._serialise(resultsPath, this.baseline) : null; - const serialisedExpected = !this.isNew ? this._serialise(resultsPath, this.expected) : null; + const serialisedResult = result ? this._serialise(result) : null; + const serialisedBaseline = !this.isNew ? this._serialise(this.baseline) : null; + const serialisedExpected = !this.isNew ? this._serialise(this.expected) : null; return new BettererRunSummaryΩ({ baseline: serialisedBaseline, diff --git a/packages/betterer/src/runner/config.ts b/packages/betterer/src/runner/config.ts index b8ca90451..acb21bc74 100644 --- a/packages/betterer/src/runner/config.ts +++ b/packages/betterer/src/runner/config.ts @@ -1,8 +1,8 @@ -import type { BettererConfig } from '../config/index.js'; import type { BettererConfigFS } from '../fs/index.js'; import type { BettererConfigWatcher, BettererOptionsWatcher, BettererOptionsWatcherOverride } from './types.js'; import { toArray, validateBool, validateStringArray } from '../config/index.js'; +import { getGlobals } from '../globals.js'; export function createWatcherConfig( configFS: BettererConfigFS, @@ -17,8 +17,9 @@ export function createWatcherConfig( return { ...configFS, ignores, watch }; } -export function overrideWatchConfig(config: BettererConfig, optionsOverride: BettererOptionsWatcherOverride): void { +export function overrideWatchConfig(optionsOverride: BettererOptionsWatcherOverride): void { if (optionsOverride.ignores) { + const { config } = getGlobals(); validateStringArray({ ignores: optionsOverride.ignores }); config.ignores = toArray(optionsOverride.ignores); } diff --git a/packages/betterer/src/runner/runner.ts b/packages/betterer/src/runner/runner.ts index a4e3a9063..f2a1fb05b 100644 --- a/packages/betterer/src/runner/runner.ts +++ b/packages/betterer/src/runner/runner.ts @@ -1,56 +1,75 @@ import type { FSWatcher } from 'chokidar'; import type { BettererOptions } from '../api/index.js'; -import type { BettererOptionsOverride } from '../config/index.js'; +import type { BettererConfig, BettererOptionsOverride } from '../config/index.js'; +import type { BettererContextSummary } from '../context/index.js'; import type { BettererFilePaths } from '../fs/index.js'; -import type { BettererSuiteSummary } from '../suite/index.js'; +import type { BettererReporterΩ } from '../reporters/index.js'; +import type { BettererSuiteSummary, BettererSuiteSummaryΩ } from '../suite/index.js'; import type { BettererOptionsWatcher, BettererRunner } from './types.js'; import { BettererError } from '@betterer/errors'; import { BettererContextΩ } from '../context/index.js'; import { createGlobals, destroyGlobals, getGlobals } from '../globals.js'; -import { normalisedPath } from '../utils.js'; +import { defer, normalisedPath } from '../utils.js'; import { createWatcher, WATCHER_EVENTS } from './watcher.js'; const DEBOUNCE_TIME = 200; export class BettererRunnerΩ implements BettererRunner { - private _jobs: Array = []; - private _running: Promise | null = null; + public config: BettererConfig; + public readonly lifecycle = defer(); + + private _reporterContextStart: Promise; + private _isRunOnce = false; private _isStopped = false; + private _jobs: Array = []; + private _running: Promise | null = null; + private _sigterm = this.stop.bind(this); private constructor( private readonly _context: BettererContextΩ, private readonly _watcher: FSWatcher | null - ) {} + ) { + const { config, reporter } = getGlobals(); + const reporterΩ = reporter as BettererReporterΩ; + + this.config = config; + + // Don't await here! A custom reporter could be awaiting + // the lifecycle promise which is unresolved right now! + this._reporterContextStart = reporterΩ.contextStart(this, this.lifecycle.promise); + + // eslint-disable-next-line @typescript-eslint/no-misused-promises -- SIGTERM doesn't care about Promises + process.on('SIGTERM', this._sigterm); + + if (this._watcher) { + this._watcher.on('all', (event: string, filePath: string) => { + if (WATCHER_EVENTS.includes(event)) { + void this.queue([filePath]); + } + }); + } + } public static async create( options: BettererOptions, optionsWatch: BettererOptionsWatcher = {} ): Promise { await createGlobals(options, optionsWatch); - const { config } = getGlobals(); - const watcher = await createWatcher(config); + const watcher = await createWatcher(); const context = new BettererContextΩ(); - const runner = new BettererRunnerΩ(context, watcher); - - if (watcher) { - watcher.on('all', (event: string, filePath: string) => { - if (WATCHER_EVENTS.includes(event)) { - void runner.queue([filePath]); - } - }); - } - return runner; + return new BettererRunnerΩ(context, watcher); } public async options(optionsOverride: BettererOptionsOverride): Promise { await this._context.options(optionsOverride); } - public async run(): Promise { - await this._context.runOnce(); + public async run(): Promise { + this._isRunOnce = true; + await this.queue([]); return await this.stop(); } @@ -60,19 +79,23 @@ export class BettererRunnerΩ implements BettererRunner { throw new BettererError('You cannot queue a test run after the runner has been stopped! 💥'); } this._addJob(filePaths); - return new Promise((resolve) => { + return new Promise((resolve, reject) => { setTimeout(() => { void (async () => { - await this._processQueue(); - resolve(); + try { + await this._processQueue(); + resolve(); + } catch (error) { + reject(error as BettererError); + } })(); }, DEBOUNCE_TIME); }); } - public async stop(): Promise; - public async stop(force: true): Promise; - public async stop(force?: true): Promise { + public async stop(): Promise; + public async stop(force: true): Promise; + public async stop(force?: true): Promise { try { this._isStopped = true; if (!force) { @@ -81,13 +104,38 @@ export class BettererRunnerΩ implements BettererRunner { if (this._watcher) { await this._watcher.close(); } - return await this._context.stop(); + + const contextSummary = await this._context.stop(); + + // Lifecycle promise is resolved, so it's safe to await + // the result of `reporter.contextStart`: + this.lifecycle.resolve(contextSummary); + await this._reporterContextStart; + + const { config, reporter, results, versionControl } = getGlobals(); + const reporterΩ = reporter as BettererReporterΩ; + + await reporterΩ.contextEnd(contextSummary); + + const suiteSummaryΩ = contextSummary.lastSuite as BettererSuiteSummaryΩ; + if (!config.ci) { + const didWrite = await results.api.write(suiteSummaryΩ.result); + if (didWrite && config.precommit) { + await versionControl.api.add(config.resultsPath); + } + } + await versionControl.api.writeCache(); + + return contextSummary; } catch (error) { if (force) { return null; } throw error; } finally { + // eslint-disable-next-line @typescript-eslint/no-misused-promises -- SIGTERM doesn't care about Promises + process.off('SIGTERM', this._sigterm); + await destroyGlobals(); } } @@ -114,11 +162,23 @@ export class BettererRunnerΩ implements BettererRunner { const runPaths = Array.from(filePaths).sort(); this._jobs = []; - this._running = this._context.run(runPaths); + const { versionControl } = getGlobals(); + + await versionControl.api.sync(); + + this._running = this._context.run(runPaths, this._isRunOnce); try { await this._running; - } catch { - // Errors will be handled by reporters + } catch (error) { + // Lifecycle promise is rejected, so it's safe to await + // the result of `reporter.contextStart`: + this.lifecycle.reject(error as BettererError); + await this._reporterContextStart; + + const { reporter } = getGlobals(); + const reporterΩ = reporter as BettererReporterΩ; + await reporterΩ.contextError(this, error as BettererError); + throw error; } } } diff --git a/packages/betterer/src/runner/types.ts b/packages/betterer/src/runner/types.ts index baf39366f..86ce8aab3 100644 --- a/packages/betterer/src/runner/types.ts +++ b/packages/betterer/src/runner/types.ts @@ -1,6 +1,5 @@ -import type { BettererOptionsOverride } from '../config/index.js'; +import type { BettererContext, BettererContextSummary } from '../context/types.js'; import type { BettererFilePaths } from '../fs/index.js'; -import type { BettererSuiteSummary } from '../suite/index.js'; /** * @public A {@link https://www.npmjs.com/package/glob#user-content-glob-primer | glob} pattern @@ -73,11 +72,7 @@ export interface BettererConfigWatcher { /** * @public The JS API for controlling **Betterer** runs. */ -export interface BettererRunner { - /** - * Make changes to the runner config. The updated config will be used for the next run. - */ - options(optionsOverride: BettererOptionsOverride): Promise; +export interface BettererRunner extends BettererContext { /** * Queue a **Betterer** run. * @@ -88,18 +83,19 @@ export interface BettererRunner { */ queue(filePaths?: string | BettererFilePaths): Promise; /** - * Stop the runner, but first wait for it to finish running the suite. + * Stop the runner, but first wait for it to finish running the current suite. * - * @returns the most recent {@link @betterer/betterer#BettererSuiteSummary | `BettererSuiteSummary`}. + * @returns the {@link @betterer/betterer#BettererContextSummary | `BettererContextSummary`} containing + * details of all successful runs. * @throws the error if something went wrong while stopping everything. */ - stop(): Promise; + stop(): Promise; /** * Stop the runner, without waiting for it to finish running the suite. * * @param force - when `true`, the runner will stop immediately and any errors will be ignored. - * @returns the most recent {@link @betterer/betterer#BettererSuiteSummary | `BettererSuiteSummary`}. - * (or `null` if a run hasn't finished yet). + * @returns the {@link @betterer/betterer#BettererContextSummary | `BettererContextSummary`} containing + * details of all successful runs, (or `null` if a run hasn't finished yet). */ - stop(force: true): Promise; + stop(force?: true): Promise; } diff --git a/packages/betterer/src/runner/watcher.ts b/packages/betterer/src/runner/watcher.ts index 227521f7a..9a65eb2a6 100644 --- a/packages/betterer/src/runner/watcher.ts +++ b/packages/betterer/src/runner/watcher.ts @@ -1,17 +1,17 @@ import type { FSWatcher } from 'chokidar'; -import type { BettererConfig } from '../config/index.js'; - import { watch } from 'chokidar'; import minimatch from 'minimatch'; import path from 'node:path'; import { isTempFilePath } from '../fs/index.js'; +import { getGlobals } from '../globals.js'; import { normalisedPath } from '../utils.js'; export const WATCHER_EVENTS = ['add', 'change']; -export async function createWatcher(config: BettererConfig): Promise { +export async function createWatcher(): Promise { + const { config } = getGlobals(); if (!config.watch) { return null; } diff --git a/packages/betterer/src/suite/index.ts b/packages/betterer/src/suite/index.ts index 7ebf052b2..e29c9305b 100644 --- a/packages/betterer/src/suite/index.ts +++ b/packages/betterer/src/suite/index.ts @@ -1,3 +1,3 @@ export { BettererSuiteSummaryΩ } from './suite-summary.js'; export { BettererSuiteΩ } from './suite.js'; -export { BettererSuite, BettererSuiteSummaries, BettererSuiteSummary } from './types.js'; +export { BettererSuite, BettererSuiteSummaries, BettererSuiteSummary, BettererSuites } from './types.js'; diff --git a/packages/betterer/src/suite/suite-summary.ts b/packages/betterer/src/suite/suite-summary.ts index 8198bc7f9..b420286f9 100644 --- a/packages/betterer/src/suite/suite-summary.ts +++ b/packages/betterer/src/suite/suite-summary.ts @@ -90,13 +90,13 @@ export class BettererSuiteSummaryΩ implements BettererSuiteSummary { private _mergeResult(): BettererResultsSerialised { return this.runSummaries.reduce((results, runSummary) => { - const { isFailed, isSkipped, isNew, isObsolete, isRemoved, isWorse } = runSummary; + const { isFailed, isSkipped, isNew, isObsolete, isRemoved, isWorse, isUpdated } = runSummary; const isSkippedOrFailed = isSkipped || isFailed; if (isRemoved || (isSkippedOrFailed && isNew)) { return results; } const { expected, name, result } = runSummary; - if ((isSkippedOrFailed && !isNew) || isWorse || isObsolete) { + if ((isSkippedOrFailed && !isNew) || (isWorse && !isUpdated) || isObsolete) { invariantΔ(expected, 'Test has successfully run in the past so it must have an expected result!'); results[name] = { value: expected.printed }; return results; diff --git a/packages/betterer/src/suite/suite.ts b/packages/betterer/src/suite/suite.ts index 24947a1eb..96bf2608b 100644 --- a/packages/betterer/src/suite/suite.ts +++ b/packages/betterer/src/suite/suite.ts @@ -2,21 +2,22 @@ import type { BettererError } from '@betterer/errors'; import type { BettererFilePaths } from '../fs/index.js'; import type { BettererReporterΩ } from '../reporters/index.js'; -import type { BettererReporterRun, BettererRunSummary, BettererRuns } from '../run/index.js'; +import type { BettererRuns } from '../run/index.js'; import type { BettererSuite, BettererSuiteSummary } from './types.js'; import { invariantΔ } from '@betterer/errors'; +import { getGlobals } from '../globals.js'; +import { BettererResultΩ } from '../results/index.js'; +import { BettererRunΩ, BettererRunObsoleteΩ } from '../run/index.js'; import { defer } from '../utils.js'; import { BettererSuiteSummaryΩ } from './suite-summary.js'; -import { BettererRunΩ } from '../run/index.js'; -import { getGlobals } from '../globals.js'; -import { BettererRunObsoleteΩ } from '../run/run-obsolete.js'; -import { BettererResultΩ } from '../results/result.js'; const NEGATIVE_FILTER_TOKEN = '!'; export class BettererSuiteΩ implements BettererSuite { + public readonly lifecycle = defer(); + private constructor( public filePaths: BettererFilePaths, public runs: BettererRuns @@ -56,15 +57,10 @@ export class BettererSuiteΩ implements BettererSuite { const runSummaries = await Promise.all( this.runs.map(async (run) => { - // Attach lifecycle promise for Reporters: - const lifecycle = defer(); - (run as BettererReporterRun).lifecycle = lifecycle.promise; - const runΩ = run as BettererRunΩ; const { config } = getGlobals(); - const { filters, reporter } = config; - const reporterΩ = reporter as BettererReporterΩ; + const { filters } = config; // This is all a bit backwards because "filters" is named badly. const hasFilters = !!filters.length; @@ -98,9 +94,12 @@ export class BettererSuiteΩ implements BettererSuite { const isOtherTestOnly = hasOnly && !runΩ.isOnly; const isFiltered = (hasFilters && !isSelected) || isOtherTestOnly; + const { reporter } = getGlobals(); + const reporterΩ = reporter as BettererReporterΩ; + // Don't await here! A custom reporter could be awaiting // the lifecycle promise which is unresolved right now! - const reportRunStart = reporterΩ.runStart(runΩ, lifecycle.promise); + const reportRunStart = reporterΩ.runStart(runΩ, runΩ.lifecycle.promise); const runSummary = await runΩ.run(isFiltered); @@ -111,11 +110,17 @@ export class BettererSuiteΩ implements BettererSuite { if (runSummary.isFailed) { const { error } = runSummary; invariantΔ(error, 'A failed run will always have an `error`!'); - lifecycle.reject(error); + runΩ.lifecycle.reject(error); + + // Lifecycle promise is resolved, so it's safe to await + // the result of `reporter.runStart`: await reportRunStart; await reporterΩ.runError(runΩ, error as BettererError); } else { - lifecycle.resolve(runSummary); + runΩ.lifecycle.resolve(runSummary); + + // Lifecycle promise is resolved, so it's safe to await + // the result of `reporter.runStart`: await reportRunStart; await reporterΩ.runEnd(runSummary); } diff --git a/packages/betterer/src/suite/types.ts b/packages/betterer/src/suite/types.ts index 50ee2234f..25be4d39e 100644 --- a/packages/betterer/src/suite/types.ts +++ b/packages/betterer/src/suite/types.ts @@ -40,6 +40,8 @@ export interface BettererSuite { readonly runs: BettererRuns; } +export type BettererSuites = Array; + /** * @public The summary of a {@link @betterer/betterer#BettererSuite | `BettererSuite`} suite. Includes * everything from {@link @betterer/betterer#BettererSuite | `BettererSuite`}. diff --git a/packages/betterer/src/test/file-test/differ.ts b/packages/betterer/src/test/file-test/differ.ts index e791ff373..6f45827a7 100644 --- a/packages/betterer/src/test/file-test/differ.ts +++ b/packages/betterer/src/test/file-test/differ.ts @@ -1,4 +1,4 @@ -import type { BettererLogs } from '@betterer/logger'; +import type { BettererLogger, BettererLogs } from '@betterer/logger'; import type { BettererFileΩ } from './file.js'; import type { BettererFileTestResultΩ } from './file-test-result.js'; @@ -159,19 +159,33 @@ export function differ(expected: BettererFileTestResult, result: BettererFileTes const diffEntries = Object.entries(diff); const logs: BettererLogs = []; + diffEntries.forEach(([filePath, diff]) => { const existing = diff.existing ?? []; const fixed = diff.fixed ?? []; - if (fixed.length) { - logs.push({ success: `${String(fixed.length)} fixed ${getIssues(fixed.length)} in "${filePath}".` }); - } - if (existing.length) { - logs.push({ warn: `${String(existing.length)} existing ${getIssues(existing.length)} in "${filePath}".` }); - } const newIssues = diff.new ?? []; + const nExisting = existing.length; + const nFixed = fixed.length; const nIssues = newIssues.length; + + if (nFixed || nExisting || nIssues) { + let type: keyof BettererLogger = 'success'; + const messages: Array = []; + if (nFixed > 0) { + messages.push(`${FORMATTER.format(nFixed)} fixed`); + } + if (nExisting > 0) { + type = 'warn'; + messages.push(`${FORMATTER.format(nExisting)} existing`); + } + if (nIssues > 0) { + type = 'error'; + messages.push(`${FORMATTER.format(nIssues)} new`); + } + logs.push({ [type]: `${messages.join(', ')} ${getIssues(nFixed + nExisting + nIssues)} in "${filePath}".` }); + } + if (nIssues) { - logs.push({ error: `New ${getIssues(nIssues)} in "${filePath}"!` }); if (nIssues > 1) { logs.push({ error: `Showing first of ${FORMATTER.format(nIssues)} new issues:` }); } diff --git a/packages/betterer/src/test/resolver-test/resolver-test.ts b/packages/betterer/src/test/resolver-test/resolver-test.ts index ca0e07900..386967de7 100644 --- a/packages/betterer/src/test/resolver-test/resolver-test.ts +++ b/packages/betterer/src/test/resolver-test/resolver-test.ts @@ -1,18 +1,17 @@ -import type { BettererRun, BettererWorkerRunΩ } from '../../run/index.js'; -import type { BettererFileTestResultΩ } from '../file-test/index.js'; import type { BettererFileGlobs, BettererFilePaths, BettererFilePatterns, BettererFileResolver } from '../../fs/index.js'; +import type { BettererRun, BettererWorkerRunΩ } from '../../run/index.js'; +import type { BettererFileTestResultΩ } from '../file-test/index.js'; import type { BettererTestOptions } from '../types.js'; -import path from 'node:path'; +import { BettererError, invariantΔ } from '@betterer/errors'; + import { BettererFileResolverΩ } from '../../fs/index.js'; -import { getGlobals } from '../../globals.js'; import { BettererTest } from '../test.js'; -import { BettererError, invariantΔ } from '@betterer/errors'; import { checkBaseName } from '../utils.js'; /** @@ -34,8 +33,8 @@ export class BettererResolverTest< ...options, test: async (run: BettererRun): Promise => { const runΩ = run as BettererWorkerRunΩ; - const { versionControl } = getGlobals(); - this._resolverΩ.init(path.dirname(runΩ.testMeta.configPath), versionControl); + + this._resolverΩ.init(runΩ.testMeta); const { filePaths } = runΩ; invariantΔ(filePaths, `\`filePaths\` should always exist for a \`BettererResolverTest\` run!`); @@ -59,7 +58,7 @@ export class BettererResolverTest< let isFullRun = filePathsForThisRun === testFiles; if (!run.isNew) { - const cacheMisses = await versionControl.api.filterCached(run.name, filePathsForThisRun); + const cacheMisses = await this._resolverΩ.filterCached(filePathsForThisRun); isFullRun = isFullRun && cacheMisses.length === filePathsForThisRun.length; filePathsForThisRun = cacheMisses; } @@ -96,7 +95,7 @@ export class BettererResolverTest< * the `test()` function is being executed. */ public get resolver(): BettererFileResolver { - if (!this._resolverΩ.isInitialised()) { + if (!this._resolverΩ.initialised) { throw new BettererError('`resolver` can only be used while the `test` function is being executed. ❌'); } return this._resolverΩ; diff --git a/packages/betterer/src/utils.ts b/packages/betterer/src/utils.ts index c637a9789..96c22bde2 100644 --- a/packages/betterer/src/utils.ts +++ b/packages/betterer/src/utils.ts @@ -32,7 +32,8 @@ export function normalisedPath(filePath: string): string { type Resolve = (value: T) => void; type Reject = (error: Error) => void; -interface Defer { +/** @knipignore */ +export interface Defer { promise: Promise; resolve: Resolve; reject: Reject; diff --git a/packages/fixture/src/fs.ts b/packages/fixture/src/fs.ts index efb3846e6..92be91f5c 100644 --- a/packages/fixture/src/fs.ts +++ b/packages/fixture/src/fs.ts @@ -16,7 +16,7 @@ export async function createFixtureFS( } function normalisedPath(filePath: string): string { - return path.sep === path.posix.sep ? filePath : filePath.split(path.sep).join(path.posix.sep); + return filePath.split(path.sep).join(path.posix.sep); } async function cleanup(): Promise { diff --git a/packages/fixture/src/logging.ts b/packages/fixture/src/logging.ts index 4e8ad6f7f..b316378d5 100644 --- a/packages/fixture/src/logging.ts +++ b/packages/fixture/src/logging.ts @@ -1,12 +1,9 @@ import type { FixtureLogs, FixtureLogsMap, FixtureOptions } from './types.js'; -import path from 'node:path'; - import { getStdOutΔ } from '@betterer/render'; import ansiRegex from 'ansi-regex'; const ANSI_REGEX = ansiRegex(); -const PROJECT_REGEXP = new RegExp(normalisedPath(process.cwd()), 'g'); const STACK_TRACK_LINE_REGEXP = /^\s+at\s+/; const FIXTURE_LOGS_MAP: FixtureLogsMap = {}; @@ -27,11 +24,7 @@ export function createFixtureLogs(fixtureName: string, options: FixtureOptions = } const lines = message.replace(/\r/g, '').split('\n'); const filteredLines = lines.filter((line) => !isStackTraceLine(line)); - const formattedLines = filteredLines.map((line) => { - line = replaceProjectPath(normalisedPath(line)); - line = line.trimEnd(); - return line; - }); + const formattedLines = filteredLines.map((line) => line.trimEnd()); message = formattedLines.join('\n'); const trimmed = message.trim(); if (trimmed.length === 0) { @@ -73,11 +66,3 @@ function isFiltered(str: string, options: FixtureOptions): boolean { const filters = options.logFilters ?? []; return filters.some((filter) => !!filter.exec(str)); } - -function replaceProjectPath(str: string): string { - return str.replace(PROJECT_REGEXP, ''); -} - -function normalisedPath(str: string): string { - return str.split(path.win32.sep).join(path.posix.sep); -} diff --git a/packages/logger/src/code.ts b/packages/logger/src/code.ts index f85307c65..c308489d4 100644 --- a/packages/logger/src/code.ts +++ b/packages/logger/src/code.ts @@ -33,6 +33,6 @@ export function codeΔ(codeInfo: BettererLoggerCodeInfo): string { line: endLocation.line + 1, column: endLocation.column + 1 }; - // `codeFrameColumns` doesn't handle empty strings very well! - return `\n ${filePath}\n${codeFrameColumns(fileText || ' ', { start, end }, options)}\n`; + // `codeFrameColumns` doesn't handle empty strings very well, so add some whitespace! + return `\n${codeFrameColumns(fileText || ' ', { start, end }, options)}\n`; } diff --git a/packages/render/src/index.ts b/packages/render/src/index.ts index fb94f2a26..a709d6d7a 100644 --- a/packages/render/src/index.ts +++ b/packages/render/src/index.ts @@ -26,7 +26,7 @@ export const React = R; * * Re-exported from `ink` */ -export type { Instance, RenderOptions, TextProps } from 'ink'; +export type { Instance, RenderOptions } from 'ink'; /** * @internal This could change at any point! Please don't use! @@ -40,7 +40,14 @@ export type { FC, PropsWithChildren } from 'react'; * * Re-exported from `ink` */ -export { render, Box, Text, useApp, useInput, useStdin } from 'ink'; +export { render, Box, useApp, useInput, useStdin } from 'ink'; + +/** + * @internal This could change at any point! Please don't use! + * + * Re-exported from `ink`, but modified to remove process.cwd() from any text + */ +export { Text, TextProps } from './text.js'; /** * @internal This could change at any point! Please don't use! diff --git a/packages/render/src/text.tsx b/packages/render/src/text.tsx new file mode 100644 index 000000000..42b0daf81 --- /dev/null +++ b/packages/render/src/text.tsx @@ -0,0 +1,34 @@ +import type { TextProps } from 'ink'; + +import { Text as InkText } from 'ink'; +import React from 'react'; +import path from 'node:path'; + +export type { TextProps } from 'ink'; + +/** + * @internal This could change at any point! Please don't use! + * + * Re-exported from `ink`, but modified to remove process.cwd() from any text + */ +export const Text: React.FC = (props) => { + const { children, ...rest } = props; + const stripped = Array.isArray(children) ? children.map(stripCwd) : [children].map(stripCwd); + return {stripped}; +}; + +function stripCwd(log: React.ReactNode): React.ReactNode { + if (typeof log !== 'string') { + return log; + } + const processDir = path.join(process.cwd(), path.sep); + return log.replaceAll(toPosixPath(processDir), '').replaceAll(toWin32Path(processDir), '').replaceAll('file://', ''); +} + +function toPosixPath(str: string): string { + return str.split(path.sep).join(path.posix.sep); +} + +function toWin32Path(str: string): string { + return str.split(path.sep).join(path.win32.sep); +} diff --git a/packages/reporter/src/components/suite/deltas/file-test-delta.ts b/packages/reporter/src/components/suite/deltas/file-test-delta.ts index 5f9008f52..66e2b3b2b 100644 --- a/packages/reporter/src/components/suite/deltas/file-test-delta.ts +++ b/packages/reporter/src/components/suite/deltas/file-test-delta.ts @@ -18,7 +18,8 @@ export function fileTestDelta(delta: BettererDelta | null): string | null { } if (baseline != null && diff > 0) { const diffFormatted = formatter.format(diff); - return ` (${diffFormatted} new ${diffIssues}, ${resultFormatted} total)`; + const existingFormatted = formatter.format(result - diff); + return ` (${diffFormatted} new ${diffIssues}, ${existingFormatted} existing, ${resultFormatted} total)`; } return ''; } diff --git a/packages/reporter/src/components/suite/tasks.ts b/packages/reporter/src/components/suite/tasks.ts index 9c9b80543..305316dbc 100644 --- a/packages/reporter/src/components/suite/tasks.ts +++ b/packages/reporter/src/components/suite/tasks.ts @@ -36,7 +36,7 @@ export function useTask(run: BettererRun): BettererTask { const name = quote(run.name); await logger.progress(testRunning(name)); - const runSummary = await (run as BettererReporterRun).lifecycle; + const runSummary = await (run as BettererReporterRun).lifecycle.promise; if (runSummary.isExpired) { await logger.warn(testExpired(name)); diff --git a/packages/reporter/src/reporter.tsx b/packages/reporter/src/reporter.tsx index dde489e01..9225125b9 100644 --- a/packages/reporter/src/reporter.tsx +++ b/packages/reporter/src/reporter.tsx @@ -74,8 +74,6 @@ export function createReporterΔ(): BettererReporter { return { render(action?: BettererReporterAction, done?: () => void): void { const state = dispatch(action); - // eslint-disable-next-line no-console -- Clear the console before re-rendering the CLI UI: - console.clear(); const component = ; if (!app) { diff --git a/packages/reporter/src/types.ts b/packages/reporter/src/types.ts index e591c2610..811e3c57f 100644 --- a/packages/reporter/src/types.ts +++ b/packages/reporter/src/types.ts @@ -9,5 +9,15 @@ export interface BettererReporterRenderer { } export type BettererReporterRun = BettererRun & { - lifecycle: Promise; + lifecycle: Defer; }; + +type Resolve = (value: T) => void; +type Reject = (error: Error) => void; + +/** @knipignore */ +export interface Defer { + promise: Promise; + resolve: Resolve; + reject: Reject; +} diff --git a/test/__snapshots__/cache-ci.spec.ts.snap b/test/__snapshots__/cache-ci.spec.ts.snap index 529ae1c7a..26734bb07 100644 --- a/test/__snapshots__/cache-ci.spec.ts.snap +++ b/test/__snapshots__/cache-ci.spec.ts.snap @@ -36,40 +36,36 @@ exports[`betterer > should not update the cache file in CI mode 2`] = ` 🤔 test: running "test"! ", "🌟 Betterer: 1 test running... -🔥 test: "test" got worse. (1 new issue, 3 total) 😔 +🔥 test: "test" got worse. (1 new issue, 2 existing, 3 total) 😔 ", "🌟 Betterer: 1 test running... -🔥 test: "test" got worse. (1 new issue, 3 total) 😔 +🔥 test: "test" got worse. (1 new issue, 2 existing, 3 total) 😔 -Error: "test" got worse. (1 new issue, 3 total) 😔 +Error: "test" got worse. (1 new issue, 2 existing, 3 total) 😔 ", "💥 Betterer: 1 test done! 1 test errored! -🔥 test: "test" got worse. (1 new issue, 3 total) 😔 -・ 2 existing issues in "/fixtures/cache-ci/src/index.ts". -・ New issue in "/fixtures/cache-ci/src/index.ts"! +🔥 test: "test" got worse. (1 new issue, 2 existing, 3 total) 😔 +・ 2 existing, 1 new issues in "fixtures/cache-ci/src/index.ts". ・ -・ /fixtures/cache-ci/src/index.ts ・ 1 | // HACK: ・ 2 | // HACK: ・ > 3 | // HACK: ・ | ^^^^^^^ RegExp match ・ -Error: "test" got worse. (1 new issue, 3 total) 😔 +Error: "test" got worse. (1 new issue, 2 existing, 3 total) 😔 ", "💥 Betterer: 1 test done! 1 test errored! -🔥 test: "test" got worse. (1 new issue, 3 total) 😔 -・ 2 existing issues in "/fixtures/cache-ci/src/index.ts". -・ New issue in "/fixtures/cache-ci/src/index.ts"! +🔥 test: "test" got worse. (1 new issue, 2 existing, 3 total) 😔 +・ 2 existing, 1 new issues in "fixtures/cache-ci/src/index.ts". ・ -・ /fixtures/cache-ci/src/index.ts ・ 1 | // HACK: ・ 2 | // HACK: ・ > 3 | // HACK: ・ | ^^^^^^^ RegExp match ・ -Error: "test" got worse. (1 new issue, 3 total) 😔 +Error: "test" got worse. (1 new issue, 2 existing, 3 total) 😔 1 test got checked. 🤔 1 test got worse. 😔 diff --git a/test/__snapshots__/cache-deleted-file.spec.ts.snap b/test/__snapshots__/cache-deleted-file.spec.ts.snap index 801e7c182..46f8bb422 100644 --- a/test/__snapshots__/cache-deleted-file.spec.ts.snap +++ b/test/__snapshots__/cache-deleted-file.spec.ts.snap @@ -110,38 +110,36 @@ exports[`betterer > should remove files from the cache when they are deleted 6`] 🤔 test: running "test"! ", "🌟 Betterer (0ms): 1 test running... -🔥 test: "test" got worse. (2 new issues, 4 total) 😔 +🔥 test: "test" got worse. (2 new issues, 2 existing, 4 total) 😔 ", "🌟 Betterer (0ms): 1 test running... -🔥 test: "test" got worse. (2 new issues, 4 total) 😔 +🔥 test: "test" got worse. (2 new issues, 2 existing, 4 total) 😔 -Error: "test" got worse. (2 new issues, 4 total) 😔 +Error: "test" got worse. (2 new issues, 2 existing, 4 total) 😔 ", "💥 Betterer (0ms): 1 test done! 1 test errored! -🔥 test: "test" got worse. (2 new issues, 4 total) 😔 -・ New issues in "/fixtures/cache-deleted-file/src/file-2.ts"! +🔥 test: "test" got worse. (2 new issues, 2 existing, 4 total) 😔 +・ 2 new issues in "fixtures/cache-deleted-file/src/file-2.ts". ・ Showing first of 2 new issues: ・ -・ /fixtures/cache-deleted-file/src/file-2.ts ・ > 1 | // HACK: ・ | ^^^^^^^ RegExp match ・ 2 | // HACK: ・ -Error: "test" got worse. (2 new issues, 4 total) 😔 +Error: "test" got worse. (2 new issues, 2 existing, 4 total) 😔 ", "💥 Betterer (0ms): 1 test done! 1 test errored! -🔥 test: "test" got worse. (2 new issues, 4 total) 😔 -・ New issues in "/fixtures/cache-deleted-file/src/file-2.ts"! +🔥 test: "test" got worse. (2 new issues, 2 existing, 4 total) 😔 +・ 2 new issues in "fixtures/cache-deleted-file/src/file-2.ts". ・ Showing first of 2 new issues: ・ -・ /fixtures/cache-deleted-file/src/file-2.ts ・ > 1 | // HACK: ・ | ^^^^^^^ RegExp match ・ 2 | // HACK: ・ -Error: "test" got worse. (2 new issues, 4 total) 😔 +Error: "test" got worse. (2 new issues, 2 existing, 4 total) 😔 1 test got checked. 🤔 1 test got worse. 😔 diff --git a/test/__snapshots__/cache-path.spec.ts.snap b/test/__snapshots__/cache-path.spec.ts.snap index 12a451bef..9ef03b473 100644 --- a/test/__snapshots__/cache-path.spec.ts.snap +++ b/test/__snapshots__/cache-path.spec.ts.snap @@ -115,40 +115,36 @@ exports[`betterer > should write a cache file to a different path 7`] = ` 🤔 test: running "test"! ", "🌟 Betterer (0ms): 1 test running... -🔥 test: "test" got worse. (1 new issue, 3 total) 😔 +🔥 test: "test" got worse. (1 new issue, 2 existing, 3 total) 😔 ", "🌟 Betterer (0ms): 1 test running... -🔥 test: "test" got worse. (1 new issue, 3 total) 😔 +🔥 test: "test" got worse. (1 new issue, 2 existing, 3 total) 😔 -Error: "test" got worse. (1 new issue, 3 total) 😔 +Error: "test" got worse. (1 new issue, 2 existing, 3 total) 😔 ", "💥 Betterer (0ms): 1 test done! 1 test errored! -🔥 test: "test" got worse. (1 new issue, 3 total) 😔 -・ 2 existing issues in "/fixtures/cache-path/src/index.ts". -・ New issue in "/fixtures/cache-path/src/index.ts"! +🔥 test: "test" got worse. (1 new issue, 2 existing, 3 total) 😔 +・ 2 existing, 1 new issues in "fixtures/cache-path/src/index.ts". ・ -・ /fixtures/cache-path/src/index.ts ・ 1 | // HACK: ・ 2 | // HACK: ・ > 3 | // HACK: ・ | ^^^^^^^ RegExp match ・ -Error: "test" got worse. (1 new issue, 3 total) 😔 +Error: "test" got worse. (1 new issue, 2 existing, 3 total) 😔 ", "💥 Betterer (0ms): 1 test done! 1 test errored! -🔥 test: "test" got worse. (1 new issue, 3 total) 😔 -・ 2 existing issues in "/fixtures/cache-path/src/index.ts". -・ New issue in "/fixtures/cache-path/src/index.ts"! +🔥 test: "test" got worse. (1 new issue, 2 existing, 3 total) 😔 +・ 2 existing, 1 new issues in "fixtures/cache-path/src/index.ts". ・ -・ /fixtures/cache-path/src/index.ts ・ 1 | // HACK: ・ 2 | // HACK: ・ > 3 | // HACK: ・ | ^^^^^^^ RegExp match ・ -Error: "test" got worse. (1 new issue, 3 total) 😔 +Error: "test" got worse. (1 new issue, 2 existing, 3 total) 😔 1 test got checked. 🤔 1 test got worse. 😔 diff --git a/test/__snapshots__/cache-worse.spec.ts.snap b/test/__snapshots__/cache-worse.spec.ts.snap index ca6c97440..bdb7a6c8d 100644 --- a/test/__snapshots__/cache-worse.spec.ts.snap +++ b/test/__snapshots__/cache-worse.spec.ts.snap @@ -64,38 +64,34 @@ exports[`betterer > doesn't cache if a test gets worse 3`] = ` 🤔 test: running "test"! ", "🌟 Betterer (0ms): 1 test running... -🔥 test: "test" got worse. (1 new issue, 2 total) 😔 +🔥 test: "test" got worse. (1 new issue, 1 existing, 2 total) 😔 ", "🌟 Betterer (0ms): 1 test running... -🔥 test: "test" got worse. (1 new issue, 2 total) 😔 +🔥 test: "test" got worse. (1 new issue, 1 existing, 2 total) 😔 -Error: "test" got worse. (1 new issue, 2 total) 😔 +Error: "test" got worse. (1 new issue, 1 existing, 2 total) 😔 ", "💥 Betterer (0ms): 1 test done! 1 test errored! -🔥 test: "test" got worse. (1 new issue, 2 total) 😔 -・ 1 existing issue in "/fixtures/cache-worse/src/index.ts". -・ New issue in "/fixtures/cache-worse/src/index.ts"! +🔥 test: "test" got worse. (1 new issue, 1 existing, 2 total) 😔 +・ 1 existing, 1 new issues in "fixtures/cache-worse/src/index.ts". ・ -・ /fixtures/cache-worse/src/index.ts ・ 1 | // HACK: ・ > 2 | // HACK: ・ | ^^^^^^^ RegExp match ・ -Error: "test" got worse. (1 new issue, 2 total) 😔 +Error: "test" got worse. (1 new issue, 1 existing, 2 total) 😔 ", "💥 Betterer (0ms): 1 test done! 1 test errored! -🔥 test: "test" got worse. (1 new issue, 2 total) 😔 -・ 1 existing issue in "/fixtures/cache-worse/src/index.ts". -・ New issue in "/fixtures/cache-worse/src/index.ts"! +🔥 test: "test" got worse. (1 new issue, 1 existing, 2 total) 😔 +・ 1 existing, 1 new issues in "fixtures/cache-worse/src/index.ts". ・ -・ /fixtures/cache-worse/src/index.ts ・ 1 | // HACK: ・ > 2 | // HACK: ・ | ^^^^^^^ RegExp match ・ -Error: "test" got worse. (1 new issue, 2 total) 😔 +Error: "test" got worse. (1 new issue, 1 existing, 2 total) 😔 1 test got checked. 🤔 1 test got worse. 😔 @@ -108,38 +104,34 @@ You should try to fix the new issues! As a last resort, you can run \`betterer - 🤔 test: running "test"! ", "🌟 Betterer (0ms): 1 test running... -🔥 test: "test" got worse. (1 new issue, 2 total) 😔 +🔥 test: "test" got worse. (1 new issue, 1 existing, 2 total) 😔 ", "🌟 Betterer (0ms): 1 test running... -🔥 test: "test" got worse. (1 new issue, 2 total) 😔 +🔥 test: "test" got worse. (1 new issue, 1 existing, 2 total) 😔 -Error: "test" got worse. (1 new issue, 2 total) 😔 +Error: "test" got worse. (1 new issue, 1 existing, 2 total) 😔 ", "💥 Betterer (0ms): 1 test done! 1 test errored! -🔥 test: "test" got worse. (1 new issue, 2 total) 😔 -・ 1 existing issue in "/fixtures/cache-worse/src/index.ts". -・ New issue in "/fixtures/cache-worse/src/index.ts"! +🔥 test: "test" got worse. (1 new issue, 1 existing, 2 total) 😔 +・ 1 existing, 1 new issues in "fixtures/cache-worse/src/index.ts". ・ -・ /fixtures/cache-worse/src/index.ts ・ 1 | // HACK: ・ > 2 | // HACK: ・ | ^^^^^^^ RegExp match ・ -Error: "test" got worse. (1 new issue, 2 total) 😔 +Error: "test" got worse. (1 new issue, 1 existing, 2 total) 😔 ", "💥 Betterer (0ms): 1 test done! 1 test errored! -🔥 test: "test" got worse. (1 new issue, 2 total) 😔 -・ 1 existing issue in "/fixtures/cache-worse/src/index.ts". -・ New issue in "/fixtures/cache-worse/src/index.ts"! +🔥 test: "test" got worse. (1 new issue, 1 existing, 2 total) 😔 +・ 1 existing, 1 new issues in "fixtures/cache-worse/src/index.ts". ・ -・ /fixtures/cache-worse/src/index.ts ・ 1 | // HACK: ・ > 2 | // HACK: ・ | ^^^^^^^ RegExp match ・ -Error: "test" got worse. (1 new issue, 2 total) 😔 +Error: "test" got worse. (1 new issue, 1 existing, 2 total) 😔 1 test got checked. 🤔 1 test got worse. 😔 diff --git a/test/__snapshots__/cache.spec.ts.snap b/test/__snapshots__/cache.spec.ts.snap index fd8ec8cd7..c3e517ab3 100644 --- a/test/__snapshots__/cache.spec.ts.snap +++ b/test/__snapshots__/cache.spec.ts.snap @@ -115,40 +115,36 @@ exports[`betterer > should write a cache file 7`] = ` 🤔 test: running "test"! ", "🌟 Betterer (0ms): 1 test running... -🔥 test: "test" got worse. (1 new issue, 3 total) 😔 +🔥 test: "test" got worse. (1 new issue, 2 existing, 3 total) 😔 ", "🌟 Betterer (0ms): 1 test running... -🔥 test: "test" got worse. (1 new issue, 3 total) 😔 +🔥 test: "test" got worse. (1 new issue, 2 existing, 3 total) 😔 -Error: "test" got worse. (1 new issue, 3 total) 😔 +Error: "test" got worse. (1 new issue, 2 existing, 3 total) 😔 ", "💥 Betterer (0ms): 1 test done! 1 test errored! -🔥 test: "test" got worse. (1 new issue, 3 total) 😔 -・ 2 existing issues in "/fixtures/cache/src/index.ts". -・ New issue in "/fixtures/cache/src/index.ts"! +🔥 test: "test" got worse. (1 new issue, 2 existing, 3 total) 😔 +・ 2 existing, 1 new issues in "fixtures/cache/src/index.ts". ・ -・ /fixtures/cache/src/index.ts ・ 1 | // HACK: ・ 2 | // HACK: ・ > 3 | // HACK: ・ | ^^^^^^^ RegExp match ・ -Error: "test" got worse. (1 new issue, 3 total) 😔 +Error: "test" got worse. (1 new issue, 2 existing, 3 total) 😔 ", "💥 Betterer (0ms): 1 test done! 1 test errored! -🔥 test: "test" got worse. (1 new issue, 3 total) 😔 -・ 2 existing issues in "/fixtures/cache/src/index.ts". -・ New issue in "/fixtures/cache/src/index.ts"! +🔥 test: "test" got worse. (1 new issue, 2 existing, 3 total) 😔 +・ 2 existing, 1 new issues in "fixtures/cache/src/index.ts". ・ -・ /fixtures/cache/src/index.ts ・ 1 | // HACK: ・ 2 | // HACK: ・ > 3 | // HACK: ・ | ^^^^^^^ RegExp match ・ -Error: "test" got worse. (1 new issue, 3 total) 😔 +Error: "test" got worse. (1 new issue, 2 existing, 3 total) 😔 1 test got checked. 🤔 1 test got worse. 😔 diff --git a/test/__snapshots__/config-invalid.spec.ts.snap b/test/__snapshots__/config-invalid.spec.ts.snap index 00acb71b1..40cf0cee8 100644 --- a/test/__snapshots__/config-invalid.spec.ts.snap +++ b/test/__snapshots__/config-invalid.spec.ts.snap @@ -3,11 +3,11 @@ exports[`betterer > should throw when there is an invalid config file 1`] = ` [ " -Error: could not import config from "/fixtures/config-invalid/.betterer.ts". 😔 +Error: could not import config from "fixtures/config-invalid/.betterer.ts". 😔 -Error: could not import "/fixtures/config-invalid/.betterer.ts". 😔 +Error: could not import "fixtures/config-invalid/.betterer.ts". 😔 -Error: could not transpile "/fixtures/config-invalid/.betterer.ts". 😔 +Error: could not transpile "fixtures/config-invalid/.betterer.ts". 😔 Error: Expression expected ", diff --git a/test/__snapshots__/config-missing.spec.ts.snap b/test/__snapshots__/config-missing.spec.ts.snap index 99a98e470..b004242c2 100644 --- a/test/__snapshots__/config-missing.spec.ts.snap +++ b/test/__snapshots__/config-missing.spec.ts.snap @@ -3,7 +3,7 @@ exports[`betterer > should throw when there is not a config file 1`] = ` [ " -Error: could not find config file at "/fixtures/config-missing/.betterer.ts". 😔 +Error: could not find config file at "fixtures/config-missing/.betterer.ts". 😔 Error: All promises were rejected ", diff --git a/test/__snapshots__/eslint-complex-project.spec.ts.snap b/test/__snapshots__/eslint-complex-project.spec.ts.snap index 7fda18a8d..743e9f22d 100644 --- a/test/__snapshots__/eslint-complex-project.spec.ts.snap +++ b/test/__snapshots__/eslint-complex-project.spec.ts.snap @@ -61,38 +61,34 @@ exports[`betterer > should report the status of a new eslint rule with a complex 🤔 test: running "test"! ", "🌟 Betterer (0ms): 1 test running... -🔥 test: "test" got worse. (1 new issue, 3 total) 😔 +🔥 test: "test" got worse. (1 new issue, 2 existing, 3 total) 😔 ", "🌟 Betterer (0ms): 1 test running... -🔥 test: "test" got worse. (1 new issue, 3 total) 😔 +🔥 test: "test" got worse. (1 new issue, 2 existing, 3 total) 😔 -Error: "test" got worse. (1 new issue, 3 total) 😔 +Error: "test" got worse. (1 new issue, 2 existing, 3 total) 😔 ", "💥 Betterer (0ms): 1 test done! 1 test errored! -🔥 test: "test" got worse. (1 new issue, 3 total) 😔 -・ 1 existing issue in "/fixtures/eslint-complex-project/src/index.ts". -・ New issue in "/fixtures/eslint-complex-project/src/index.ts"! +🔥 test: "test" got worse. (1 new issue, 2 existing, 3 total) 😔 +・ 1 existing, 1 new issues in "fixtures/eslint-complex-project/src/index.ts". ・ -・ /fixtures/eslint-complex-project/src/index.ts ・ 1 | debugger; ・ > 2 | debugger; ・ | ^^^^^^^^^ Unexpected 'debugger' statement. ・ -Error: "test" got worse. (1 new issue, 3 total) 😔 +Error: "test" got worse. (1 new issue, 2 existing, 3 total) 😔 ", "💥 Betterer (0ms): 1 test done! 1 test errored! -🔥 test: "test" got worse. (1 new issue, 3 total) 😔 -・ 1 existing issue in "/fixtures/eslint-complex-project/src/index.ts". -・ New issue in "/fixtures/eslint-complex-project/src/index.ts"! +🔥 test: "test" got worse. (1 new issue, 2 existing, 3 total) 😔 +・ 1 existing, 1 new issues in "fixtures/eslint-complex-project/src/index.ts". ・ -・ /fixtures/eslint-complex-project/src/index.ts ・ 1 | debugger; ・ > 2 | debugger; ・ | ^^^^^^^^^ Unexpected 'debugger' statement. ・ -Error: "test" got worse. (1 new issue, 3 total) 😔 +Error: "test" got worse. (1 new issue, 2 existing, 3 total) 😔 1 test got checked. 🤔 1 test got worse. 😔 diff --git a/test/__snapshots__/eslint.spec.ts.snap b/test/__snapshots__/eslint.spec.ts.snap index 16acf438f..d61eae5f3 100644 --- a/test/__snapshots__/eslint.spec.ts.snap +++ b/test/__snapshots__/eslint.spec.ts.snap @@ -58,38 +58,34 @@ exports[`betterer > should report the status of a new eslint rule 2`] = ` 🤔 test: running "test"! ", "🌟 Betterer (0ms): 1 test running... -🔥 test: "test" got worse. (1 new issue, 2 total) 😔 +🔥 test: "test" got worse. (1 new issue, 1 existing, 2 total) 😔 ", "🌟 Betterer (0ms): 1 test running... -🔥 test: "test" got worse. (1 new issue, 2 total) 😔 +🔥 test: "test" got worse. (1 new issue, 1 existing, 2 total) 😔 -Error: "test" got worse. (1 new issue, 2 total) 😔 +Error: "test" got worse. (1 new issue, 1 existing, 2 total) 😔 ", "💥 Betterer (0ms): 1 test done! 1 test errored! -🔥 test: "test" got worse. (1 new issue, 2 total) 😔 -・ 1 existing issue in "/fixtures/eslint/src/index.ts". -・ New issue in "/fixtures/eslint/src/index.ts"! +🔥 test: "test" got worse. (1 new issue, 1 existing, 2 total) 😔 +・ 1 existing, 1 new issues in "fixtures/eslint/src/index.ts". ・ -・ /fixtures/eslint/src/index.ts ・ 1 | debugger; ・ > 2 | debugger; ・ | ^^^^^^^^^ Unexpected 'debugger' statement. ・ -Error: "test" got worse. (1 new issue, 2 total) 😔 +Error: "test" got worse. (1 new issue, 1 existing, 2 total) 😔 ", "💥 Betterer (0ms): 1 test done! 1 test errored! -🔥 test: "test" got worse. (1 new issue, 2 total) 😔 -・ 1 existing issue in "/fixtures/eslint/src/index.ts". -・ New issue in "/fixtures/eslint/src/index.ts"! +🔥 test: "test" got worse. (1 new issue, 1 existing, 2 total) 😔 +・ 1 existing, 1 new issues in "fixtures/eslint/src/index.ts". ・ -・ /fixtures/eslint/src/index.ts ・ 1 | debugger; ・ > 2 | debugger; ・ | ^^^^^^^^^ Unexpected 'debugger' statement. ・ -Error: "test" got worse. (1 new issue, 2 total) 😔 +Error: "test" got worse. (1 new issue, 1 existing, 2 total) 😔 1 test got checked. 🤔 1 test got worse. 😔 diff --git a/test/__snapshots__/exclude-global.spec.ts.snap b/test/__snapshots__/exclude-global.spec.ts.snap index 82ad7fb8e..19eb53080 100644 --- a/test/__snapshots__/exclude-global.spec.ts.snap +++ b/test/__snapshots__/exclude-global.spec.ts.snap @@ -59,34 +59,34 @@ exports[`betterer > should handle a global exclude 3`] = ` ", "Checking 1 file... 🤔 -・ /fixtures/exclude-global/src/index.ts +・ fixtures/exclude-global/src/index.ts 🌟 Betterer (0ms): ", "Checking 1 file... 🤔 -・ /fixtures/exclude-global/src/index.ts +・ fixtures/exclude-global/src/index.ts 🌟 Betterer (0ms): 1 test running... 🤔 test: running "test"! ", "Checking 1 file... 🤔 -・ /fixtures/exclude-global/src/index.ts +・ fixtures/exclude-global/src/index.ts 🌟 Betterer (0ms): 1 test running... ✅ test: "test" stayed the same. (2 issues) 😐 ", "Checking 1 file... 🤔 -・ /fixtures/exclude-global/src/index.ts +・ fixtures/exclude-global/src/index.ts 🎉 Betterer (0ms): 1 test done! ✅ test: "test" stayed the same. (2 issues) 😐 ", "Checked 1 file! 🔍 -・ /fixtures/exclude-global/src/index.ts +・ fixtures/exclude-global/src/index.ts 🎉 Betterer (0ms): 1 test done! ✅ test: "test" stayed the same. (2 issues) 😐 diff --git a/test/__snapshots__/file-test-constraint.spec.ts.snap b/test/__snapshots__/file-test-constraint.spec.ts.snap index e6d736c65..55627b63d 100644 --- a/test/__snapshots__/file-test-constraint.spec.ts.snap +++ b/test/__snapshots__/file-test-constraint.spec.ts.snap @@ -43,13 +43,13 @@ exports[`betterer > should let you override the constraint of a file test 2`] = 🤔 test: running "test"! ", "🌟 Betterer (0ms): 1 test running... -✅ test: "test" stayed the same. (1 new issue, 3 total) 😐 +✅ test: "test" stayed the same. (1 new issue, 2 existing, 3 total) 😐 ", "🎉 Betterer (0ms): 1 test done! -✅ test: "test" stayed the same. (1 new issue, 3 total) 😐 +✅ test: "test" stayed the same. (1 new issue, 2 existing, 3 total) 😐 ", "🎉 Betterer (0ms): 1 test done! -✅ test: "test" stayed the same. (1 new issue, 3 total) 😐 +✅ test: "test" stayed the same. (1 new issue, 2 existing, 3 total) 😐 1 test got checked. 🤔 1 test stayed the same. 😐 diff --git a/test/__snapshots__/file-test-goal.spec.ts.snap b/test/__snapshots__/file-test-goal.spec.ts.snap index 1108896dc..cb050a3ea 100644 --- a/test/__snapshots__/file-test-goal.spec.ts.snap +++ b/test/__snapshots__/file-test-goal.spec.ts.snap @@ -59,40 +59,36 @@ exports[`betterer > should let you override the goal of a file test 2`] = ` 🤔 test: running "test"! ", "🌟 Betterer (0ms): 1 test running... -🔥 test: "test" got worse. (1 new issue, 3 total) 😔 +🔥 test: "test" got worse. (1 new issue, 2 existing, 3 total) 😔 ", "🌟 Betterer (0ms): 1 test running... -🔥 test: "test" got worse. (1 new issue, 3 total) 😔 +🔥 test: "test" got worse. (1 new issue, 2 existing, 3 total) 😔 -Error: "test" got worse. (1 new issue, 3 total) 😔 +Error: "test" got worse. (1 new issue, 2 existing, 3 total) 😔 ", "💥 Betterer (0ms): 1 test done! 1 test errored! -🔥 test: "test" got worse. (1 new issue, 3 total) 😔 -・ 2 existing issues in "/fixtures/file-test-goal/src/index.ts". -・ New issue in "/fixtures/file-test-goal/src/index.ts"! +🔥 test: "test" got worse. (1 new issue, 2 existing, 3 total) 😔 +・ 2 existing, 1 new issues in "fixtures/file-test-goal/src/index.ts". ・ -・ /fixtures/file-test-goal/src/index.ts ・ 1 | debugger; ・ 2 | debugger; ・ > 3 | debugger; ・ | ^^^^^^^^^ Unexpected 'debugger' statement. ・ -Error: "test" got worse. (1 new issue, 3 total) 😔 +Error: "test" got worse. (1 new issue, 2 existing, 3 total) 😔 ", "💥 Betterer (0ms): 1 test done! 1 test errored! -🔥 test: "test" got worse. (1 new issue, 3 total) 😔 -・ 2 existing issues in "/fixtures/file-test-goal/src/index.ts". -・ New issue in "/fixtures/file-test-goal/src/index.ts"! +🔥 test: "test" got worse. (1 new issue, 2 existing, 3 total) 😔 +・ 2 existing, 1 new issues in "fixtures/file-test-goal/src/index.ts". ・ -・ /fixtures/file-test-goal/src/index.ts ・ 1 | debugger; ・ 2 | debugger; ・ > 3 | debugger; ・ | ^^^^^^^^^ Unexpected 'debugger' statement. ・ -Error: "test" got worse. (1 new issue, 3 total) 😔 +Error: "test" got worse. (1 new issue, 2 existing, 3 total) 😔 1 test got checked. 🤔 1 test got worse. 😔 diff --git a/test/__snapshots__/file-test-sort-absolute.spec.ts.snap b/test/__snapshots__/file-test-sort-absolute.spec.ts.snap index 1a3a80b90..cecd7b5a0 100644 --- a/test/__snapshots__/file-test-sort-absolute.spec.ts.snap +++ b/test/__snapshots__/file-test-sort-absolute.spec.ts.snap @@ -51,34 +51,32 @@ exports[`betterer > should sort files by their file path correctly with absolute ", "Checking 1 file... 🤔 -・ /fixtures/file-test-sort-absolute/src/c.ts +・ fixtures/file-test-sort-absolute/src/c.ts 🌟 Betterer (0ms): ", "Checking 1 file... 🤔 -・ /fixtures/file-test-sort-absolute/src/c.ts +・ fixtures/file-test-sort-absolute/src/c.ts 🌟 Betterer (0ms): 1 test running... 🤔 test: running "test"! ", "Checking 1 file... 🤔 -・ /fixtures/file-test-sort-absolute/src/c.ts +・ fixtures/file-test-sort-absolute/src/c.ts 🌟 Betterer (0ms): 1 test running... -✅ test: "test" got force updated. (1 new issue, 9 total) 🆙 +✅ test: "test" got force updated. (1 new issue, 8 existing, 9 total) 🆙 ", "Checking 1 file... 🤔 -・ /fixtures/file-test-sort-absolute/src/c.ts +・ fixtures/file-test-sort-absolute/src/c.ts 🎉 Betterer (0ms): 1 test done! -✅ test: "test" got force updated. (1 new issue, 9 total) 🆙 -・ 2 existing issues in "/fixtures/file-test-sort-absolute/src/c.ts". -・ New issue in "/fixtures/file-test-sort-absolute/src/c.ts"! +✅ test: "test" got force updated. (1 new issue, 8 existing, 9 total) 🆙 +・ 2 existing, 1 new issues in "fixtures/file-test-sort-absolute/src/c.ts". ・ -・ /fixtures/file-test-sort-absolute/src/c.ts ・ 1 | debugger; ・ 2 | debugger; ・ > 3 | debugger; @@ -87,14 +85,12 @@ exports[`betterer > should sort files by their file path correctly with absolute ", "Checked 1 file! 🔍 -・ /fixtures/file-test-sort-absolute/src/c.ts +・ fixtures/file-test-sort-absolute/src/c.ts 🎉 Betterer (0ms): 1 test done! -✅ test: "test" got force updated. (1 new issue, 9 total) 🆙 -・ 2 existing issues in "/fixtures/file-test-sort-absolute/src/c.ts". -・ New issue in "/fixtures/file-test-sort-absolute/src/c.ts"! +✅ test: "test" got force updated. (1 new issue, 8 existing, 9 total) 🆙 +・ 2 existing, 1 new issues in "fixtures/file-test-sort-absolute/src/c.ts". ・ -・ /fixtures/file-test-sort-absolute/src/c.ts ・ 1 | debugger; ・ 2 | debugger; ・ > 3 | debugger; diff --git a/test/__snapshots__/file-test-sort-subset.spec.ts.snap b/test/__snapshots__/file-test-sort-subset.spec.ts.snap index a4805b486..7dab0e529 100644 --- a/test/__snapshots__/file-test-sort-subset.spec.ts.snap +++ b/test/__snapshots__/file-test-sort-subset.spec.ts.snap @@ -55,14 +55,12 @@ exports[`betterer > should sort files by their file path even when only running 🤔 test: running "test"! ", "🌟 Betterer (0ms): 1 test running... -✅ test: "test" got force updated. (1 new issue, 9 total) 🆙 +✅ test: "test" got force updated. (1 new issue, 8 existing, 9 total) 🆙 ", "🎉 Betterer (0ms): 1 test done! -✅ test: "test" got force updated. (1 new issue, 9 total) 🆙 -・ 2 existing issues in "/fixtures/file-test-sort-subset/src/c.ts". -・ New issue in "/fixtures/file-test-sort-subset/src/c.ts"! +✅ test: "test" got force updated. (1 new issue, 8 existing, 9 total) 🆙 +・ 2 existing, 1 new issues in "fixtures/file-test-sort-subset/src/c.ts". ・ -・ /fixtures/file-test-sort-subset/src/c.ts ・ 1 | debugger; ・ 2 | debugger; ・ > 3 | debugger; @@ -70,11 +68,9 @@ exports[`betterer > should sort files by their file path even when only running ・ ", "🎉 Betterer (0ms): 1 test done! -✅ test: "test" got force updated. (1 new issue, 9 total) 🆙 -・ 2 existing issues in "/fixtures/file-test-sort-subset/src/c.ts". -・ New issue in "/fixtures/file-test-sort-subset/src/c.ts"! +✅ test: "test" got force updated. (1 new issue, 8 existing, 9 total) 🆙 +・ 2 existing, 1 new issues in "fixtures/file-test-sort-subset/src/c.ts". ・ -・ /fixtures/file-test-sort-subset/src/c.ts ・ 1 | debugger; ・ 2 | debugger; ・ > 3 | debugger; diff --git a/test/__snapshots__/include-global.spec.ts.snap b/test/__snapshots__/include-global.spec.ts.snap index 6f3cdbc38..06f938125 100644 --- a/test/__snapshots__/include-global.spec.ts.snap +++ b/test/__snapshots__/include-global.spec.ts.snap @@ -56,51 +56,49 @@ exports[`betterer > should handle a global include 3`] = ` ", "Checking 2 files... 🤔 -・ /fixtures/include-global/global.ts -・ /fixtures/include-global/src/global.ts +・ fixtures/include-global/global.ts +・ fixtures/include-global/src/global.ts 🌟 Betterer (0ms): ", "Checking 2 files... 🤔 -・ /fixtures/include-global/global.ts -・ /fixtures/include-global/src/global.ts +・ fixtures/include-global/global.ts +・ fixtures/include-global/src/global.ts 🌟 Betterer (0ms): 1 test running... 🤔 test: running "test"! ", "Checking 2 files... 🤔 -・ /fixtures/include-global/global.ts -・ /fixtures/include-global/src/global.ts +・ fixtures/include-global/global.ts +・ fixtures/include-global/src/global.ts 🌟 Betterer (0ms): 1 test running... -✅ test: "test" got force updated. (1 new issue, 2 total) 🆙 +✅ test: "test" got force updated. (1 new issue, 1 existing, 2 total) 🆙 ", "Checking 2 files... 🤔 -・ /fixtures/include-global/global.ts -・ /fixtures/include-global/src/global.ts +・ fixtures/include-global/global.ts +・ fixtures/include-global/src/global.ts 🎉 Betterer (0ms): 1 test done! -✅ test: "test" got force updated. (1 new issue, 2 total) 🆙 -・ New issue in "/fixtures/include-global/src/global.ts"! +✅ test: "test" got force updated. (1 new issue, 1 existing, 2 total) 🆙 +・ 1 new issue in "fixtures/include-global/src/global.ts". ・ -・ /fixtures/include-global/src/global.ts ・ > 1 | // Hack ・ | ^^^^^^^ RegExp match ・ ", "Checked 2 files! 🔍 -・ /fixtures/include-global/global.ts -・ /fixtures/include-global/src/global.ts +・ fixtures/include-global/global.ts +・ fixtures/include-global/src/global.ts 🎉 Betterer (0ms): 1 test done! -✅ test: "test" got force updated. (1 new issue, 2 total) 🆙 -・ New issue in "/fixtures/include-global/src/global.ts"! +✅ test: "test" got force updated. (1 new issue, 1 existing, 2 total) 🆙 +・ 1 new issue in "fixtures/include-global/src/global.ts". ・ -・ /fixtures/include-global/src/global.ts ・ > 1 | // Hack ・ | ^^^^^^^ RegExp match ・ diff --git a/test/__snapshots__/knip.spec.ts.snap b/test/__snapshots__/knip.spec.ts.snap index 80780d70b..342549805 100644 --- a/test/__snapshots__/knip.spec.ts.snap +++ b/test/__snapshots__/knip.spec.ts.snap @@ -61,36 +61,32 @@ exports[`betterer > should report the status of a new knip config 2`] = ` 🤔 knip: running "knip"! ", "🌟 Betterer (0ms): 1 test running... -🔥 knip: "knip" got worse. (1 new issue, 3 total) 😔 +🔥 knip: "knip" got worse. (1 new issue, 2 existing, 3 total) 😔 ", "🌟 Betterer (0ms): 1 test running... -🔥 knip: "knip" got worse. (1 new issue, 3 total) 😔 +🔥 knip: "knip" got worse. (1 new issue, 2 existing, 3 total) 😔 -Error: "knip" got worse. (1 new issue, 3 total) 😔 +Error: "knip" got worse. (1 new issue, 2 existing, 3 total) 😔 ", "💥 Betterer (0ms): 1 test done! 1 test errored! -🔥 knip: "knip" got worse. (1 new issue, 3 total) 😔 -・ 1 existing issue in "/fixtures/knip/src/index.ts". -・ New issue in "/fixtures/knip/src/index.ts"! +🔥 knip: "knip" got worse. (1 new issue, 2 existing, 3 total) 😔 +・ 1 existing, 1 new issues in "fixtures/knip/src/index.ts". ・ -・ /fixtures/knip/src/index.ts ・ > 1 | import 'thanos-glove'; import 'console.fuck'; ・ | ^ Unlisted dependencies: console.fuck ・ -Error: "knip" got worse. (1 new issue, 3 total) 😔 +Error: "knip" got worse. (1 new issue, 2 existing, 3 total) 😔 ", "💥 Betterer (0ms): 1 test done! 1 test errored! -🔥 knip: "knip" got worse. (1 new issue, 3 total) 😔 -・ 1 existing issue in "/fixtures/knip/src/index.ts". -・ New issue in "/fixtures/knip/src/index.ts"! +🔥 knip: "knip" got worse. (1 new issue, 2 existing, 3 total) 😔 +・ 1 existing, 1 new issues in "fixtures/knip/src/index.ts". ・ -・ /fixtures/knip/src/index.ts ・ > 1 | import 'thanos-glove'; import 'console.fuck'; ・ | ^ Unlisted dependencies: console.fuck ・ -Error: "knip" got worse. (1 new issue, 3 total) 😔 +Error: "knip" got worse. (1 new issue, 2 existing, 3 total) 😔 1 test got checked. 🤔 1 test got worse. 😔 diff --git a/test/__snapshots__/regexp.spec.ts.snap b/test/__snapshots__/regexp.spec.ts.snap index a1bef0ac7..ca55a10c8 100644 --- a/test/__snapshots__/regexp.spec.ts.snap +++ b/test/__snapshots__/regexp.spec.ts.snap @@ -58,38 +58,34 @@ exports[`betterer > should report the existence of RegExp matches 2`] = ` 🤔 regexp: running "regexp"! ", "🌟 Betterer (0ms): 1 test running... -🔥 regexp: "regexp" got worse. (1 new issue, 2 total) 😔 +🔥 regexp: "regexp" got worse. (1 new issue, 1 existing, 2 total) 😔 ", "🌟 Betterer (0ms): 1 test running... -🔥 regexp: "regexp" got worse. (1 new issue, 2 total) 😔 +🔥 regexp: "regexp" got worse. (1 new issue, 1 existing, 2 total) 😔 -Error: "regexp" got worse. (1 new issue, 2 total) 😔 +Error: "regexp" got worse. (1 new issue, 1 existing, 2 total) 😔 ", "💥 Betterer (0ms): 1 test done! 1 test errored! -🔥 regexp: "regexp" got worse. (1 new issue, 2 total) 😔 -・ 1 existing issue in "/fixtures/regexp/src/index.ts". -・ New issue in "/fixtures/regexp/src/index.ts"! +🔥 regexp: "regexp" got worse. (1 new issue, 1 existing, 2 total) 😔 +・ 1 existing, 1 new issues in "fixtures/regexp/src/index.ts". ・ -・ /fixtures/regexp/src/index.ts ・ 1 | // HACK: ・ > 2 | // HACK: ・ | ^^^^^^^ RegExp match ・ -Error: "regexp" got worse. (1 new issue, 2 total) 😔 +Error: "regexp" got worse. (1 new issue, 1 existing, 2 total) 😔 ", "💥 Betterer (0ms): 1 test done! 1 test errored! -🔥 regexp: "regexp" got worse. (1 new issue, 2 total) 😔 -・ 1 existing issue in "/fixtures/regexp/src/index.ts". -・ New issue in "/fixtures/regexp/src/index.ts"! +🔥 regexp: "regexp" got worse. (1 new issue, 1 existing, 2 total) 😔 +・ 1 existing, 1 new issues in "fixtures/regexp/src/index.ts". ・ -・ /fixtures/regexp/src/index.ts ・ 1 | // HACK: ・ > 2 | // HACK: ・ | ^^^^^^^ RegExp match ・ -Error: "regexp" got worse. (1 new issue, 2 total) 😔 +Error: "regexp" got worse. (1 new issue, 1 existing, 2 total) 😔 1 test got checked. 🤔 1 test got worse. 😔 diff --git a/test/__snapshots__/reporter-invalid-hook-function.spec.ts.snap b/test/__snapshots__/reporter-invalid-hook-function.spec.ts.snap index 39d27927a..14b1ae194 100644 --- a/test/__snapshots__/reporter-invalid-hook-function.spec.ts.snap +++ b/test/__snapshots__/reporter-invalid-hook-function.spec.ts.snap @@ -3,7 +3,7 @@ exports[`betterer --reporter > should throw when a hook is not a function 1`] = ` [ " -Error: could not import "/fixtures/reporter-invalid-hook-function/reporter.js". 😔 +Error: could not import "fixtures/reporter-invalid-hook-function/reporter.js". 😔 Error: "contextStart" is not a function. 😔 ", diff --git a/test/__snapshots__/reporter-invalid-hook-name.spec.ts.snap b/test/__snapshots__/reporter-invalid-hook-name.spec.ts.snap index be8c340ee..7cc8f1ab3 100644 --- a/test/__snapshots__/reporter-invalid-hook-name.spec.ts.snap +++ b/test/__snapshots__/reporter-invalid-hook-name.spec.ts.snap @@ -3,7 +3,7 @@ exports[`betterer --reporter > should throw when there is an invalid hook name 1`] = ` [ " -Error: could not import "/fixtures/reporter-invalid-hook-name/reporter.js". 😔 +Error: could not import "fixtures/reporter-invalid-hook-name/reporter.js". 😔 Error: "notAHook" is not a valid reporter hook name. 😔 ", diff --git a/test/__snapshots__/reporter-no-export.spec.ts.snap b/test/__snapshots__/reporter-no-export.spec.ts.snap index a5037b1df..66530a7dc 100644 --- a/test/__snapshots__/reporter-no-export.spec.ts.snap +++ b/test/__snapshots__/reporter-no-export.spec.ts.snap @@ -3,9 +3,9 @@ exports[`betterer --reporter > should throw when there is nothing exported 1`] = ` [ " -Error: could not import "/fixtures/reporter-no-export/reporter.js". 😔 +Error: could not import "fixtures/reporter-no-export/reporter.js". 😔 -Error: "/fixtures/reporter-no-export/reporter.js" didn't create a reporter. 😔 +Error: "fixtures/reporter-no-export/reporter.js" didn't create a reporter. 😔 ", ] `; diff --git a/test/__snapshots__/results-read-error.spec.ts.snap b/test/__snapshots__/results-read-error.spec.ts.snap index 3a20e161a..ea50d9879 100644 --- a/test/__snapshots__/results-read-error.spec.ts.snap +++ b/test/__snapshots__/results-read-error.spec.ts.snap @@ -3,7 +3,7 @@ exports[`betterer > should throw when reading the results file fails 1`] = ` [ " -Error: could not read results from "/fixtures/results-read-error/.betterer.results". 😔 +Error: could not read results from "fixtures/results-read-error/.betterer.results". 😔 Error: ", diff --git a/test/__snapshots__/styelint.spec.ts.snap b/test/__snapshots__/styelint.spec.ts.snap index 19174d165..cab9699d1 100644 --- a/test/__snapshots__/styelint.spec.ts.snap +++ b/test/__snapshots__/styelint.spec.ts.snap @@ -42,48 +42,44 @@ exports[`betterer > should report the status of a new stylelint rule 2`] = ` 🤔 stylelint: running "stylelint"! ", "🌟 Betterer (0ms): 1 test running... -🔥 stylelint: "stylelint" got worse. (2 new issues, 4 total) 😔 +🔥 stylelint: "stylelint" got worse. (2 new issues, 2 existing, 4 total) 😔 ", "🌟 Betterer (0ms): 1 test running... -🔥 stylelint: "stylelint" got worse. (2 new issues, 4 total) 😔 +🔥 stylelint: "stylelint" got worse. (2 new issues, 2 existing, 4 total) 😔 -Error: "stylelint" got worse. (2 new issues, 4 total) 😔 +Error: "stylelint" got worse. (2 new issues, 2 existing, 4 total) 😔 ", "💥 Betterer (0ms): 1 test done! 1 test errored! -🔥 stylelint: "stylelint" got worse. (2 new issues, 4 total) 😔 -・ 2 existing issues in "/fixtures/stylelint/src/styles.scss". -・ New issues in "/fixtures/stylelint/src/styles.scss"! +🔥 stylelint: "stylelint" got worse. (2 new issues, 2 existing, 4 total) 😔 +・ 2 existing, 2 new issues in "fixtures/stylelint/src/styles.scss". ・ Showing first of 2 new issues: ・ -・ /fixtures/stylelint/src/styles.scss ・ 12 | b & {} ・ 13 | & b {} ・ > 14 | &:hover {} -・ | ^ Expected rule with selector matching "/^&:/w/" to come before rule with selector matching "/^&/" (order/order) +・ | ^ Expected rule with selector matching "/^&:\\w/" to come before rule with selector matching "/^&/" (order/order) ・ 15 | } ・ 16 | ・ 17 | .foo { ・ -Error: "stylelint" got worse. (2 new issues, 4 total) 😔 +Error: "stylelint" got worse. (2 new issues, 2 existing, 4 total) 😔 ", "💥 Betterer (0ms): 1 test done! 1 test errored! -🔥 stylelint: "stylelint" got worse. (2 new issues, 4 total) 😔 -・ 2 existing issues in "/fixtures/stylelint/src/styles.scss". -・ New issues in "/fixtures/stylelint/src/styles.scss"! +🔥 stylelint: "stylelint" got worse. (2 new issues, 2 existing, 4 total) 😔 +・ 2 existing, 2 new issues in "fixtures/stylelint/src/styles.scss". ・ Showing first of 2 new issues: ・ -・ /fixtures/stylelint/src/styles.scss ・ 12 | b & {} ・ 13 | & b {} ・ > 14 | &:hover {} -・ | ^ Expected rule with selector matching "/^&:/w/" to come before rule with selector matching "/^&/" (order/order) +・ | ^ Expected rule with selector matching "/^&:\\w/" to come before rule with selector matching "/^&/" (order/order) ・ 15 | } ・ 16 | ・ 17 | .foo { ・ -Error: "stylelint" got worse. (2 new issues, 4 total) 😔 +Error: "stylelint" got worse. (2 new issues, 2 existing, 4 total) 😔 1 test got checked. 🤔 1 test got worse. 😔 diff --git a/test/__snapshots__/test-not-a-function.spec.ts.snap b/test/__snapshots__/test-not-a-function.spec.ts.snap index 21e5bcbc0..7303d4f3e 100644 --- a/test/__snapshots__/test-not-a-function.spec.ts.snap +++ b/test/__snapshots__/test-not-a-function.spec.ts.snap @@ -3,7 +3,7 @@ exports[`betterer > should throw if a test is not a function 1`] = ` [ " -Error: could not create "test" from "/fixtures/test-not-a-function/.betterer.js". 😔 +Error: could not create "test" from "fixtures/test-not-a-function/.betterer.js". 😔 Error: "test" must be a function. ", diff --git a/test/__snapshots__/tsquery.spec.ts.snap b/test/__snapshots__/tsquery.spec.ts.snap index 31469103c..04af60555 100644 --- a/test/__snapshots__/tsquery.spec.ts.snap +++ b/test/__snapshots__/tsquery.spec.ts.snap @@ -58,38 +58,34 @@ exports[`betterer > should report the existence of TSQuery matches 2`] = ` 🤔 tsquery: running "tsquery"! ", "🌟 Betterer (0ms): 1 test running... -🔥 tsquery: "tsquery" got worse. (1 new issue, 2 total) 😔 +🔥 tsquery: "tsquery" got worse. (1 new issue, 1 existing, 2 total) 😔 ", "🌟 Betterer (0ms): 1 test running... -🔥 tsquery: "tsquery" got worse. (1 new issue, 2 total) 😔 +🔥 tsquery: "tsquery" got worse. (1 new issue, 1 existing, 2 total) 😔 -Error: "tsquery" got worse. (1 new issue, 2 total) 😔 +Error: "tsquery" got worse. (1 new issue, 1 existing, 2 total) 😔 ", "💥 Betterer (0ms): 1 test done! 1 test errored! -🔥 tsquery: "tsquery" got worse. (1 new issue, 2 total) 😔 -・ 1 existing issue in "/fixtures/tsquery/src/index.ts". -・ New issue in "/fixtures/tsquery/src/index.ts"! +🔥 tsquery: "tsquery" got worse. (1 new issue, 1 existing, 2 total) 😔 +・ 1 existing, 1 new issues in "fixtures/tsquery/src/index.ts". ・ -・ /fixtures/tsquery/src/index.ts ・ 1 | console.log('foo'); ・ > 2 | console.log('foo'); ・ | ^^^^^^^^^^^ TSQuery match ・ -Error: "tsquery" got worse. (1 new issue, 2 total) 😔 +Error: "tsquery" got worse. (1 new issue, 1 existing, 2 total) 😔 ", "💥 Betterer (0ms): 1 test done! 1 test errored! -🔥 tsquery: "tsquery" got worse. (1 new issue, 2 total) 😔 -・ 1 existing issue in "/fixtures/tsquery/src/index.ts". -・ New issue in "/fixtures/tsquery/src/index.ts"! +🔥 tsquery: "tsquery" got worse. (1 new issue, 1 existing, 2 total) 😔 +・ 1 existing, 1 new issues in "fixtures/tsquery/src/index.ts". ・ -・ /fixtures/tsquery/src/index.ts ・ 1 | console.log('foo'); ・ > 2 | console.log('foo'); ・ | ^^^^^^^^^^^ TSQuery match ・ -Error: "tsquery" got worse. (1 new issue, 2 total) 😔 +Error: "tsquery" got worse. (1 new issue, 1 existing, 2 total) 😔 1 test got checked. 🤔 1 test got worse. 😔 diff --git a/test/__snapshots__/typescript-strict.spec.ts.snap b/test/__snapshots__/typescript-strict.spec.ts.snap index 4e658b1fd..72de2462c 100644 --- a/test/__snapshots__/typescript-strict.spec.ts.snap +++ b/test/__snapshots__/typescript-strict.spec.ts.snap @@ -63,40 +63,36 @@ exports[`betterer > should report the status of the TypeScript compiler in stric 🤔 typescript: running "typescript"! ", "🌟 Betterer (0ms): 1 test running... -🔥 typescript: "typescript" got worse. (1 new issue, 7 total) 😔 +🔥 typescript: "typescript" got worse. (1 new issue, 6 existing, 7 total) 😔 ", "🌟 Betterer (0ms): 1 test running... -🔥 typescript: "typescript" got worse. (1 new issue, 7 total) 😔 +🔥 typescript: "typescript" got worse. (1 new issue, 6 existing, 7 total) 😔 -Error: "typescript" got worse. (1 new issue, 7 total) 😔 +Error: "typescript" got worse. (1 new issue, 6 existing, 7 total) 😔 ", "💥 Betterer (0ms): 1 test done! 1 test errored! -🔥 typescript: "typescript" got worse. (1 new issue, 7 total) 😔 -・ 6 existing issues in "/fixtures/typescript-strict/src/index.ts". -・ New issue in "/fixtures/typescript-strict/src/index.ts"! +🔥 typescript: "typescript" got worse. (1 new issue, 6 existing, 7 total) 😔 +・ 6 existing, 1 new issues in "fixtures/typescript-strict/src/index.ts". ・ -・ /fixtures/typescript-strict/src/index.ts ・ 32 | const a = 'a'; ・ 33 | const one = 1; ・ > 34 | console.log(a * one); ・ | ^ The left-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type. ・ -Error: "typescript" got worse. (1 new issue, 7 total) 😔 +Error: "typescript" got worse. (1 new issue, 6 existing, 7 total) 😔 ", "💥 Betterer (0ms): 1 test done! 1 test errored! -🔥 typescript: "typescript" got worse. (1 new issue, 7 total) 😔 -・ 6 existing issues in "/fixtures/typescript-strict/src/index.ts". -・ New issue in "/fixtures/typescript-strict/src/index.ts"! +🔥 typescript: "typescript" got worse. (1 new issue, 6 existing, 7 total) 😔 +・ 6 existing, 1 new issues in "fixtures/typescript-strict/src/index.ts". ・ -・ /fixtures/typescript-strict/src/index.ts ・ 32 | const a = 'a'; ・ 33 | const one = 1; ・ > 34 | console.log(a * one); ・ | ^ The left-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type. ・ -Error: "typescript" got worse. (1 new issue, 7 total) 😔 +Error: "typescript" got worse. (1 new issue, 6 existing, 7 total) 😔 1 test got checked. 🤔 1 test got worse. 😔 diff --git a/test/__snapshots__/typescript.spec.ts.snap b/test/__snapshots__/typescript.spec.ts.snap index 631671136..2d333d18b 100644 --- a/test/__snapshots__/typescript.spec.ts.snap +++ b/test/__snapshots__/typescript.spec.ts.snap @@ -58,40 +58,36 @@ exports[`betterer > should report the status of the TypeScript compiler 2`] = ` 🤔 typescript: running "typescript"! ", "🌟 Betterer (0ms): 1 test running... -🔥 typescript: "typescript" got worse. (1 new issue, 2 total) 😔 +🔥 typescript: "typescript" got worse. (1 new issue, 1 existing, 2 total) 😔 ", "🌟 Betterer (0ms): 1 test running... -🔥 typescript: "typescript" got worse. (1 new issue, 2 total) 😔 +🔥 typescript: "typescript" got worse. (1 new issue, 1 existing, 2 total) 😔 -Error: "typescript" got worse. (1 new issue, 2 total) 😔 +Error: "typescript" got worse. (1 new issue, 1 existing, 2 total) 😔 ", "💥 Betterer (0ms): 1 test done! 1 test errored! -🔥 typescript: "typescript" got worse. (1 new issue, 2 total) 😔 -・ 1 existing issue in "/fixtures/typescript/src/index.ts". -・ New issue in "/fixtures/typescript/src/index.ts"! +🔥 typescript: "typescript" got worse. (1 new issue, 1 existing, 2 total) 😔 +・ 1 existing, 1 new issues in "fixtures/typescript/src/index.ts". ・ -・ /fixtures/typescript/src/index.ts ・ 1 | const a = 'a'; ・ 2 | const one = 1; ・ > 3 | console.log(a * one, one * a); ・ | ^ The right-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type. ・ -Error: "typescript" got worse. (1 new issue, 2 total) 😔 +Error: "typescript" got worse. (1 new issue, 1 existing, 2 total) 😔 ", "💥 Betterer (0ms): 1 test done! 1 test errored! -🔥 typescript: "typescript" got worse. (1 new issue, 2 total) 😔 -・ 1 existing issue in "/fixtures/typescript/src/index.ts". -・ New issue in "/fixtures/typescript/src/index.ts"! +🔥 typescript: "typescript" got worse. (1 new issue, 1 existing, 2 total) 😔 +・ 1 existing, 1 new issues in "fixtures/typescript/src/index.ts". ・ -・ /fixtures/typescript/src/index.ts ・ 1 | const a = 'a'; ・ 2 | const one = 1; ・ > 3 | console.log(a * one, one * a); ・ | ^ The right-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type. ・ -Error: "typescript" got worse. (1 new issue, 2 total) 😔 +Error: "typescript" got worse. (1 new issue, 1 existing, 2 total) 😔 1 test got checked. 🤔 1 test got worse. 😔 diff --git a/test/__snapshots__/workers.e2e.spec.ts.snap b/test/__snapshots__/workers.e2e.spec.ts.snap index e8b4d7b2b..86a9f26a3 100644 --- a/test/__snapshots__/workers.e2e.spec.ts.snap +++ b/test/__snapshots__/workers.e2e.spec.ts.snap @@ -25,33 +25,29 @@ exports[`betterer > should run tests in workers 1`] = ` ✅ test 1: "test 1" stayed the same. 😐 ✅ test 2: "test 2" stayed the same. 😐 ✅ test 3: "test 3" met its goal! 🎉 -🔥 test 4: "test 4" got worse. (1 new issue, 2 total) 😔 -・ 1 existing issue in "/fixtures/workers/src/index.ts". -・ New issue in "/fixtures/workers/src/index.ts"! +🔥 test 4: "test 4" got worse. (1 new issue, 1 existing, 2 total) 😔 +・ 1 existing, 1 new issues in "fixtures/workers/src/index.ts". ・ -・ /fixtures/workers/src/index.ts ・ 1 | // HACK ・ > 2 | // HACK ・ | ^^^^^^^ RegExp match ・ -Error: "test 4" got worse. (1 new issue, 2 total) 😔 +Error: "test 4" got worse. (1 new issue, 1 existing, 2 total) 😔 ", "💥 Betterer (0ms): 4 tests done! 1 test errored! ✅ test 1: "test 1" stayed the same. 😐 ✅ test 2: "test 2" stayed the same. 😐 ✅ test 3: "test 3" met its goal! 🎉 -🔥 test 4: "test 4" got worse. (1 new issue, 2 total) 😔 -・ 1 existing issue in "/fixtures/workers/src/index.ts". -・ New issue in "/fixtures/workers/src/index.ts"! +🔥 test 4: "test 4" got worse. (1 new issue, 1 existing, 2 total) 😔 +・ 1 existing, 1 new issues in "fixtures/workers/src/index.ts". ・ -・ /fixtures/workers/src/index.ts ・ 1 | // HACK ・ > 2 | // HACK ・ | ^^^^^^^ RegExp match ・ -Error: "test 4" got worse. (1 new issue, 2 total) 😔 +Error: "test 4" got worse. (1 new issue, 1 existing, 2 total) 😔 4 tests got checked. 🤔 1 test got better! 😍 diff --git a/test/__snapshots__/workers.spec.ts.snap b/test/__snapshots__/workers.spec.ts.snap deleted file mode 100644 index 59e08e103..000000000 --- a/test/__snapshots__/workers.spec.ts.snap +++ /dev/null @@ -1,91 +0,0 @@ -// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html - -exports[`betterer > should run tests in workers 1`] = ` -[ - "🌟 Betterer (0ms): -", - "🎉 Betterer (0ms): 4 tests done! -✅ test 1: "test 1" got checked for the first time! 🎉 -✅ test 2: "test 2" got checked for the first time! 🎉 -✅ test 3: "test 3" got checked for the first time! (1 issue) 🎉 -✅ test 4: "test 4" got checked for the first time! (1 issue) 🎉 -", - "🎉 Betterer (0ms): 4 tests done! -✅ test 1: "test 1" got checked for the first time! 🎉 -✅ test 2: "test 2" got checked for the first time! 🎉 -✅ test 3: "test 3" got checked for the first time! (1 issue) 🎉 -✅ test 4: "test 4" got checked for the first time! (1 issue) 🎉 - -4 tests got checked. 🤔 -4 tests got checked for the first time! 🎉 -", - "🌟 Betterer (0ms): -", - "💥 Betterer (0ms): 4 tests done! 1 test errored! -✅ test 1: "test 1" stayed the same. 😐 -✅ test 2: "test 2" stayed the same. 😐 -✅ test 3: "test 3" met its goal! 🎉 -🔥 test 4: "test 4" got worse. (1 new issue, 2 total) 😔 -・ 1 existing issue in "/fixtures/workers/src/index.ts". -・ New issue in "/fixtures/workers/src/index.ts"! -・ -・ /fixtures/workers/src/index.ts -・ 1 | // HACK -・ > 2 | // HACK -・ | ^^^^^^^ RegExp match -・ - -Error: "test 4" got worse. (1 new issue, 2 total) 😔 -", - "💥 Betterer (0ms): 4 tests done! 1 test errored! -✅ test 1: "test 1" stayed the same. 😐 -✅ test 2: "test 2" stayed the same. 😐 -✅ test 3: "test 3" met its goal! 🎉 -🔥 test 4: "test 4" got worse. (1 new issue, 2 total) 😔 -・ 1 existing issue in "/fixtures/workers/src/index.ts". -・ New issue in "/fixtures/workers/src/index.ts"! -・ -・ /fixtures/workers/src/index.ts -・ 1 | // HACK -・ > 2 | // HACK -・ | ^^^^^^^ RegExp match -・ - -Error: "test 4" got worse. (1 new issue, 2 total) 😔 - -4 tests got checked. 🤔 -1 test got better! 😍 -1 test met its goal! 🎉 -2 tests stayed the same. 😐 -1 test got worse. 😔 - -You should try to fix the new issues! As a last resort, you can run \`betterer --update\` to force an update of the results file. 🆙 -", -] -`; - -exports[`betterer > should run tests in workers 2`] = ` -"// BETTERER RESULTS V2. -// -// If this file contains merge conflicts, use \`betterer merge\` to automatically resolve them: -// https://phenomnomnominal.github.io/betterer/docs/results-file/#merge -// -exports[\`test 1\`] = { - value: \`0 -\` -}; - -exports[\`test 2\`] = { - value: \`0 -\` -}; - -exports[\`test 4\`] = { - value: \`{ - "src/index.ts:2760033717": [ - [0, 0, 7, "RegExp match", "645651780"] - ] - }\` -}; -" -`; diff --git a/test/__snapshots__/worse-strict.spec.ts.snap b/test/__snapshots__/worse-strict.spec.ts.snap index 14634991c..f1d306745 100644 --- a/test/__snapshots__/worse-strict.spec.ts.snap +++ b/test/__snapshots__/worse-strict.spec.ts.snap @@ -41,38 +41,34 @@ exports[`betterer > should stay worse if an update is not allowed 2`] = ` 🤔 test: running "test"! ", "🌟 Betterer (0ms): 1 test running... -🔥 test: "test" got worse. (1 new issue, 2 total) 😔 +🔥 test: "test" got worse. (1 new issue, 1 existing, 2 total) 😔 ", "🌟 Betterer (0ms): 1 test running... -🔥 test: "test" got worse. (1 new issue, 2 total) 😔 +🔥 test: "test" got worse. (1 new issue, 1 existing, 2 total) 😔 -Error: "test" got worse. (1 new issue, 2 total) 😔 +Error: "test" got worse. (1 new issue, 1 existing, 2 total) 😔 ", "💥 Betterer (0ms): 1 test done! 1 test errored! -🔥 test: "test" got worse. (1 new issue, 2 total) 😔 -・ 1 existing issue in "/fixtures/worse-strict/src/index.ts". -・ New issue in "/fixtures/worse-strict/src/index.ts"! +🔥 test: "test" got worse. (1 new issue, 1 existing, 2 total) 😔 +・ 1 existing, 1 new issues in "fixtures/worse-strict/src/index.ts". ・ -・ /fixtures/worse-strict/src/index.ts ・ 1 | console.log('foo'); ・ > 2 | console.log('foo'); ・ | ^^^^^^^^^^^ TSQuery match ・ -Error: "test" got worse. (1 new issue, 2 total) 😔 +Error: "test" got worse. (1 new issue, 1 existing, 2 total) 😔 ", "💥 Betterer (0ms): 1 test done! 1 test errored! -🔥 test: "test" got worse. (1 new issue, 2 total) 😔 -・ 1 existing issue in "/fixtures/worse-strict/src/index.ts". -・ New issue in "/fixtures/worse-strict/src/index.ts"! +🔥 test: "test" got worse. (1 new issue, 1 existing, 2 total) 😔 +・ 1 existing, 1 new issues in "fixtures/worse-strict/src/index.ts". ・ -・ /fixtures/worse-strict/src/index.ts ・ 1 | console.log('foo'); ・ > 2 | console.log('foo'); ・ | ^^^^^^^^^^^ TSQuery match ・ -Error: "test" got worse. (1 new issue, 2 total) 😔 +Error: "test" got worse. (1 new issue, 1 existing, 2 total) 😔 1 test got checked. 🤔 1 test got worse. 😔 diff --git a/test/__snapshots__/worse-update.spec.ts.snap b/test/__snapshots__/worse-update.spec.ts.snap index 126a46924..47f4bfc05 100644 --- a/test/__snapshots__/worse-update.spec.ts.snap +++ b/test/__snapshots__/worse-update.spec.ts.snap @@ -42,25 +42,21 @@ exports[`betterer > should not stay worse if an update is forced 2`] = ` 🤔 test: running "test"! ", "🌟 Betterer (0ms): 1 test running... -✅ test: "test" got force updated. (1 new issue, 2 total) 🆙 +✅ test: "test" got force updated. (1 new issue, 1 existing, 2 total) 🆙 ", "🎉 Betterer (0ms): 1 test done! -✅ test: "test" got force updated. (1 new issue, 2 total) 🆙 -・ 1 existing issue in "/fixtures/worse-update/src/index.ts". -・ New issue in "/fixtures/worse-update/src/index.ts"! +✅ test: "test" got force updated. (1 new issue, 1 existing, 2 total) 🆙 +・ 1 existing, 1 new issues in "fixtures/worse-update/src/index.ts". ・ -・ /fixtures/worse-update/src/index.ts ・ 1 | console.log('foo'); ・ > 2 | console.log('foo'); ・ | ^^^^^^^^^^^ TSQuery match ・ ", "🎉 Betterer (0ms): 1 test done! -✅ test: "test" got force updated. (1 new issue, 2 total) 🆙 -・ 1 existing issue in "/fixtures/worse-update/src/index.ts". -・ New issue in "/fixtures/worse-update/src/index.ts"! +✅ test: "test" got force updated. (1 new issue, 1 existing, 2 total) 🆙 +・ 1 existing, 1 new issues in "fixtures/worse-update/src/index.ts". ・ -・ /fixtures/worse-update/src/index.ts ・ 1 | console.log('foo'); ・ > 2 | console.log('foo'); ・ | ^^^^^^^^^^^ TSQuery match diff --git a/test/cli/__snapshots__/ci-changes.spec.ts.snap b/test/cli/__snapshots__/ci-changes.spec.ts.snap index 21cb59827..f92f0cf65 100644 --- a/test/cli/__snapshots__/ci-changes.spec.ts.snap +++ b/test/cli/__snapshots__/ci-changes.spec.ts.snap @@ -25,40 +25,36 @@ exports[`betterer ci > should throw an error when a test changes 1`] = ` 🤔 test: running "test"! ", "🌟 Betterer: 1 test running... -🔥 test: "test" got worse. (1 new issue, 2 total) 😔 +🔥 test: "test" got worse. (1 new issue, 1 existing, 2 total) 😔 ", "🌟 Betterer: 1 test running... -🔥 test: "test" got worse. (1 new issue, 2 total) 😔 +🔥 test: "test" got worse. (1 new issue, 1 existing, 2 total) 😔 -Error: "test" got worse. (1 new issue, 2 total) 😔 +Error: "test" got worse. (1 new issue, 1 existing, 2 total) 😔 ", "💥 Betterer: 1 test done! 1 test errored! -🔥 test: "test" got worse. (1 new issue, 2 total) 😔 -・ 1 existing issue in "/fixtures/ci-worse/src/index.ts". -・ New issue in "/fixtures/ci-worse/src/index.ts"! +🔥 test: "test" got worse. (1 new issue, 1 existing, 2 total) 😔 +・ 1 existing, 1 new issues in "fixtures/ci-worse/src/index.ts". ・ -・ /fixtures/ci-worse/src/index.ts ・ 2 | const one = 1; ・ 3 | console.log(one * a); ・ > 4 | console.log(a * one); ・ | ^ The left-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type. ・ -Error: "test" got worse. (1 new issue, 2 total) 😔 +Error: "test" got worse. (1 new issue, 1 existing, 2 total) 😔 ", "💥 Betterer: 1 test done! 1 test errored! -🔥 test: "test" got worse. (1 new issue, 2 total) 😔 -・ 1 existing issue in "/fixtures/ci-worse/src/index.ts". -・ New issue in "/fixtures/ci-worse/src/index.ts"! +🔥 test: "test" got worse. (1 new issue, 1 existing, 2 total) 😔 +・ 1 existing, 1 new issues in "fixtures/ci-worse/src/index.ts". ・ -・ /fixtures/ci-worse/src/index.ts ・ 2 | const one = 1; ・ 3 | console.log(one * a); ・ > 4 | console.log(a * one); ・ | ^ The left-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type. ・ -Error: "test" got worse. (1 new issue, 2 total) 😔 +Error: "test" got worse. (1 new issue, 1 existing, 2 total) 😔 1 test got checked. 🤔 1 test got worse. 😔 diff --git a/test/cli/__snapshots__/init-js.spec.ts.snap b/test/cli/__snapshots__/init-js.spec.ts.snap index bf307e7a8..1727b005f 100644 --- a/test/cli/__snapshots__/init-js.spec.ts.snap +++ b/test/cli/__snapshots__/init-js.spec.ts.snap @@ -4,7 +4,7 @@ exports[`betterer cli > should initialise betterer in a repo with JS 1`] = ` [ "🎉 Initialising Betterer (0ms): 2 tasks done! ✅ Create test file: done! -・ created "/fixtures/init-js/.betterer.js"! +・ created "fixtures/init-js/.betterer.js"! ✅ Update package.json: done! ・ added "betterer" script to package.json file ・ added "@betterer/cli" dependency to package.json file", diff --git a/test/cli/__snapshots__/init-multiple.spec.ts.snap b/test/cli/__snapshots__/init-multiple.spec.ts.snap index 874629957..18619b634 100644 --- a/test/cli/__snapshots__/init-multiple.spec.ts.snap +++ b/test/cli/__snapshots__/init-multiple.spec.ts.snap @@ -4,14 +4,14 @@ exports[`betterer cli > should work multiple times 1`] = ` [ "🎉 Initialising Betterer (0ms): 2 tasks done! ✅ Create test file: done! -・ created "/fixtures/init-multiple/.betterer.ts"! +・ created "fixtures/init-multiple/.betterer.ts"! ✅ Update package.json: done! ・ added "betterer" script to package.json file ・ added "@betterer/cli" dependency to package.json file ・ added "typescript" dependency to package.json file", "🎉 Initialising Betterer (0ms): 2 tasks done! ✅ Create test file: done! -・ "/fixtures/init-multiple/.betterer.ts" already exists, moving on... +・ "fixtures/init-multiple/.betterer.ts" already exists, moving on... ✅ Update package.json: done! ・ "betterer" script already exists, moving on... ・ "@betterer/cli" dependency already exists, moving on... diff --git a/test/cli/__snapshots__/init-ts.spec.ts.snap b/test/cli/__snapshots__/init-ts.spec.ts.snap index 3cabcd8ab..2e4d80072 100644 --- a/test/cli/__snapshots__/init-ts.spec.ts.snap +++ b/test/cli/__snapshots__/init-ts.spec.ts.snap @@ -4,7 +4,7 @@ exports[`betterer cli > should initialise betterer in a repo with TS 1`] = ` [ "🎉 Initialising Betterer (0ms): 2 tasks done! ✅ Create test file: done! -・ created "/fixtures/init-ts/.betterer.ts"! +・ created "fixtures/init-ts/.betterer.ts"! ✅ Update package.json: done! ・ added "betterer" script to package.json file ・ added "@betterer/cli" dependency to package.json file diff --git a/test/cli/__snapshots__/logo-show.spec.ts.snap b/test/cli/__snapshots__/logo-show.spec.ts.snap index 6e9ca230d..32c157761 100644 --- a/test/cli/__snapshots__/logo-show.spec.ts.snap +++ b/test/cli/__snapshots__/logo-show.spec.ts.snap @@ -20,57 +20,57 @@ exports[`betterer cli > should show the logo 1`] = ` 1 test got checked for the first time! 🎉 ", " - / | / _ _ _ + \\ | / _ _ _ '-.ooo.-' | |__ ___| |_| |_ ___ _ __ ___ _ __ ----ooooo--- | '_ // _ / __| __/ _ / '__/ _ / '__| +---ooooo--- | '_ \\/ _ \\ __| __/ _ \\ '__/ _ \\ '__| .-'ooo'-. | |_)| __/ |_| || __/ | | __/ | - / | / |_.__//___|/__|/__/___|_| /___|_| + / | \\ |_.__/\\___|\\__|\\__\\___|_| \\___|_| ", " - / | / _ _ _ + \\ | / _ _ _ '-.ooo.-' | |__ ___| |_| |_ ___ _ __ ___ _ __ ----ooooo--- | '_ // _ / __| __/ _ / '__/ _ / '__| +---ooooo--- | '_ \\/ _ \\ __| __/ _ \\ '__/ _ \\ '__| .-'ooo'-. | |_)| __/ |_| || __/ | | __/ | - / | / |_.__//___|/__|/__/___|_| /___|_| + / | \\ |_.__/\\___|\\__|\\__\\___|_| \\___|_| 🌟 Betterer (0ms): ", " - / | / _ _ _ + \\ | / _ _ _ '-.ooo.-' | |__ ___| |_| |_ ___ _ __ ___ _ __ ----ooooo--- | '_ // _ / __| __/ _ / '__/ _ / '__| +---ooooo--- | '_ \\/ _ \\ __| __/ _ \\ '__/ _ \\ '__| .-'ooo'-. | |_)| __/ |_| || __/ | | __/ | - / | / |_.__//___|/__|/__/___|_| /___|_| + / | \\ |_.__/\\___|\\__|\\__\\___|_| \\___|_| 🌟 Betterer (0ms): 1 test running... 🤔 test 1: running "test 1"! ", " - / | / _ _ _ + \\ | / _ _ _ '-.ooo.-' | |__ ___| |_| |_ ___ _ __ ___ _ __ ----ooooo--- | '_ // _ / __| __/ _ / '__/ _ / '__| +---ooooo--- | '_ \\/ _ \\ __| __/ _ \\ '__/ _ \\ '__| .-'ooo'-. | |_)| __/ |_| || __/ | | __/ | - / | / |_.__//___|/__|/__/___|_| /___|_| + / | \\ |_.__/\\___|\\__|\\__\\___|_| \\___|_| 🌟 Betterer (0ms): 1 test running... ✅ test 1: "test 1" stayed the same. 😐 ", " - / | / _ _ _ + \\ | / _ _ _ '-.ooo.-' | |__ ___| |_| |_ ___ _ __ ___ _ __ ----ooooo--- | '_ // _ / __| __/ _ / '__/ _ / '__| +---ooooo--- | '_ \\/ _ \\ __| __/ _ \\ '__/ _ \\ '__| .-'ooo'-. | |_)| __/ |_| || __/ | | __/ | - / | / |_.__//___|/__|/__/___|_| /___|_| + / | \\ |_.__/\\___|\\__|\\__\\___|_| \\___|_| 🎉 Betterer (0ms): 1 test done! ✅ test 1: "test 1" stayed the same. 😐 ", " - / | / _ _ _ + \\ | / _ _ _ '-.ooo.-' | |__ ___| |_| |_ ___ _ __ ___ _ __ ----ooooo--- | '_ // _ / __| __/ _ / '__/ _ / '__| +---ooooo--- | '_ \\/ _ \\ __| __/ _ \\ '__/ _ \\ '__| .-'ooo'-. | |_)| __/ |_| || __/ | | __/ | - / | / |_.__//___|/__|/__/___|_| /___|_| + / | \\ |_.__/\\___|\\__|\\__\\___|_| \\___|_| 🎉 Betterer (0ms): 1 test done! ✅ test 1: "test 1" stayed the same. 😐 diff --git a/test/cli/__snapshots__/precommit-specific-file.spec.ts.snap b/test/cli/__snapshots__/precommit-specific-file.spec.ts.snap index fe31e499d..186fd7367 100644 --- a/test/cli/__snapshots__/precommit-specific-file.spec.ts.snap +++ b/test/cli/__snapshots__/precommit-specific-file.spec.ts.snap @@ -21,34 +21,34 @@ exports[`betterer precommit > should test just the specified files 1`] = ` ", "Checking 1 file... 🤔 -・ /fixtures/precommit-specific-file/src/new-file.ts +・ fixtures/precommit-specific-file/src/new-file.ts 🌟 Betterer: ", "Checking 1 file... 🤔 -・ /fixtures/precommit-specific-file/src/new-file.ts +・ fixtures/precommit-specific-file/src/new-file.ts 🌟 Betterer: 1 test running... 🤔 test: running "test"! ", "Checking 1 file... 🤔 -・ /fixtures/precommit-specific-file/src/new-file.ts +・ fixtures/precommit-specific-file/src/new-file.ts 🌟 Betterer: 1 test running... ✅ test: "test" stayed the same. (3 issues) 😐 ", "Checking 1 file... 🤔 -・ /fixtures/precommit-specific-file/src/new-file.ts +・ fixtures/precommit-specific-file/src/new-file.ts 🎉 Betterer: 1 test done! ✅ test: "test" stayed the same. (3 issues) 😐 ", "Checked 1 file! 🔍 -・ /fixtures/precommit-specific-file/src/new-file.ts +・ fixtures/precommit-specific-file/src/new-file.ts 🎉 Betterer: 1 test done! ✅ test: "test" stayed the same. (3 issues) 😐 diff --git a/test/cli/__snapshots__/precommit-worse.spec.ts.snap b/test/cli/__snapshots__/precommit-worse.spec.ts.snap index fdb6b0f9d..7ef0c2934 100644 --- a/test/cli/__snapshots__/precommit-worse.spec.ts.snap +++ b/test/cli/__snapshots__/precommit-worse.spec.ts.snap @@ -25,40 +25,36 @@ exports[`betterer precommit > should not update the changeset when a test gets w 🤔 test: running "test"! ", "🌟 Betterer: 1 test running... -🔥 test: "test" got worse. (1 new issue, 2 total) 😔 +🔥 test: "test" got worse. (1 new issue, 1 existing, 2 total) 😔 ", "🌟 Betterer: 1 test running... -🔥 test: "test" got worse. (1 new issue, 2 total) 😔 +🔥 test: "test" got worse. (1 new issue, 1 existing, 2 total) 😔 -Error: "test" got worse. (1 new issue, 2 total) 😔 +Error: "test" got worse. (1 new issue, 1 existing, 2 total) 😔 ", "💥 Betterer: 1 test done! 1 test errored! -🔥 test: "test" got worse. (1 new issue, 2 total) 😔 -・ 1 existing issue in "/fixtures/precommit-worse/src/index.ts". -・ New issue in "/fixtures/precommit-worse/src/index.ts"! +🔥 test: "test" got worse. (1 new issue, 1 existing, 2 total) 😔 +・ 1 existing, 1 new issues in "fixtures/precommit-worse/src/index.ts". ・ -・ /fixtures/precommit-worse/src/index.ts ・ 2 | const one = 1; ・ 3 | console.log(one * a); ・ > 4 | console.log(a * one); ・ | ^ The left-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type. ・ -Error: "test" got worse. (1 new issue, 2 total) 😔 +Error: "test" got worse. (1 new issue, 1 existing, 2 total) 😔 ", "💥 Betterer: 1 test done! 1 test errored! -🔥 test: "test" got worse. (1 new issue, 2 total) 😔 -・ 1 existing issue in "/fixtures/precommit-worse/src/index.ts". -・ New issue in "/fixtures/precommit-worse/src/index.ts"! +🔥 test: "test" got worse. (1 new issue, 1 existing, 2 total) 😔 +・ 1 existing, 1 new issues in "fixtures/precommit-worse/src/index.ts". ・ -・ /fixtures/precommit-worse/src/index.ts ・ 2 | const one = 1; ・ 3 | console.log(one * a); ・ > 4 | console.log(a * one); ・ | ^ The left-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type. ・ -Error: "test" got worse. (1 new issue, 2 total) 😔 +Error: "test" got worse. (1 new issue, 1 existing, 2 total) 😔 1 test got checked. 🤔 1 test got worse. 😔 diff --git a/test/cli/__snapshots__/results-file-test.spec.ts.snap b/test/cli/__snapshots__/results-file-test.spec.ts.snap index 0fadfb9b1..c984ee5d0 100644 --- a/test/cli/__snapshots__/results-file-test.spec.ts.snap +++ b/test/cli/__snapshots__/results-file-test.spec.ts.snap @@ -4,8 +4,8 @@ exports[`betterer cli > should report the current results for a file test 1`] = [ "test: - RegExp match - /fixtures/results-file-test/src/file-with-issue.ts:1:0 - RegExp match - /fixtures/results-file-test/src/file-with-issues.ts:1:0 - RegExp match - /fixtures/results-file-test/src/file-with-issues.ts:2:0", + RegExp match - fixtures/results-file-test/src/file-with-issue.ts:1:0 + RegExp match - fixtures/results-file-test/src/file-with-issues.ts:1:0 + RegExp match - fixtures/results-file-test/src/file-with-issues.ts:2:0", ] `; diff --git a/test/cli/__snapshots__/upgrade-exported-default-test-cjs.spec.ts.snap b/test/cli/__snapshots__/upgrade-exported-default-test-cjs.spec.ts.snap index 2621965c7..25587fdce 100644 --- a/test/cli/__snapshots__/upgrade-exported-default-test-cjs.spec.ts.snap +++ b/test/cli/__snapshots__/upgrade-exported-default-test-cjs.spec.ts.snap @@ -100,6 +100,6 @@ exports[`betterer upgrade > should upgrade exported default test in a CJS module ・", "🎉 Upgrading Betterer (0ms): 1 task done! ✅ Upgrading "./.betterer.ts": done! -・ Saved upgraded config to "/fixtures/upgrade-exported-default-test-cjs/.betterer.ts"! ☀️", +・ Saved upgraded config to "fixtures/upgrade-exported-default-test-cjs/.betterer.ts"! ☀️", ] `; diff --git a/test/cli/__snapshots__/upgrade-exported-default-test-esm.spec.ts.snap b/test/cli/__snapshots__/upgrade-exported-default-test-esm.spec.ts.snap index 1fdd2419a..b8d4e9d5f 100644 --- a/test/cli/__snapshots__/upgrade-exported-default-test-esm.spec.ts.snap +++ b/test/cli/__snapshots__/upgrade-exported-default-test-esm.spec.ts.snap @@ -100,6 +100,6 @@ exports[`betterer upgrade > should upgrade exported default test in an ES module ・", "🎉 Upgrading Betterer (0ms): 1 task done! ✅ Upgrading "./.betterer.ts": done! -・ Saved upgraded config to "/fixtures/upgrade-exported-default-test-esm/.betterer.ts"! ☀️", +・ Saved upgraded config to "fixtures/upgrade-exported-default-test-esm/.betterer.ts"! ☀️", ] `; diff --git a/test/cli/precommit-add.spec.ts b/test/cli/precommit-add.spec.ts index e3ef67900..79a42904e 100644 --- a/test/cli/precommit-add.spec.ts +++ b/test/cli/precommit-add.spec.ts @@ -52,14 +52,7 @@ export default { await writeFile(indexPath, `const a = 'a';\nconst one = 1;\nconsole.log(one + one);`); - let failed = false; - try { - await cliΔ(fixturePath, [...ARGV, 'precommit', '--workers=false']); - } catch { - failed = true; - } - - expect(failed).toEqual(false); + await cliΔ(fixturePath, [...ARGV, 'precommit', '--workers=false']); expect(logs).toMatchSnapshot(); diff --git a/test/runner/runner-excluded.spec.ts b/test/runner/runner-excluded.spec.ts index 917a47c93..46e5b7b3f 100644 --- a/test/runner/runner-excluded.spec.ts +++ b/test/runner/runner-excluded.spec.ts @@ -56,11 +56,14 @@ export default tslint.config( const runner = await betterer.runner({ configPaths, resultsPath, cwd, workers: false }); await runner.queue(testPath); - const suiteSummary = await runner.stop(); - const [runSummary] = suiteSummary.runSummaries; - expect(runSummary.isComplete).toEqual(true); - expect(runSummary.filePaths).toHaveLength(0); + const contextSummary = await runner.stop(); + + const runSuite = contextSummary?.lastSuite; + const [runSummary] = runSuite?.runSummaries ?? []; + + expect(runSummary?.isComplete).toEqual(true); + expect(runSummary?.filePaths).toHaveLength(0); await cleanup(); }); diff --git a/test/runner/runner-included.spec.ts b/test/runner/runner-included.spec.ts index dfb5af13d..f27c80cf5 100644 --- a/test/runner/runner-included.spec.ts +++ b/test/runner/runner-included.spec.ts @@ -56,11 +56,14 @@ export default tslint.config( const runner = await betterer.runner({ configPaths, resultsPath, cwd, workers: false }); await runner.queue(indexPath); - const suiteSummary = await runner.stop(); - const [runSummary] = suiteSummary.runSummaries; - expect(runSummary.isNew).toEqual(true); - expect(runSummary.filePaths).toEqual([indexPath]); + const contextSummary = await runner.stop(); + + const runSuite = contextSummary?.lastSuite; + const [runSummary] = runSuite?.runSummaries ?? []; + + expect(runSummary?.isNew).toEqual(true); + expect(runSummary?.filePaths).toEqual([indexPath]); await cleanup(); }); diff --git a/test/watch/__snapshots__/watch-debounced.spec.ts.snap b/test/watch/__snapshots__/watch-debounced.spec.ts.snap index be510c353..b5165b5a4 100644 --- a/test/watch/__snapshots__/watch-debounced.spec.ts.snap +++ b/test/watch/__snapshots__/watch-debounced.spec.ts.snap @@ -14,8 +14,8 @@ Ignores (press "i" to edit): No current ignore patterns Checking 2 files... 🤔 -・ /fixtures/watch-debounce/src/file.ts -・ /fixtures/watch-debounce/src/index.ts +・ fixtures/watch-debounce/src/file.ts +・ fixtures/watch-debounce/src/index.ts 🌟 Betterer (0ms): @@ -26,8 +26,8 @@ Ignores (press "i" to edit): No current ignore patterns Checking 2 files... 🤔 -・ /fixtures/watch-debounce/src/file.ts -・ /fixtures/watch-debounce/src/index.ts +・ fixtures/watch-debounce/src/file.ts +・ fixtures/watch-debounce/src/index.ts 🌟 Betterer (0ms): 1 test running... 🤔 test: running "test"! @@ -39,8 +39,8 @@ Ignores (press "i" to edit): No current ignore patterns Checking 2 files... 🤔 -・ /fixtures/watch-debounce/src/file.ts -・ /fixtures/watch-debounce/src/index.ts +・ fixtures/watch-debounce/src/file.ts +・ fixtures/watch-debounce/src/index.ts 🌟 Betterer (0ms): 1 test running... ✅ test: "test" got checked for the first time! (3 issues) 🎉 @@ -52,8 +52,8 @@ Ignores (press "i" to edit): No current ignore patterns Checking 2 files... 🤔 -・ /fixtures/watch-debounce/src/file.ts -・ /fixtures/watch-debounce/src/index.ts +・ fixtures/watch-debounce/src/file.ts +・ fixtures/watch-debounce/src/index.ts 🎉 Betterer (0ms): 1 test done! ✅ test: "test" got checked for the first time! (3 issues) 🎉 @@ -65,8 +65,8 @@ Ignores (press "i" to edit): No current ignore patterns Checked 2 files! 🔍 -・ /fixtures/watch-debounce/src/file.ts -・ /fixtures/watch-debounce/src/index.ts +・ fixtures/watch-debounce/src/file.ts +・ fixtures/watch-debounce/src/index.ts 🎉 Betterer (0ms): 1 test done! ✅ test: "test" got checked for the first time! (3 issues) 🎉 diff --git a/test/watch/__snapshots__/watch-ignored.spec.ts.snap b/test/watch/__snapshots__/watch-ignored.spec.ts.snap index ad33cfd8c..19e75a0ef 100644 --- a/test/watch/__snapshots__/watch-ignored.spec.ts.snap +++ b/test/watch/__snapshots__/watch-ignored.spec.ts.snap @@ -14,7 +14,7 @@ Ignores (press "i" to edit): No current ignore patterns Checking 1 file... 🤔 -・ /fixtures/watch-ignored/src/index.ts +・ fixtures/watch-ignored/src/index.ts 🌟 Betterer (0ms): @@ -25,7 +25,7 @@ Ignores (press "i" to edit): No current ignore patterns Checking 1 file... 🤔 -・ /fixtures/watch-ignored/src/index.ts +・ fixtures/watch-ignored/src/index.ts 🌟 Betterer (0ms): 1 test running... 🤔 test: running "test"! @@ -37,7 +37,7 @@ Ignores (press "i" to edit): No current ignore patterns Checking 1 file... 🤔 -・ /fixtures/watch-ignored/src/index.ts +・ fixtures/watch-ignored/src/index.ts 🌟 Betterer (0ms): 1 test running... ✅ test: "test" got checked for the first time! (1 issue) 🎉 @@ -49,7 +49,7 @@ Ignores (press "i" to edit): No current ignore patterns Checking 1 file... 🤔 -・ /fixtures/watch-ignored/src/index.ts +・ fixtures/watch-ignored/src/index.ts 🎉 Betterer (0ms): 1 test done! ✅ test: "test" got checked for the first time! (1 issue) 🎉 @@ -61,7 +61,7 @@ Ignores (press "i" to edit): No current ignore patterns Checked 1 file! 🔍 -・ /fixtures/watch-ignored/src/index.ts +・ fixtures/watch-ignored/src/index.ts 🎉 Betterer (0ms): 1 test done! ✅ test: "test" got checked for the first time! (1 issue) 🎉 diff --git a/test/watch/__snapshots__/watch-quit.spec.ts.snap b/test/watch/__snapshots__/watch-quit.spec.ts.snap index 45095db95..f5f24d69a 100644 --- a/test/watch/__snapshots__/watch-quit.spec.ts.snap +++ b/test/watch/__snapshots__/watch-quit.spec.ts.snap @@ -14,7 +14,7 @@ Ignores (press "i" to edit): No current ignore patterns Checking 1 file... 🤔 -・ /fixtures/watch-quit/src/index.ts +・ fixtures/watch-quit/src/index.ts 🌟 Betterer (0ms): @@ -25,7 +25,7 @@ Ignores (press "i" to edit): No current ignore patterns Checking 1 file... 🤔 -・ /fixtures/watch-quit/src/index.ts +・ fixtures/watch-quit/src/index.ts 🌟 Betterer (0ms): 1 test running... 🤔 test: running "test"! @@ -37,7 +37,7 @@ Ignores (press "i" to edit): No current ignore patterns Checking 1 file... 🤔 -・ /fixtures/watch-quit/src/index.ts +・ fixtures/watch-quit/src/index.ts 🌟 Betterer (0ms): 1 test running... ✅ test: "test" got checked for the first time! (2 issues) 🎉 @@ -49,7 +49,7 @@ Ignores (press "i" to edit): No current ignore patterns Checking 1 file... 🤔 -・ /fixtures/watch-quit/src/index.ts +・ fixtures/watch-quit/src/index.ts 🎉 Betterer (0ms): 1 test done! ✅ test: "test" got checked for the first time! (2 issues) 🎉 @@ -61,7 +61,7 @@ Ignores (press "i" to edit): No current ignore patterns Checked 1 file! 🔍 -・ /fixtures/watch-quit/src/index.ts +・ fixtures/watch-quit/src/index.ts 🎉 Betterer (0ms): 1 test done! ✅ test: "test" got checked for the first time! (2 issues) 🎉 diff --git a/test/watch/__snapshots__/watch.spec.ts.snap b/test/watch/__snapshots__/watch.spec.ts.snap index 42a707a7d..bdb52e1ce 100644 --- a/test/watch/__snapshots__/watch.spec.ts.snap +++ b/test/watch/__snapshots__/watch.spec.ts.snap @@ -31,7 +31,7 @@ Ignores (press "i" to edit): No current ignore patterns Checking 1 file... 🤔 -・ /fixtures/watch/src/index.ts +・ fixtures/watch/src/index.ts 🌟 Betterer (0ms): @@ -42,7 +42,7 @@ Ignores (press "i" to edit): No current ignore patterns Checking 1 file... 🤔 -・ /fixtures/watch/src/index.ts +・ fixtures/watch/src/index.ts 🌟 Betterer (0ms): 1 test running... 🤔 test: running "test"! @@ -54,10 +54,10 @@ Ignores (press "i" to edit): No current ignore patterns Checking 1 file... 🤔 -・ /fixtures/watch/src/index.ts +・ fixtures/watch/src/index.ts 🌟 Betterer (0ms): 1 test running... -🔥 test: "test" got worse. (1 new issue, 3 total) 😔 +🔥 test: "test" got worse. (1 new issue, 2 existing, 3 total) 😔 (press "q" to quit) ", @@ -66,12 +66,12 @@ Ignores (press "i" to edit): No current ignore patterns Checking 1 file... 🤔 -・ /fixtures/watch/src/index.ts +・ fixtures/watch/src/index.ts 🌟 Betterer (0ms): 1 test running... -🔥 test: "test" got worse. (1 new issue, 3 total) 😔 +🔥 test: "test" got worse. (1 new issue, 2 existing, 3 total) 😔 -Error: "test" got worse. (1 new issue, 3 total) 😔 +Error: "test" got worse. (1 new issue, 2 existing, 3 total) 😔 (press "q" to quit) ", @@ -80,20 +80,18 @@ Ignores (press "i" to edit): No current ignore patterns Checking 1 file... 🤔 -・ /fixtures/watch/src/index.ts +・ fixtures/watch/src/index.ts 💥 Betterer (0ms): 1 test done! 1 test errored! -🔥 test: "test" got worse. (1 new issue, 3 total) 😔 -・ 2 existing issues in "/fixtures/watch/src/index.ts". -・ New issue in "/fixtures/watch/src/index.ts"! +🔥 test: "test" got worse. (1 new issue, 2 existing, 3 total) 😔 +・ 2 existing, 1 new issues in "fixtures/watch/src/index.ts". ・ -・ /fixtures/watch/src/index.ts ・ 1 | console.log('foo'); ・ > 2 | console.log('foo');console.log('foo'); ・ | ^^^^^^^^^^^ TSQuery match ・ -Error: "test" got worse. (1 new issue, 3 total) 😔 +Error: "test" got worse. (1 new issue, 2 existing, 3 total) 😔 (press "q" to quit) ", @@ -102,20 +100,18 @@ Ignores (press "i" to edit): No current ignore patterns Checked 1 file! 🔍 -・ /fixtures/watch/src/index.ts +・ fixtures/watch/src/index.ts 💥 Betterer (0ms): 1 test done! 1 test errored! -🔥 test: "test" got worse. (1 new issue, 3 total) 😔 -・ 2 existing issues in "/fixtures/watch/src/index.ts". -・ New issue in "/fixtures/watch/src/index.ts"! +🔥 test: "test" got worse. (1 new issue, 2 existing, 3 total) 😔 +・ 2 existing, 1 new issues in "fixtures/watch/src/index.ts". ・ -・ /fixtures/watch/src/index.ts ・ 1 | console.log('foo'); ・ > 2 | console.log('foo');console.log('foo'); ・ | ^^^^^^^^^^^ TSQuery match ・ -Error: "test" got worse. (1 new issue, 3 total) 😔 +Error: "test" got worse. (1 new issue, 2 existing, 3 total) 😔 1 test got checked. 🤔 1 test got worse. 😔 @@ -129,20 +125,18 @@ Ignores (press "i" to edit): No current ignore patterns Checking 1 file... 🤔 -・ /fixtures/watch/src/index.ts +・ fixtures/watch/src/index.ts 💥 Betterer (0ms): 1 test done! 1 test errored! -🔥 test: "test" got worse. (1 new issue, 3 total) 😔 -・ 2 existing issues in "/fixtures/watch/src/index.ts". -・ New issue in "/fixtures/watch/src/index.ts"! +🔥 test: "test" got worse. (1 new issue, 2 existing, 3 total) 😔 +・ 2 existing, 1 new issues in "fixtures/watch/src/index.ts". ・ -・ /fixtures/watch/src/index.ts ・ 1 | console.log('foo'); ・ > 2 | console.log('foo');console.log('foo'); ・ | ^^^^^^^^^^^ TSQuery match ・ -Error: "test" got worse. (1 new issue, 3 total) 😔 +Error: "test" got worse. (1 new issue, 2 existing, 3 total) 😔 (press "q" to quit) ", @@ -151,7 +145,7 @@ Ignores (press "i" to edit): No current ignore patterns Checking 1 file... 🤔 -・ /fixtures/watch/src/index.ts +・ fixtures/watch/src/index.ts 🌟 Betterer (0ms): 1 test running... 🤔 test: running "test"! @@ -163,7 +157,7 @@ Ignores (press "i" to edit): No current ignore patterns Checking 1 file... 🤔 -・ /fixtures/watch/src/index.ts +・ fixtures/watch/src/index.ts 🌟 Betterer (0ms): 1 test running... ✅ test: "test" stayed the same. (2 issues) 😐 @@ -175,7 +169,7 @@ Ignores (press "i" to edit): No current ignore patterns Checking 1 file... 🤔 -・ /fixtures/watch/src/index.ts +・ fixtures/watch/src/index.ts 🎉 Betterer (0ms): 1 test done! ✅ test: "test" stayed the same. (2 issues) 😐 @@ -187,7 +181,7 @@ Ignores (press "i" to edit): No current ignore patterns Checked 1 file! 🔍 -・ /fixtures/watch/src/index.ts +・ fixtures/watch/src/index.ts 🎉 Betterer (0ms): 1 test done! ✅ test: "test" stayed the same. (2 issues) 😐 @@ -202,7 +196,7 @@ Ignores (press "i" to edit): No current ignore patterns Checking 1 file... 🤔 -・ /fixtures/watch/src/index.ts +・ fixtures/watch/src/index.ts 🎉 Betterer (0ms): 1 test done! ✅ test: "test" stayed the same. (2 issues) 😐 @@ -214,7 +208,7 @@ Ignores (press "i" to edit): No current ignore patterns Checking 1 file... 🤔 -・ /fixtures/watch/src/index.ts +・ fixtures/watch/src/index.ts 🌟 Betterer (0ms): 1 test running... 🤔 test: running "test"! @@ -226,7 +220,7 @@ Ignores (press "i" to edit): No current ignore patterns Checking 1 file... 🤔 -・ /fixtures/watch/src/index.ts +・ fixtures/watch/src/index.ts 🌟 Betterer (0ms): 1 test running... ✅ test: "test" got better! (1 fixed issue, 1 remaining) 😍 @@ -238,7 +232,7 @@ Ignores (press "i" to edit): No current ignore patterns Checking 1 file... 🤔 -・ /fixtures/watch/src/index.ts +・ fixtures/watch/src/index.ts 🎉 Betterer (0ms): 1 test done! ✅ test: "test" got better! (1 fixed issue, 1 remaining) 😍 @@ -250,7 +244,7 @@ Ignores (press "i" to edit): No current ignore patterns Checked 1 file! 🔍 -・ /fixtures/watch/src/index.ts +・ fixtures/watch/src/index.ts 🎉 Betterer (0ms): 1 test done! ✅ test: "test" got better! (1 fixed issue, 1 remaining) 😍 diff --git a/test/watch/watch-ignored.spec.ts b/test/watch/watch-ignored.spec.ts index b9fff84db..cedf850ca 100644 --- a/test/watch/watch-ignored.spec.ts +++ b/test/watch/watch-ignored.spec.ts @@ -61,7 +61,7 @@ ignored.ts await runner.stop(); - expect(runSummary.filePaths).toHaveLength(1); + expect(runSummary?.filePaths).toHaveLength(1); expect(logs).toMatchSnapshot();