Skip to main content

BettererFileTest

API > @betterer/betterer > BettererFileTest

A very common usecase for Betterer is to track issues across all the files in a project. BettererFileTest provides a wrapper around BettererTest that makes it easier to implement such a test.

Signature

export declare class BettererFileTest implements BettererFileTestBase 
Implements: BettererFileTestBase

Remarks

BettererFileTest provides a useful example for the more complex possibilities of the BettererTestOptions interface.

Example

const fileTest = new BettererFileTest(async (filePaths, fileTestResult) => {
await Promise.all(
filePaths.map(async (filePath) => {
const fileContents = await fs.readFile(filePath, 'utf8');
const file = fileTestResult.addFile(filePath, fileContents);
file.addIssue(0, 1, `There's something wrong with this file!`);
})
);
});

Constructors

ConstructorModifiersDescription
(constructor)(fileTest)Constructs a new instance of the BettererFileTest class

Properties

PropertyModifiersTypeDescription
configBettererFileTestConfigThe complete configuration for the test.
isOnlybooleanWhen true, all other tests will be skipped. Calling only() will set this to true.
isSkippedbooleanWhen true, this test will be skipped. Calling skip() will set this to true.

Methods

MethodModifiersDescription
constraint(constraintOverride)Override the constraint in the test configuration.
deadline(deadlineOverride)Override the deadline in the test configuration.
exclude(excludePatterns)Add a list of Regular Expression filters for files to exclude when running the test.
goal(goalOverride)Override the goal in the test configuration.
include(includePatterns)Add a list of glob patterns for files to include when running the test.
only()Run only this test. All other tests will be marked as skipped.
skip()Skip this test.