-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
inso cli scripting first pass (#7790)
* poc * add header test * fix lint * fix types * make require work * low cost abstraction * test insomnia.sendRequest * remove execa * split tests and improve docs * dynamic import to fix build
- Loading branch information
Showing
23 changed files
with
600 additions
and
418 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,109 @@ | ||
<!-- markdownlint-disable heading-style first-line-h1 --> | ||
<!-- markdownlint-disable no-inline-html --> | ||
<div align="center"> | ||
<br /> | ||
<br /> | ||
<img src="https://raw.githubusercontent.com/Kong/insomnia/develop/packages/insomnia-inso/assets/logo.svg" alt=""/> | ||
<h1> | ||
Inso CLI | ||
<br /> | ||
<br /> | ||
</h1> | ||
<h3>A CLI for <a href="https://insomnia.rest">Insomnia</a></h3> | ||
<pre>npm install --global <a href="https://www.npmjs.com/package/insomnia-inso">insomnia-inso</a></pre> | ||
<img src="https://raw.githubusercontent.com/Kong/insomnia/develop/packages/insomnia-inso/assets/demo.gif" alt=""/> | ||
<br /> | ||
</div> | ||
<br /> | ||
<!-- markdownlint-enable no-inline-html --> | ||
|
||
## Documentation | ||
|
||
See the [open-source Inso CLI documentation](https://docs.insomnia.rest/inso-cli/introduction). | ||
# Documentation | ||
|
||
How to use [Inso CLI](https://docs.insomnia.rest/inso-cli/introduction). | ||
|
||
## Testing | ||
|
||
```shell | ||
# unit tests | ||
npm run test:unit | ||
|
||
# start smoke test api (required for e2e tests) | ||
npm run serve -w insomnia-smoke-test | ||
|
||
# e2e tests for dev bundle | ||
npm run test:bundle | ||
|
||
# e2e tests for binary | ||
npm run test:binary | ||
``` | ||
|
||
## Development | ||
|
||
### Getting started | ||
|
||
```shell | ||
npm run inso-start | ||
npm run test -w insomnia-inso | ||
# will default to insomnia app database | ||
$PWD/packages/insomnia-inso/bin/inso run test | ||
# will use config, useful for testing with fewer args | ||
$PWD/packages/insomnia-inso/bin/inso -w packages/insomnia-inso/src/db/fixtures/git-repo script runTest | ||
``` | ||
|
||
### node-libcurl | ||
|
||
`Error: The module '.../insomnia/node_modules/@getinsomnia/node-libcurl/lib/binding/node_libcurl.node' | ||
was compiled against a different Node.js version using` | ||
|
||
node-libcurl builds for 3 operating systems and two versions of nodejs. insomnia-inso uses the nodejs build and insomnia app uses the electron build. you can switch between them using the following two commands | ||
|
||
```shell | ||
# install node version | ||
node_modules/.bin/node-pre-gyp install --update-binary --directory node_modules/@getinsomnia/node-libcurl | ||
# install electron version | ||
node_modules/.bin/node-pre-gyp install --update-binary --directory node_modules/@getinsomnia/node-libcurl --runtime=electron --target=30.0.0 | ||
``` | ||
|
||
## Run CLI Smoke Tests | ||
|
||
```shell | ||
# Run CLI tests | ||
npm run test:bundle -w insomnia-inso | ||
# Package the Inso CLI binaries | ||
npm run inso-package | ||
npm run test:binary -w insomnia-inso | ||
``` | ||
|
||
## Debugging CLI tests using watcher | ||
|
||
This is helpful for debugging failing api tests | ||
|
||
From project root, in separate terminals: | ||
|
||
```sh | ||
# start smoke test api | ||
npm run serve -w insomnia-smoke-test | ||
|
||
# watch inso | ||
npm run start -w insomnia-inso | ||
|
||
# run api test with dev bundle | ||
$PWD/packages/insomnia-inso/bin/inso run test "Echo Test Suite" --src $PWD/packages/insomnia-smoke-test/fixtures/inso-nedb --env Dev --verbose | ||
``` | ||
|
||
## How to debug pkg | ||
|
||
```sh | ||
# run modify package command and then a unit test | ||
npm run package -w insomnia-inso && \ | ||
$PWD/packages/insomnia-inso/binaries/inso run test "Echo Test Suite" --src $PWD/packages/insomnia-smoke-test/fixtures/inso-nedb --env Dev --verbose | ||
|
||
``` | ||
|
||
## How to update the `inso-nedb` fixtures | ||
|
||
Run Insomnia with `INSOMNIA_DATA_PATH` environment variable set to `fixtures/inso-nedb`, e.g.: | ||
|
||
```bash | ||
INSOMNIA_DATA_PATH=packages/insomnia-smoke-test/fixtures/inso-nedb /Applications/Insomnia.app/Contents/MacOS/Insomnia | ||
``` | ||
|
||
Relaunch the app one more time, so that Insomnia compacts the database. | ||
|
||
The `.gitignore` file will explicitly ignore certain database files, to keep the directory size down and avoid prevent sensitive data leaks. | ||
|
||
## How to run inso with the `inso-nedb` fixture locally? | ||
|
||
Set the `--src` argument pointed to `packages/insomnia-smoke-test/fixtures/inso-nedb`: | ||
|
||
```bash | ||
# if installed globally | ||
inso --src <INSO_NEDB_PATH> | ||
|
||
# using the package bin | ||
./packages/insomnia-inso/bin/inso --src <INSO_NEDB_PATH> | ||
|
||
# using a binary | ||
./packages/insomnia-inso/binaries/insomnia-inso --src <INSO_NEDB_PATH> | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.