Custom JavaScript actions

JavaScript Steps

If you know how to code in JavaScript, you can overcome any limitations of BugBug features. With the power and flexibility of custom code actions, you can run any function during your tests.
Hint! You can all native JS functions, ex. you can request data via XMLHttpRequest, or store values in localStorage, etc.
Remember! You can also use variables in your custom code

Advanced JavaScript assertions

Use JS code to add complex assertions. Run any function and if it returns true the assertions will pass.
Example: assert if an input element has a specific placeholder text.
  1. 1.
    Record a regular assertion to the input.
  2. 2.
    Change its type to "Custom Javascript assertion"
  3. 3.
    Enter custom JS code that checks the placeholder of the element, for example if (element.placeholder === 'Username') { return true } else {return false}

Make an API request from a custom Javascript code

Using the custom JS you can really do anything. For example, you can request some data from your API and use this data in a custom javascript variable or in an assertion.
Here's an example of how to make a server-side request from Javascript.
const response = await fetch('', {
cors: 'no-cors'
const json = await response.json();
return[0].email; //return the first user email
Note! This is coding, so it adds complexity and more problems to solve. If you encounter complications with cookies or "Access-Control-Allow-Origin” ask a developer for help or contact BugBug support. We recommend that you keep things simple and find another solution to achieve a similar goal.
Learn more in the full Fetch Web API documentation
We listed several ideas on what can you achieve with API requests via code:
Use API request to
Example use case
Compare the data displayed in your app with the data returned from the server
Check if your currency exchange is up-to-date
Get a list of test users and their parameters from a centralized testing data file
Get a login and password for your random test user, skipping the registration process
Get the latest item from a server and its ID
Check if the most recently added product is shown on the list of search results