truepass
API reference

truepass

Every export of truepass, with its signature and doc comment: parseUnifiedDiff, unexplainedSnapshots, weakenedAssertions, MATCHER_RANK, check, createProgram and 1 more, plus 4 types.

truepass: what makes a test suite report green without the code passing.

import { parseUnifiedDiff, unexplainedSnapshots, weakenedAssertions, … } from 'truepass';

Functions

check

function check(base: string, git: Git): Promise<Finding[]>;
ParameterType
basestring
gitGit

Returns Promise<Finding[]>

createProgram

The program, over a given git: the real one in the bin, a fake one in the tests.

function createProgram(git: Git): import("burgee").Manifest;
ParameterType
gitGit

Returns import("burgee").Manifest

parseUnifiedDiff

Parse git diff --unified=0 output into files and hunks.

function parseUnifiedDiff(diff: string): FileDiff[];
ParameterType
diffstring

Returns FileDiff[]

unexplainedSnapshots

A changed snapshot needs a Snapshot: <reason> line in one of the range's commit messages — updating a snapshot is how a wrong output becomes the expected one, so the change has to say what it accepts.

function unexplainedSnapshots(changedPaths: string[], commitMessages: string): Finding[];
ParameterType
changedPathsstring[]
commitMessagesstring

Returns Finding[]

weakenedAssertions

Assertions on the same subject that moved to a weaker matcher. An Assertion: <why> line in one of the range's commit messages accepts them.

function weakenedAssertions(files: FileDiff[], commitMessages: string): Finding[];
ParameterType
filesFileDiff[]
commitMessagesstring

Returns Finding[]

Constants

MATCHER_RANK

Strictness, strongest first. A change that moves an assertion on the same subject to a lower rank accepts more wrong answers than it did.

const MATCHER_RANK: Readonly<Record<string, number>>;

program

const program: import("burgee").Manifest;

Interfaces

ChangedLine

The two truepass checks a lint rule cannot make, because they are about what a change did rather than what a file says: an assertion moved to a weaker matcher, and a snapshot rewritten with no reason given.

interface ChangedLine {
    line: number;
    text: string;
}

FileDiff

interface FileDiff {
    path: string;
    hunks: Hunk[];
}

Finding

interface Finding {
    check: 'weakened-assertion' | 'unexplained-snapshot';
    path: string;
    line: number;
    message: string;
}

Hunk

interface Hunk {
    removed: ChangedLine[];
    added: ChangedLine[];
}

On this page