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

Importing JS modules (both CJS and ESM) doesn't work in GraalJS #1637

Open
valdero opened this issue Dec 29, 2023 · 9 comments
Open

Importing JS modules (both CJS and ESM) doesn't work in GraalJS #1637

valdero opened this issue Dec 29, 2023 · 9 comments
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

@valdero
Copy link

valdero commented Dec 29, 2023

Describe the bug
Graaljs supports importing CommonJS or ECMAScript modules. However, due to maestro's GraalJsEngine implementation, no module imports work currently.

This most likely happens as Context.newBuilder("js") is missing .allowIO(true) here: https://github.com/mobile-dev-inc/maestro/blob/main/maestro-client/src/main/java/maestro/js/GraalJsEngine.kt#L83

See more info on module imports in the graalVM reference manual: https://www.graalvm.org/latest/reference-manual/js/Modules/#ecmascript-modules-esm

To Reproduce

  1. Create two js files, e.g. main.js and env.mjs
// main.js
import { env } from "./two.mjs";

const testImport = () => {
  console.log(`${env.URL}`);
  return env.URL;
};

output.url = testImport();
// env.mjs
export const env = {
  URL: "https://example.com",
  ANOTHER_URL: "https://another-example.com",
};
  1. Include main.js in e.g. main.yaml
appId: com.example.myapplication
jsEngine: graaljs
---
- runScript: main.js
- evalScript: ${console.log(output.url)}
  1. Run maestro test main.yaml

Expected behavior
Importing CommonJS or ECMAScript modules should work.

Screenshots
Currently maestro tries to evaluate the import as a script.
Screenshot 2023-12-30 at 0 28 29

@valdero valdero added the bug Something isn't working label Dec 29, 2023
@JohnValanidas
Copy link

Is there any traction on this issue? Our team is evaluating Maestro, and we're running into an issue similar to the above.

@yonice7
Copy link

yonice7 commented Jan 30, 2024

Having the same problem here

@karamangokhan
Copy link

same issue

@monaelaidy
Copy link

Same issue :(

@tiagodread
Copy link

Hey @axelniklasson @igorsmotto any expectations for fixing this bug?

@bartekpacia
Copy link
Contributor

hey @tiagodread! Bartek from mobile.dev team here. I see this issue is highly requested. I'll try to prioritize it in the coming weeks, because it looks like the benefit/effort required ratio is pretty good here.

In the meantime, of course, we're always happy to accept contributions.

@bartekpacia bartekpacia added the maestro cli Related to the command-line Maestro tool label Jul 12, 2024
@bartekpacia bartekpacia changed the title [v1.34.1] Importing CommonJS or ECMAScript modules doesn't work with graaljs Importing JS modules (both CJS and ESM) doesn't work in GraalJS Jul 12, 2024
@bartekpacia bartekpacia added the js Related to JavaScript support label Jul 12, 2024
@itinsley-cnd

This comment has been minimized.

@bartekpacia bartekpacia added the P2 Important and valid issues not at the top of the work list label Aug 15, 2024
@tiagodread
Copy link

hey @tiagodread! Bartek from mobile.dev team here. I see this issue is highly requested. I'll try to prioritize it in the coming weeks, because it looks like the benefit/effort required ratio is pretty good here.

In the meantime, of course, we're always happy to accept contributions.

@bartekpacia I've tested this scenario along with #2022

@RTapper-PS
Copy link

same 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

No branches or pull requests

9 participants