/
Executing code in Test versus Live

Executing code in Test versus Live

The iguana.isTest() function checks if the script is running in the Translator editor (test mode). It returns true when the script is running in the Translator (test mode) and false when the script is running in a live component.

It’s often used with if statements to conditionally execute specific actions.

if iguana.isTest() then -- execute actions that I do not want to run live end if not iguana.isTest() then -- execute actions that I do not want to run in the editor (test mode) end

This function can be very handy when you want to avoid running code while editing. For instance, you may only want to perform a file write operation when the component is running live.

You can also use component.live() in a similar manner to change how code operates in the Translator editor versus when a component is live and running. This is a slightly more intuitive API.

 

Related content

Pattern Matching
Pattern Matching
Read with this
Choosing the code to run for your component
Choosing the code to run for your component
More like this
Slack
Read with this
iguana.stopOnError()
iguana.stopOnError()
More like this
Bulk Insert on Merge
Bulk Insert on Merge
Read with this
Translator - Toolbar
Translator - Toolbar
More like this