# slack-cli-test-util

> Prototype for slack cli test lib package

Latest version **2.2.1** (published 2023-07-27) · ISC license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install slack-cli-test-util
pnpm add slack-cli-test-util
yarn add slack-cli-test-util
bun add slack-cli-test-util
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 2.2.1 |
| Published | 2023-07-27 |
| First published | 2023-07-27 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 4 |
| Unpacked size | 94.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | sgorby |

## Links

- npm: https://www.npmjs.com/package/slack-cli-test-util
- npm.io page: https://npm.io/package/slack-cli-test-util

## Dependencies (4)

- [winston](https://npm.io/package/winston.md) ^3.8.2
- [tree-kill](https://npm.io/package/tree-kill.md) ^1.2.2
- [typescript](https://npm.io/package/typescript.md) ^4.3.5
- [@types/node](https://npm.io/package/@types/node.md) ^18.15.5

## Recent versions

- 2.2.1 (latest) — 2023-07-27
- 2.2.0 — 2023-07-27

## README

# slack-cli-test-util

This library is designated to automate [Slack Command Line Interface](https://github.com/slackapi/slack-cli) (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

```bash
npm install slack-cli-test-util
```

2. 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
3. Import and use SlackCLILib, VerificationHelper or SlackTracerId

```ts
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`

```ts
// 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

| EnvVar              | Required | Note                                                                           |
| ------------------- | -------- | ------------------------------------------------------------------------------ |
| SLACK_CLI_PATH      | yes      | path to slack cli binary                                                       |
| SLACK_CLI_LOG_LEVEL | no       | default: 'info'. [Logger levels](https://github.com/winstonjs/winston#logging) |

---
_Source: https://npm.io/package/slack-cli-test-util · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
