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

Invalid scenario file #93

Closed
jdelbarcogarza-softtek opened this issue Oct 3, 2023 · 8 comments
Closed

Invalid scenario file #93

jdelbarcogarza-softtek opened this issue Oct 3, 2023 · 8 comments

Comments

@jdelbarcogarza-softtek
Copy link

``Hello, I'm trying to test memlab for a project. While following the tutorial it worked, but now when trying to run a scenario in my project. The error Invalid scenario file: .\tests\test.js comes up. Context: I placed the `scenario.js` file inside `/src/test` folders.

Here is my scenario:


module.exports = {
    url: () => "http://localhost:5173/apps/music%20app/",
    action: async () => {
        // enter requests route by clicking link
        const elements = await page.$x(
            "//a[contains(., 'Requests')]"
        )

        if (elements.length > 0) {
            const [a] = elements;
            await a.click();

            // Clean up external references from memlab
            await Promise.all(elements.map((e) => e.dispose()));
        } else {
            console.log("No matching elements found.");
        }
    },
    back: async () => await page.click("a[contains(., 'Dashboard')]"),
};

Could someone put me in the right direction here on how to get memlab up and running?

@jdelbarcogarza-softtek
Copy link
Author

Update: when the file is extracted from the project's folder, memlab works. But should memlab be able to run code inside the project's codebase?

@JacksonGL
Copy link
Member

The scenario file doesn't define page function parameter for action and back, not sure why it works when it is outside the project's codebase

@mrdulin
Copy link

mrdulin commented Feb 27, 2024

same issue.

@JacksonGL
Copy link
Member

Do not forget about the page parameter in the scenario definition.

module.exports = {
  url: ...
  // do not forget about the `page` parameter here
  action: async (page) => { ... }
  // same
  back: async (page) => { ... }
}

@mrdulin
Copy link

mrdulin commented Feb 28, 2024

Do not forget about the page parameter in the scenario definition.

module.exports = {
  url: ...
  // do not forget about the `page` parameter here
  action: async (page) => { ... }
  // same
  back: async (page) => { ... }
}

OP's code has forgotten the page parameter, but this will not solve the issue.

@JacksonGL
Copy link
Member

@mrdulin To help understand and investigate the issue, can you share the steps to reproduce the issue you got? E.g., what the scenario file looked like, how you run the scenario file, and the error message.

@0918nobita
Copy link

0918nobita commented Mar 5, 2024

I was also facing the same issue. By removing the "type": "module" from package.json in npm package containing scenario.js to run and re-running memlab, the issue was resolved.

@0918nobita
Copy link

Alternatively, the issue can also be resolved by renaming scenario.js to scenario.cjs .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants