-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #20 from shoma-mano/fix
fix: runScript can't be used in imported flow
- Loading branch information
Showing
18 changed files
with
255 additions
and
173 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { getOutput, M } from "maests"; | ||
import { openApp } from "@/fixtures/utils/openApp"; | ||
import { someScript } from "./utils/script"; | ||
|
||
// use composable flow easiliy | ||
openApp(); | ||
|
||
// run script like this | ||
M.runScript(someScript); | ||
|
||
// use variables set in someScript | ||
M.assertVisible({ id: getOutput("id") }); | ||
|
||
// use runFlow to run some flow with condition | ||
M.runFlow({ | ||
flow: () => { | ||
M.repeatWhileNotVisible( | ||
{ | ||
text: "4", | ||
}, | ||
() => { | ||
M.tapOnText("Increment"); | ||
} | ||
); | ||
}, | ||
condition: { | ||
visible: "Increment", | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export const hello = () => "Hello, World!"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { M } from "maests"; | ||
|
||
export const openApp = () => { | ||
M.initFlow({ appId: "com.my.app" }); | ||
M.launchApp({ appId: "com.my.app" }); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import type { APIResult } from "./type"; | ||
import { hello } from "./hello"; | ||
|
||
export const someScript = () => { | ||
// typed http request | ||
const body = http.get("https://jsonplaceholder.typicode.com/todos/1").body; | ||
const result = json<APIResult>(body); | ||
console.log("id " + result.userId); | ||
|
||
// you can use environment variables | ||
console.log(`appId from env: ${process.env.APP_ID}`); | ||
|
||
// you can use imported functions | ||
console.log("imported file " + hello()); | ||
|
||
if (maestro.platform === "android") { | ||
console.log("platform is android"); | ||
} | ||
|
||
// set a variable to output to use in flow | ||
output.id = "com.my.app:id/action_bar_root"; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
export type APIResult = { | ||
userId: number; | ||
id: number; | ||
title: string; | ||
completed: boolean; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export const nestScript = () => { | ||
console.log("nestScript"); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
import { M } from "maests"; | ||
import { nestScript } from "./nest-script"; | ||
|
||
export const openApp = () => { | ||
M.initFlow({ appId: "com.my.app" }); | ||
M.launchApp({ appId: "com.my.app" }); | ||
M.runScript(nestScript); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,7 @@ | |
"**/*.tsx", | ||
".expo/types/**/*.ts", | ||
"expo-env.d.ts", | ||
"test.js" | ||
"test.js", | ||
"e2e/sample-flow.mts" | ||
] | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.