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

tests fail with v2 and svelte-kit #28

Open
michaelvogt opened this issue Nov 4, 2021 · 5 comments
Open

tests fail with v2 and svelte-kit #28

michaelvogt opened this issue Nov 4, 2021 · 5 comments
Labels
bug Something isn't working

Comments

@michaelvogt
Copy link
Contributor

Hello.

Just spent some time to set up a plain svelte-kit project with a simple mocha-vite-puppeteer test. This test runs through without problem with mocha-vite-puppeteer v1.x, but fails when switching to v2.

https://github.com/michaelvogt/kit-testing/tree/main/tmp/my-app

The stack trace looks like this:

C:\tmp\my-app\node_modules\puppeteer\lib\cjs\puppeteer\common\ExecutionContext.js:221
            throw new Error('Evaluation failed: ' + helper_js_1.helper.getExceptionMessage(exceptionDetails));
                  ^

Error: Evaluation failed: ReferenceError: mocha is not defined
    at __puppeteer_evaluation_script__:3:5
    at ExecutionContext._evaluateInternal (C:\tmp\my-app\node_modules\puppeteer\lib\cjs\puppeteer\common\ExecutionContext.js:221:19)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async ExecutionContext.evaluate (C:\tmp\my-app\node_modules\puppeteer\lib\cjs\puppeteer\common\ExecutionContext.js:110:16)
    at async file:///C:/tmp/my-app/node_modules/mocha-vite-puppeteer/cli.js:140:24

I have the feeling that this is something simple, but I don't know how to debug this.

@larsthorup
Copy link
Owner

Hey @michaelvogt thank your for creating a repo with reproduction! I have been sick this week, but hope to look into this shortly.

@larsthorup larsthorup added the bug Something isn't working label Nov 5, 2021
@michaelvogt
Copy link
Contributor Author

No worries, please take your time to get healthy again.

@larsthorup
Copy link
Owner

When I create an empty index.html (or with any html content really) next to test.html in the my-app folder of your repo, then npm test will run successfully no matter whether enableBarePath is set to true or false:

 13:39:28 /c/r/github/michaelvogt/kit-testing/tmp/my-app
$ ls -l index.html
-rw-r--r-- 1 lars 197609 0 Nov  7 13:33 index.html
 13:39:31 /c/r/github/michaelvogt/kit-testing/tmp/my-app
$ npm test

> my-app@0.0.1 test
> mocha-vite-puppeteer

[vite] connecting...


  Counter
    ✔ should count


  1 passing (7ms)

To me it seems like this is a requirement of Vite, rather than being something we can do anything about in mocha-vite-puppeteer.

@michaelvogt Could you verify if this "solution" also works with your other svelte-kit project?

@larsthorup
Copy link
Owner

Assuming the "solution" above is confirmed, we could improve the developer experience by giving a better error message in this case...

@michaelvogt
Copy link
Contributor Author

I think the important information here is, that the 1.x version of mocha-vite-puppeteer work fine, only the 2.x version is broken.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants