maestro
maestro copied to clipboard
Importing JS modules (both CJS and ESM) doesn't work in GraalJS
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
- Create two js files, e.g.
main.js
andenv.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",
};
- Include
main.js
in e.g.main.yaml
appId: com.example.myapplication
jsEngine: graaljs
---
- runScript: main.js
- evalScript: ${console.log(output.url)}
- 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.
Is there any traction on this issue? Our team is evaluating Maestro, and we're running into an issue similar to the above.
Having the same problem here
same issue
Same issue :(
Hey @axelniklasson @igorsmotto any expectations for fixing this bug?
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.
Same issue.