1.0.2 • Published 3 years ago
statewize-dev-client v1.0.2
STATEWIZE dev client
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:
- Debug line by line local functions
- Mock functions' outputs for ease of development and testing
Example project
Please see this repository for a quick-start example project.
Usage
- Install the dev server:
YARN:
yarn add -D statewize-dev-client
NPM:
npm install -D statewize-dev-client
- 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
},
})
Toggle debug mode on the canvas:
Now, run your project, and start an execution on STATEWIZE
For more comprehensive docs, please visit our Developers' Documentation
1.0.2
3 years ago