Migrating legacy snippets to parameterized snippets

Parameterized JavaScript snippets were released on mabl Desktop App version 1.4.2. Snippets that were created prior to that version, including all snippets created in the mabl Trainer Chrome extension, are considered legacy snippets.


Example of a legacy snippet

If your workspace contains legacy snippets, we recommend that you convert your legacy snippets into parameterized snippets. The benefits of enabling snippet parameters include:

  1. Greater ease of use: Parameters make it easier for users who are less familiar with JavaScript to update values as needed.
  2. Greater reusability: By overriding default parameter values, it's easier to reuse snippets across your workspace.

This guide outlines the steps you can take to convert your legacy snippets into parameterized snippets.

Enabling parameters for a legacy snippet

  1. Open a test that contains the legacy snippet in the mabl Trainer. The step that uses a legacy snippet will show an Unparameterized snippet badge.
  2. Click on the Unparameterized snippet badge or the pencil icon to edit the snippet step.
  1. Click on the Edit code button. The Snippet Editor will appear in a new window.
  2. Click on Enable parameters.
  1. Identify any variables that come from the mablInputs object.

This snippet accesses a variable called "text" from the mablInputs object

  1. Convert those variables into parameters.

The "text" variable is added as the default parameter.

  1. Click Run to confirm that the snippet is working as expected.
  2. Click Save to confirm your changes. When you hover over the snippet step in the Trainer, you should see the parameters.
  1. Save your test with the newly converted snippet.

Once you've enabled parameters for your snippet, you can override the default value with a current value!




When you enable parameters in the code editor, adding a description of what a snippet does and how to work with its parameters can be helpful for other members of your workspace.