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:
- Greater ease of use: Parameters make it easier for users who are less familiar with JavaScript to update values as needed.
- 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
- 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.
- Click on the Unparameterized snippet badge or the pencil icon to edit the snippet step.

- Click on the Edit code button. The Snippet Editor will appear in a new window.
- Click on Enable parameters.

- Identify any variables that come from the
mablInputs
object.

This snippet accesses a variable called "text" from the mablInputs
object
- Convert those variables into parameters.

The "text" variable is added as the default parameter.
- Click Run to confirm that the snippet is working as expected.
- Click Save to confirm your changes. When you hover over the snippet step in the Trainer, you should see the parameters.

- 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!

Descriptions
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.
Updated 4 months ago