Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

witcher

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

witcher - npm Package Compare versions

Comparing version 0.1.0 to 0.2.0

start-dev.sh

14

CHANGELOG.md

@@ -8,2 +8,16 @@ # Changelog

## [0.2.0] - 2023-08-18
### Added
- Param `waitForMs` to test unit configuration (will wait for given amount of time before running the test)
- Test web server for E2E verification of `witcher`
- E2E test for eventual-consistent APIs
- Verification pipeline step for E2E tests
### Changed
- Structure of testing configuration files
- README to reflect changes in the project
## [0.1.0] - 2023-08-14

@@ -10,0 +24,0 @@

5

package.json
{
"name": "witcher",
"version": "0.1.0",
"version": "0.2.0",
"description": "Lightweight and fast API testing framework with database checking.",

@@ -14,3 +14,4 @@ "main": "./dist/index.mjs",

"serve": "ts-node ./src/index.mts",
"serve:dev": "nodemon",
"serve:dev": "./start-dev.sh",
"start:test-ws-bg": "(cd ./tests/web-server && npm ci && npm run start &) && npx --yes wait-port http://127.0.0.1:5070/healthcheck -t 20000",
"lint": "eslint . && prettier . --check",

@@ -17,0 +18,0 @@ "lint-fix": "prettier . --write && eslint . --fix"

103

readme.md

@@ -12,26 +12,33 @@ # Witcher API Tester

# Running the Project Locally
# Prerequisites
## Setup / First Time
- Node.js 18.0 or higher
- `npm`
- Run `npm i` the first time to install dependencies.
- Update `./test-json/testSetup.json` and `./test-json/testUnits.json` to fit your API.
# Installation
## Running
Witcher can be run using the `npx` command. This will download the latest version of Witcher and run it.
- `npm run serve` This will run the project and give you a command line prompt.
- Options to Toggle:
- `Interactive` – run tests one by one
- `Stop on Failure` - stop the test suite on the first failure.
- Choose `File on your computer` as data source
- Select one of the files placed in the `./tests-json` folder
- Optionally select database connection secrets from `./tests-json/secrets` folder
```bash
npx witcher
```
# Running the Project with Joystick-Hosted Configs
Otherwise, you can install `witcher` globally with `npm i -g witcher` which will allow you to run `witcher` without `npx`
Joystick is robust remote configuration service. Using Witcher with Joystick-hosted configs means your entire team can collaborate and update your tests.
> **Note**
> If you use global installation – make sure your "PATH" environment variable contains the
> folder where `npm` puts the binaries
## Setup / First Time
# First-time setup
- Run `npm i` for the first time to install dependencies.
## Local Configs
- Update `./test-json/testSetup.json` and `./test-json/testUnits.json` to fit your API.
## Running the Project with Joystick-Hosted Configs
Joystick is a robust remote configuration service. Using Witcher with Joystick-hosted configs means your entire team can collaborate and update your tests.
### Setup / First Time
- Create an account on [Joystick](https://app.getjoystick.com/)

@@ -53,15 +60,55 @@ - Create an organization, product and environment for your testing configs.

## Running
# Running in interactive mode
- `npm run serve` This will run the project and give you a command line prompt.
## Local Configs
- Run `npx witcher`
- Options to Toggle:
- `Interactive` – run tests one by one
- `Stop on Failure` - stop the test suite on the first failure.
- Choose `File on your computer` as data source
- Select one of the files placed in the current working directory
- Optionally select database connection secrets from `./secrets` folder
## Joystick-Hosted Configs
- `npx witcher`
- Choose options:
- `Interactive` – run tests one by one
- `Stop on failure` - stop the test suite on the first failure
- Choose `Joystick` as data source
- For the first time you'll be requested to name the environment and specify the API key. You can find the API key in the settings of the environment on Joystick.
- Paste the `ContentID` of the root config created in the previous step
- Select one of the files placed in the `./tests-json` folder
- Optionally select secrets from `./tests-json/secrets` folder
- Choose `Joystick` as a data source
- For the first time, you'll be requested to name the environment and specify the API key. You can find the API key in the settings of the environment on Joystick.
- Paste the `ContentID` of the root config created in the first-time setup step
- Optionally select secrets from `./secrets` folder
- The environment info is stored locally (`homeDirectory + "/.witcher/.joystick.json"`) so when you run `witcher` again, you can select an existing profile.
# Running in CI environment (non-interactive mode)
## In Github Actions
Please refer to the [documentation](https://github.com/marketplace/actions/run-api-test-with-witcher) of running Witcher in Github Actions
## In other CI environments
Witcher supports running in non-interactive mode and passing all necessary parameters as CLI arguments.
Please refer to the `--help` output for the list of available options.
```bash
npx witcher --help
```
Typical usage for local config may look like this:
```bash
npx witcher local ./testWebServerSetup.json --secret ./path/to/secret.json
```
And for Joystick-hosted config:
```bash
npx witcher joystick --apiKey 'xxxxxxxxxxx' --configId 'test-webserver-setup' --secret ./path/to/secret.json
```
The application will exit with code `0` if all tests passed and `1` if at least one test failed.
# Notes

@@ -71,4 +118,4 @@

- Witcher requires two configurations: a Test Setup "root" config and one or more Test Units config. The Test Setup config can reference or more Test Units config.
- For an example with comments if you have have a PostgreSQL db to check see: `./tests-json/testSetup.json` and `./tests-json/testUnits.json`
- For an example with comments for just API validation see: `./tests-json/noDbTestSetup.json` and `./tests-json/noDbTestUnits.json`
- For an example with comments if you have have a PostgreSQL db to check see: `./tests/configs/testSetup.json` and `./tests/configs/testUnits.json`
- For an example with comments for just API validation see: `./tests/configs/noDbTestSetup.json` and `./tests/configs/noDbTestUnits.json`

@@ -89,3 +136,3 @@ ## Schematics

This is entry point / starting point of a test run. This should be a .json file in the ./tests-json folder.
This is entry point / starting point of a test run. This should be a .json file in the directory where you want to run `npx witcher`.

@@ -131,3 +178,3 @@ ```jsonc

If you want to share the original Setup Config with other developers, but don't want to share your secrets, you can put them in a separate file.
This file should be in the `./tests-json/secrets` folder
This file should be in the `./secrets` folder with the `.json` extension.

@@ -150,3 +197,3 @@ ```jsonc

This should be a .json file that is in the ./tests-json folder.
This should be a .json file that is in the same folder as your root config.

@@ -153,0 +200,0 @@ ```jsonc

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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