Fakevars 1.0.1

I was tired of having to change code in my SC flows or work with a frontend or an api tool to test out something.

Enter Fakevars. Now you can define manually your GET, POST, and PARAM variables to test out SC flows.

This way you can maintain all the logic in your SC flow exactly the same by using the GET, POST, and PARAM variables and when you finished testing you can just disable or delete the Fakevars step.

This module will only run if your Node Environment $_ENV.NODE_ENV is set to development, but still you could end up uploading the SC file with sensitive data to a public site so be careful what data you use there.

This action will override the $_GET, $_POST, and $_PARAM variables if they were already set.

Changelog

Release 1.0.1

Added

  • Add $_PARAM variable
16 Likes

Great idea JonL, will take a look

1 Like

Simple things like this quite often offer such a productivity boost! Until now my approach was to create one set value action per get/post variable and assign them to environment variables with a default.

So if I had a $_POST.email variable I would do something like:

Set value email = $_ENV.TEST_EMAIL.default($_POST.email) and use this new email variable for the rest of the SC flow.

To test I would just need to create a new entry in my .env file called TEST_EMAIL and if not present it would default to the real value coming from the frontend.

While this approach improved my productivity while working exclusively on the backend it meant I had to add to maintain the env file constantly and adding additional set value steps as get/post variables I had.

I think this new extension will improve productivity even more when creating and testing quickly a SC flow.

@JonL That’s incredible, thank you!

1 Like

noice-5c88fe

1 Like

.default()? How did you even discover this? :open_mouth:

It’s a generic formatter.

image

2 Likes

Worth noting that this extension won’t work if you validate the input fields before you use fakevars so these two approaches are incompatible with the extension:

  1. You add validation on the input declaration.

  1. You run the validate step before declaring the fakevars

image

The only way fakevars make sense if you use it before the validation action and don’t add validation directly to the input.

image