Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

console.log() doesn't work in evalScript command when $ (dollar) is in the string #1760

Open
bullPaul opened this issue May 31, 2024 · 1 comment · May be fixed by #2060
Open

console.log() doesn't work in evalScript command when $ (dollar) is in the string #1760

bullPaul opened this issue May 31, 2024 · 1 comment · May be fixed by #2060
Labels
bug Something isn't working js Related to JavaScript support maestro cli Related to the command-line Maestro tool P2 Important and valid issues not at the top of the work list

Comments

@bullPaul
Copy link

Describe the bug
Adding a $ (dollar sign) within the ${} for inline-javascript for use as a string does not work as expected. It works with just a regular plain string e.g. "$100" but if you need to use it with an env variable then it goes awry.

Case 1: - evalScript: ${console.log('$')}
Case 2: - text: '${"$" + ENV_VARIABLE + "+"}'

This was mentioned in Slack as well.

To Reproduce
0. Write the test with the single line

  1. Start the simulator
  2. Run maestro test ...
  3. The step is run without an issue but no log is actually sent to the terminal

Expected behavior
For cases written above:

  1. Gets logged to the terminal with the dollar sign and the value of the env variable
  2. assertVisible etc works as expected with this while parsing the screen as usual

Screenshots
N/A

Environment information (please complete the following information):

  • Maestro version [v.1.36.0]
  • Platform: [iOS 17.0.0+]
  • Framework: [React Native with Expo]
  • Device model and OS version: [iPhone 14+]
  • Simulator
  • Host [Mac]

Workspace (if applicable)
N/A

Bugreport output (if applicable)
N/A

Additional context
N/A

@bullPaul bullPaul added the bug Something isn't working label May 31, 2024
@bartekpacia
Copy link
Contributor

bartekpacia commented Aug 24, 2024

I was able to reproduce this bug

flow

appId: com.example.example
---
- launchApp
- evalScript: ${console.log('Hello!')}
- evalScript: ${console.log('Hello money! $')}
- evalScript: ${console.log('$')}

output

Running on emulator-5554

 ║
 ║  > Flow
 ║
 ║    ✅  Launch app "com.example.example"
 ║    ✅  Run ${console.log('Hello!')}
 ║         Log messages:
 ║           Hello!
 ║    ✅  Run ${console.log('Hello money! $')}
 ║    ✅  Run ${console.log('$')}
 ║

On the other hand, this works

flow

appId: com.example.example
---
- launchApp
- runScript: script.js

output

$ maestro test maestro_issue_1760/flow_2.yaml
Running on emulator-5554

 ║
 ║  > Flow
 ║
 ║    ✅  Launch app "com.example.example"
 ║    ✅  Run script.js
 ║         Log messages:
 ║           Hello!
 ║           Hello money! $
 ║           $
 ║

@bartekpacia bartekpacia added P2 Important and valid issues not at the top of the work list maestro cli Related to the command-line Maestro tool js Related to JavaScript support labels Aug 24, 2024
@bartekpacia bartekpacia changed the title [v.1.36.0] $ within inline-javascript cannot be used console.log() doesn't work in evalScript command when $ (dollar) is in the string Aug 24, 2024
@tokou tokou linked a pull request Sep 16, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working js Related to JavaScript support maestro cli Related to the command-line Maestro tool P2 Important and valid issues not at the top of the work list
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants