All Downloads are FREE. Search and download functionalities are using the official Maven repository.

maestro.orchestra.util.Env.kt Maven / Gradle / Ivy

Go to download

Maestro is a server-driven platform-agnostic library that allows to drive tests for both iOS and Android using the same implementation through an intuitive API.

There is a newer version: 1.38.1
Show newest version
package maestro.orchestra.util

import maestro.js.JsEngine
import maestro.orchestra.DefineVariablesCommand
import maestro.orchestra.MaestroCommand

object Env {

    fun String.evaluateScripts(jsEngine: JsEngine): String {
        val result = "(?
                val script = match.groups[1]?.value ?: ""

                if (script.isNotBlank()) {
                    jsEngine.evaluateScript(script).toString()
                } else {
                    ""
                }
            }

        return result
            .replace("\\\\\\\$\\{([^\$]*)}".toRegex()) { match ->
                match.value.substringAfter('\\')
            }
    }

    fun List.withEnv(env: Map): List {
        if (env.isEmpty()) {
            return this
        }

        return listOf(MaestroCommand(DefineVariablesCommand(env))) + this
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy