Socket
Socket
Sign inDemoInstall

@salesforce/cli-plugins-testkit

Package Overview
Dependencies
Maintainers
49
Versions
296
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@salesforce/cli-plugins-testkit - npm Package Compare versions

Comparing version 0.0.2 to 0.0.3

lib/execCmd.d.ts

2

CHANGELOG.md

@@ -5,2 +5,4 @@ # Changelog

### [0.0.3](https://github.com/salesforcecli/cli-plugins-testkit/compare/v0.0.2...v0.0.3) (2021-02-03)
### [0.0.2](https://github.com/salesforcecli/cli-plugins-testkit/compare/v0.0.1...v0.0.2) (2021-01-28)

@@ -7,0 +9,0 @@

export * from './genUniqueString';
export * from './execCmd';
export { Duration } from '@salesforce/kit';

@@ -19,3 +19,7 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.Duration = void 0;
__exportStar(require("./genUniqueString"), exports);
__exportStar(require("./execCmd"), exports);
var kit_1 = require("@salesforce/kit");
Object.defineProperty(exports, "Duration", { enumerable: true, get: function () { return kit_1.Duration; } });
//# sourceMappingURL=index.js.map

23

package.json
{
"name": "@salesforce/cli-plugins-testkit",
"description": "Provides test utilities to assist Salesforce CLI plug-in authors with writing non-unit tests (NUT).",
"version": "0.0.2",
"version": "0.0.3",
"author": "Salesforce",

@@ -54,2 +54,3 @@ "license": "BSD-3-Clause",

"@salesforce/ts-types": "^1.4.4",
"debug": "^4.3.1",
"shelljs": "^0.8.4"

@@ -62,17 +63,19 @@ },

"@salesforce/ts-sinon": "^1.2.3",
"@types/debug": "^4.1.5",
"@types/shelljs": "^0.8.8",
"@types/sinon": "^9.0.10",
"@typescript-eslint/eslint-plugin": "^2.30.0",
"@typescript-eslint/parser": "^2.30.0",
"@typescript-eslint/eslint-plugin": "^4.14.1",
"@typescript-eslint/parser": "^4.14.1",
"chai": "^4.2.0",
"codecov": "^3.8.1",
"cz-conventional-changelog": "^3.3.0",
"eslint": "^6.8.0",
"eslint-config-prettier": "^6.11.0",
"eslint": "^7.18.0",
"eslint-config-prettier": "^7.2.0",
"eslint-config-salesforce": "^0.1.0",
"eslint-config-salesforce-license": "^0.1.0",
"eslint-config-salesforce-typescript": "^0.1.0",
"eslint-plugin-header": "^3.0.0",
"eslint-plugin-import": "^2.20.2",
"eslint-plugin-jsdoc": "^27.0.3",
"eslint-plugin-prettier": "^3.1.3",
"eslint-config-salesforce-typescript": "^0.2.0",
"eslint-plugin-header": "^3.1.0",
"eslint-plugin-import": "^2.22.1",
"eslint-plugin-jsdoc": "^31.4.0",
"eslint-plugin-prettier": "^3.3.1",
"husky": "^4.2.5",

@@ -79,0 +82,0 @@ "mocha": "^8.2.1",

@@ -9,3 +9,3 @@ [![NPM](https://img.shields.io/npm/v/@salesforce/cli-plugins-testkit.svg)](https://www.npmjs.com/package/@salesforce/cli-plugins-testkit)

The @salesforce/cli-plugins-testkit library provides test utilities to assist Salesforce CLI plug-in authors with writing integration, smoke, and e2e style testing. For example, you could write tests to ensure your plugin commands execute properly using an isolated Salesforce project, scratch org, and different Salesforce CLI install paths.
The @salesforce/cli-plugins-testkit library provides test utilities to assist Salesforce CLI plug-in authors with writing NUTs (non-unit-tests), like integration, smoke, and e2e style testing. For example, you could write tests to ensure your plugin commands execute properly using an isolated Salesforce project, scratch org, and different Salesforce CLI executables.

@@ -22,6 +22,62 @@ # Usage

Examples and More TBD
Using a different file exention will help seperate your unit tests from your NUTs even if they are in the same directories. For example, if you use `mytest.nut.ts` instead of `mytest.test.ts`, you can have the following scripts in your package.json (assuming mocha).
```json
{
"scripts": {
"test": "mocha **/*.test.ts",
"test-nut": "mocha **/*.nut.ts"
}
}
```
## Running Commands
Running oclif commands locally is as simple as running against the local `bin/run` file.
```typescript
import { exec } from 'shelljs';
const result = exec('./bin/run mycommand --myflag --json');
console.log(JSON.parse(result.stdout));
```
However, that doesn't provide flexiblity to target different CLI executables in Continous Integration (CI). For example, you may want to run NUTs against the newly published version of your plugin against the latest-rc of the Salesforce CLI to make sure everything still works as expected.
The testkit provides `execCmd` which makes the executable configurable as well as builtin json parsing.
```typescript
import { execCmd } from '@salesforce/cli-plugins-testkit';
const result = execCmd('mycommand --myflag --json');
console.log(result.jsonOutput);
```
The executable can then be configured in CI using the `TESTKIT_EXECUTABLE_PATH`.
```bash
# Install the release candidate in the current directory using NPM
npm install sfdx@latest-rc
# Install the newly published version of my plugin
./node_modules/.bin/sfdx plugins:install myplugin
# Target the local sfdx
export TESTKIT_EXECUTABLE_PATH=./node_modules/.bin/sfdx
# Run NUT test (requires a test-nut script target in the package.json)
yarn test-nut
```
You will notice that the executable is not configurable in the `execCmd` method directly. If you need to run other commands not located in your plugin, use shelljs directly.
```typescript
import { exec } from 'shelljs';
import { execCmd } from '@salesforce/cli-plugins-testkit';
await exec('sfdx auth:jwt:grant ... --json');
const result = await execCmd('mycommand --myflag --json');
```
## Contributing
TBD
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc