1.0.2 • Published 3 years ago

statewize-dev-client v1.0.2

Weekly downloads
-
License
GPL-3.0-only
Repository
-
Last release
3 years ago

STATEWIZE dev client

Version

This is the client used to debug your code locally. It connects to statewize-dev-server which MUST be installed and running :) This client should be installed as a dev-dependency in your local codebase.

Allows you to:

  1. Debug line by line local functions
  2. Mock functions' outputs for ease of development and testing

Example project

Please see this repository for a quick-start example project.

Usage

  1. Install the dev server:

YARN:

yarn add -D statewize-dev-client

NPM:

npm install -D statewize-dev-client
  1. Initialize the dev server in your main file (but only when developing / debugging your code, do NOT do this for production):
// require:
const {dev} = require('statewize-dev-client');

// debug functions, or mock function outputs, as mapped to your states on STATEWIZE:
const {sunshine} = require('./sunshine'); // or any other function you want to debug.

dev({
   // map state name to its function or mock:
   'mocked-state': {
      path: require.resolve('./index'), // MUST use the require.resolve syntax to provide full file path
      handler: {a: 123, mock: true} // in handler, either provide your function, or a mock object (as it's done here)
   },
   'sunshine-state': {
      path: require.resolve('./sunshine'),
      handler: sunshine // this will cause the state "sunshine-state" to trigger your local "sunshine" function when debugging
   },
})
  1. Toggle debug mode on the canvas: Image

  2. Now, run your project, and start an execution on STATEWIZE Image

For more comprehensive docs, please visit our Developers' Documentation