JavaScript snippets

An introduction to JavaScript snippets

While mabl allows you to test many web apps and APIs without code, sometimes there are app-specific use cases that aren't supported out of the box. JavaScript snippets offer a way to accomplish tasks for more advanced use cases.

995

Example of a JavaScript snippet

Use cases

Some uses for JavaScript include:

  • Generating the current date in a specific format
  • Storing the current URL as a variable and visiting it at a later point in the test
  • Formatting a value that was extracted from the page
  • Returning to the previous page in the browser

JavaScript version support

The JavaScript Snippet Editor supports ECMAScript 8. Keep in mind that browsers have different levels of JavaScript support. Mabl executes tests using the latest Chrome, Firefox, Safari (WebKit), and Edge, which broadly support ES8 standard features.

Internet Explorer primarily supports up to ES5, notably missing features such as Array.prototype.includes and async/await for asynchronous functions.

📘

External libraries

Importing external JavaScript libraries is not currently supported.

A number of user-created snippets can be found in our public JavaScript repo.

Get started

To learn more about how JavaScript snippets work in mabl browser tests, check out the following resources:

Visit our public JavaScript repo to view more examples.

🚧

Legacy snippets

Parameterized JavaScript snippets were released on mabl Desktop App version 1.4.2. If your workspace contains unparameterized snippets (legacy snippets), we recommend convert them into parameterized snippets.

Learn more about migrating your legacy snippets here.