2.2.51 • Published 11 months ago
cli-testlib-prototype-testing v2.2.51
cli-testlib-prototype-testing
This library is designated to automate slack command line interface (cli) methods. It provides a simplified and programmatic way to interact with the cli and used primarily for E2E testing.
Quickstart guide
- Install the package
npm install cli-testlib-prototype-testing
- Set cli path with environment variable
SLACK_CLI_PATH
- supply a link to a binary on the global path, like
slack-cli
,hermes
, orhermes-dev
- supply a link to a binary on the global path, like
- Import and use HermesCLILib, HermesVerificationHelper or SlackTracerId
import { HermesCLILib } from 'cli-testlib-prototype-testing';
...
const actualOutput = await HermesCLILib.runSimpleCommand('slack-cli version');
How to use the package
- HermesCLILib - contains all methods to interact with cli
- methods named after slack cli methods, e.g.
HermesCLILib.deploy()
- methods named after slack cli methods, e.g.
- HermesVerificationHelper - helper methods to verify cli output
- shouldContainString
- shouldContainStrings
- shouldNotContainStrings
- SlackTracerId - trace IDs to verify cli command output
- see available exported IDs on SlackTracerId object
- to enable:
SLACK_TEST_TRACE=true
// Import avialable objects from the package
import {
HermesCLILib,
SlackTracerId,
HermesVerificationHelper
} from 'cli-testlib-prototype-testing';
describe('CLI - Feedback', () => {
// Create a variable with a link to cli binary installed on your machine
const cli = process.env.SLACK_CLI_PATH;
it('can successfully follow the feedback survey link', async function () {
// Create command
const command = `${cli} feedback`;
// Collect actual output from the command
const actual = await HermesCLILib.runSimpleCommand(command);
// Set expected array of strings
const expected = [
// Expected string
'Feedback survey',
// Available trace
SlackTracerId.SLACK_TRACE_FEEDBACK_MESSAGE
];
// Check results with helper command
await HermesVerificationHelper.shouldContainStrings(actual, expected, command);
});
});
Configuration
EnvVar | Required | Note |
---|---|---|
SLACK_CLI_PATH | yes | path to slack cli binary |
SLACK_CLI_LOG_LEVEL | no | default: 'info'. Logger levels |