Example tests and snippets
Load testing an SPA
Load testing an SPA (single-page application is quite simple with LoadForge, but can be difficult with basic load testing tools.
A single-page application (SPA) is a web application that interacts with the user by dynamically rewriting the current web page with new data from the web server, instead of the default method of a web browser loading entire new pages.
In an SPA, a page refresh never occurs; instead, all necessary HTML, JavaScript, and CSS code is either retrieved by the browser with a single page load, or (more commonly) the appropriate resources are dynamically loaded and added to the page as necessary, usually in response to user actions.
How to Load Test an SPA
In a load test you want to simulate users arriving, and then browsing your site. With an SPA this can look a lot different, but is actually quite similar. For example, new users will request the page and especially javascript required to load the site.
Then "browsing" is often a JSON API request, which you will want to capture and simulate. This includes activities like logging in, checking out, browsing content, and so on.
You can find these requests by using your browsers Dev Tools, or, you can Record Your Browser and upload that to LoadForge to automatically generate a test. This is what makes it extremely easy to build SPA load tests with LoadForge.
The LoadForge wizard will also automatically get all the page dependencies for you, so you can easily start from a "fully loaded" position.
Setting up the Test
Once you have an accurate script as discussed above, the load test can be set-up like any normal test. The number of virtual users you want, their average wait times, and the length of the test.
You can easily configure these on your LoadForge test profile and begin testing right away!
Locust Test Example
LoadForge is powered by locust, meaning open source locust users can copy this script as well. If you are a locust user, consider importing your script to LoadForge to supercharge your testing!