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.
Example of a JavaScript snippet
A snippet is custom JavaScript code that runs in a test. Depending on your requirements, you can save snippets as a one-time snippet or reuse them in other tests:
- One-time snippets are saved with a specific version of a test or flow. If you revert the test or flow to a previous version, the snippet also reverts to what was used in the previous version. If the snippet didn't exist in the previous test or flow version, it is removed.
- Reusable snippets can be used across other tests. When you update a reusable snippet, the changes apply everywhere the snippet is used. You can manage reusable snippets, including their versioning, from the snippets page: Tests > Snippets.
Snippets by test type
The following table outlines capabilities and characteristics for JavaScript snippets by test type:
Test type | Details |
Browser |
|
Mobile |
|
API |
|
Reusable snippets created in browser and mobile tests use the same default mablJavaScriptStep function and can be shared interchangeably between these two test types. Reusable API snippets, on the other hand, can only be shared with other API tests.
Supported JavaScript version
The JavaScript Snippet Editor supports ECMAScript 8.
Learn more
Check out the following articles for more information on snippets:
See our public JavaScript repo for a number of user-created snippets.