Skip to content

Latest commit

 

History

History
76 lines (52 loc) · 1.58 KB

File metadata and controls

76 lines (52 loc) · 1.58 KB

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-cli
npx 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 common

Expected

.expected(feedback: {
  stdout?: string|string[];         // Either text as is, or array of lines
  stderr?: string|string[];
})
.expected(stdout: string|string[])  // Only check stdout

The 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