Betterer

website·Indexed 29 days ago

https://phenomnomnominal.github.io/betterer/docs/index

A testing framework that provides built-in tests for various tools including @betterer/eslint, @betterer/stylelint, @betterer/coverage, @betterer/tsquery, @betterer/typescript, @betterer/regexp, and @betterer/angular. The documentation covers the @betterer/betterer API, including BettererRunner, BettererReporter, BettererRun, and BettererSuite.

Tokens
42.7K
Snippets
372
Records
476
Agent score
72%

What's inside Betterer

  1. Overview of Betterer incremental testing

    Betterer is a test runner designed to help make incremental improvements to code, particularly in large or old codebases. When a test is run for the first time, Betterer takes a snapshot of the current state. In subsequent runs, it compares the current state against that snapshot: if the test result is worse, it throws an error; if the result is better, it updates the snapshot.
  2. Overview of Betterer for incremental codebase improvements

    Betterer is a tool designed to facilitate incremental improvements to a codebase. It prevents developers from moving further away from a defined goal by tracking a value over time (similar to snapshot testing) and ensuring that the value only changes in the desired direction. If a test result improves, Betterer updates the stored result; if it worsens, the test fails.
  3. Overview of Betterer incremental improvement testing

    Betterer is a test runner that facilitates incremental improvements to a codebase. Unlike traditional tests, Betterer takes a snapshot of the current state of a metric (e.g., the number of ESLint failures). On subsequent runs, it compares the current state against the snapshot: if the state has improved, the snapshot is updated; if the state has worsened, the test fails. This prevents the introduction of new issues while allowing developers to resolve existing ones over time.
  4. Overview of Betterer incremental testing

    Betterer is a test runner that facilitates incremental improvements to code by using a snapshot-based approach. Unlike traditional snapshot testing, Betterer operates in two stages: the first run captures the current state as a snapshot; subsequent runs compare the new result against that snapshot. If the result is 'better', the snapshot is automatically updated; if the result is 'worse', the test throws an error.
  5. Overview of @betterer/logger interfaces and types

    The @betterer/logger package provides the logging infrastructure used within Betterer to handle reporter and task logging asynchronously. It defines a set of interfaces and type aliases to standardize how messages and code blocks are logged.
  6. Overview of Betterer incremental testing

    Betterer is a test runner that facilitates incremental improvements to code. When a test is run for the first time, Betterer takes a snapshot of the current state. In subsequent runs, it compares the current state against the snapshot: if the test result is worse, it throws an error; if the result is better, it updates the snapshot.
  7. Use BettererContext to manage test suite run state

    The BettererContext interface represents the context of a set of test suite runs. It is primarily accessed through the BettererReporter interface, specifically within the contextStart and contextError hooks. It provides access to the current configuration and methods to modify options or stop the test run.
    const myReporter: BettererReporter = {
      // Access the context before any tests are run:
      contextStart (context: BettererContext) {
        // ...
      },
      // Access the context when something goes wrong:
      contextError (context: BettererContext) {
        // ...
      }
    }
  8. Use TypeScript with Betterer

    Betterer is designed to work with TypeScript and includes it as an optional dependency. By default, the Betterer initialization script creates a .betterer.ts test definition file and adds TypeScript as a dependency. Betterer uses ts-node to execute the test definition file, so manual compilation of the .betterer.ts file is not required.
  9. Use BettererRunSummary to analyze test results

    The BettererRunSummary interface represents the summary of a BettererTest run. It extends BettererRun and provides detailed status flags and data about the outcome of a test, such as whether it has improved (isBetter), regressed (isWorse), or met its goal (isComplete).
    export interface BettererRunSummary extends BettererRun
  10. Manage the Betterer results file

    Betterer saves all test results to a results file, which acts as a baseline. If a test result improves, Betterer updates the file, and the new result becomes the expected baseline. The results file is a valid JavaScript file and should be committed to source control. By default, the results file is named .betterer.results.
    # Run Betterer with a custom results file path
    betterer --results ./.custom.results
  11. Use BettererCoverageTest for coverage testing

    The BettererCoverageTest class is a specialized wrapper around BettererTest designed to simplify the implementation of coverage tests. It demonstrates advanced usage of the BettererTestOptions interface.

    Important Constraints:

    • The constructor is marked as internal.
    • Third-party developers should not call the constructor directly.
    • Third-party developers should not create subclasses that extend BettererCoverageTest.
    export declare class BettererCoverageTest extends BettererTest<BettererCoverageIssues, BettererCoverageIssues, BettererCoverageDiff>