@rapidjs.org/testing-cli
v0.1.1
Published
rJS Testing – CLI testing suite.
Readme
rJS Testing CLITest cli
rJS Testing CLI testing suite (CLITest): Test command line interfaces based on expected stdout or stderr.
npm i -D @rapidjs.org/testing-clinpx rjs-testing cli <tests-path>Integrated in
rapidjs-org/testing.
Configuration
In order to define common CLI aspects, they can be defined through the static .configure() method:
HTTPTest.configure(configuration: RequestOptions & {
commonBinary?: string;
});Test Anatomy
Expressions
Actual
.actual(binary: string, arg?: string[])
.actual(args: string[]) // Imply binary if defined a commonExpected
.expected(feedback: {
stdout?: string|string[]; // Either text as is, or array of lines
stderr?: string|string[];
})
.expected(stdout: string|string[]) // Only check stdoutThe execution output to be compared is whitespace normalised, i.e. any non-break whitespace character is condensed to a single space.
Value-based Assertion
new CLITest("Print working directory")
.actual("pwd")
.expected("/Users/rjs/app");Comparison Strategy
Before a comparison of a binary execution output, it is whitespace normalised. This is, any non-break whitespace character is condensed to a single space.
✅ SUCCESS
.actual("ls", [ "-L" ])
.expected("img1.png img2.png")❌ FAILURE
.actual("ls", [ "-L" ])
.expected("img1.png img2.png")© Thassilo Martin Schiepanski
