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.

11251125

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.
301301
  1. Click on the Edit code button. The Snippet Editor will appear in a new window.
  2. Click on Enable parameters.
11251125
  1. Identify any variables that come from the mablInputs object.
11251125

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

  1. Convert those variables into parameters.
11241124

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

296296

👍

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.


Did this page help you?