Velo: About Functional Testing in the Backend

The code editor comes equipped with a quick-test environment for debugging your backend code.

Backend Code

Backend code is essential to any Velo site. Since backend code is not visible to site visitors, all sensitive information should be handled on the backend of your site

One drawback of backend code is that you need to invest effort to trigger the code and test it, such as calling functions from the client side on a test page in your site. This can slow down the development and debugging process. 

To save you time and effort, Velo enables quick testing of backend functions directly in the code editor. 

How It Works

For step-by-step instructions on how to test your backend code, see Functional Testing in the Backend.

To test your backend function in the code editor, write your function in a backend code file as usual. Click the Play icon  next to the function to open the testing environment.

A new tab opens in the code editor for testing your function. Add sample parameter values and run the function in the test tab. The output appears on the right side of the tab. 

Notes

  • You can only test functions located in .js, .web.js, and .jsw files.
  • You can only test functions that are exported.

Just Like Preview Mode

The output you see in the test tab is the same as the output you would see in the Developer Console if you previewed your site and triggered the function. Testing backend functions in the code editor has other similarities to testing in Preview mode:

  • If you run code that affects a Wix app, the Wix app data is updated. For example, if you're testing code that creates a new Wix Stores product, the product is created when you test the code. 
  • When testing code that interacts with a database collection not associated with a Wix app, you'll be working with the data in your sandbox database and not your live database.
  • When testing your code, you are assigned the Admin role. That means you are granted all possible permissions.
  • If there is a problem with your code, you'll see the same errors you would see in Preview mode.
  • You can use Logs to monitor your function output. The view mode is "Preview." 
Was this helpful?
Yes
No