0.1.1 • Published 9 months ago

@rapidjs.org/testing-cli v0.1.1

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
9 months ago

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

0.1.1

9 months ago

0.1.0

12 months ago