2.2.1 • Published 10 months ago

slack-cli-test-util v2.2.1

Weekly downloads
-
License
ISC
Repository
-
Last release
10 months ago

slack-cli-test-util

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 is used primarily for E2E testing.

Quickstart guide

  1. Install the package
npm install slack-cli-test-util
  1. Set cli path with environment variable SLACK_CLI_PATH
    • supply a link to a binary on the global path, like slack-cli
    • it will default to using slack otherwise
    • slack cli must be installed separately
  2. Import and use SlackCLILib, VerificationHelper or SlackTracerId
import { SlackCLILib } from 'slack-cli-test-util';
...
const actualOutput = await SlackCLILib.runSimpleCommand('slack-cli version');

How to use the package

  1. SlackCLILib - contains all methods to interact with cli
    • methods named after slack cli methods, e.g. SlackCLILib.deploy()
  2. VerificationHelper - helper methods to verify cli output
    • shouldContainString
    • shouldContainStrings
    • shouldNotContainStrings
  3. 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 { SlackCLILib, SlackTracerId, VerificationHelper } from 'slack-cli-test-util';

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 SlackCLILib.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 VerificationHelper.shouldContainStrings(actual, expected, command);
	});
});

Configuration

EnvVarRequiredNote
SLACK_CLI_PATHyespath to slack cli binary
SLACK_CLI_LOG_LEVELnodefault: 'info'. Logger levels
2.2.1

10 months ago

2.2.0

10 months ago

2.2.52

10 months ago