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.
![](https://d2x3xhvgiqkx42.cloudfront.net/12345678-1234-1234-1234-1234567890ab/0ca9e8ba-16ed-4cd8-a1e1-58d01c4420f7/2021/01/26/c5085f13-694a-4cd8-8cb4-360fc1d662d3/e81452fd-a43d-4588-b2ef-a814919c5162.png)
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.
![](https://d2x3xhvgiqkx42.cloudfront.net/12345678-1234-1234-1234-1234567890ab/0ca9e8ba-16ed-4cd8-a1e1-58d01c4420f7/2021/01/26/994be39b-daca-43d5-9cc9-41cab81a1550/9712276d-4b56-4648-864f-12c79ef5ef01.png)
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."
What's Next? Learn how to test your backend functions.