credred / karma-vite

A karma plugin. Transform es module by using vite.
MIT License
13 stars 4 forks source link

"Failed to load url" log output #8

Open thomasjm opened 11 months ago

thomasjm commented 11 months ago

When I try to use this plugin, I get slightly concerning "failed to load url" messages in the log output. They don't seem to affect the running of the tests, but I'd like to make them go away.

For example, I tried running the react example from this repo:

tom in ~/tools/karma-vite-react-example λ pnpm run test       

> @ test /home/tom/tools/karma-vite-react-example
> karma start

WebSocket server error: Port is already in use
19 10 2023 01:21:37.129:WARN [karma]: No captured browser, open http://localhost:9877/test/
19 10 2023 01:21:37.138:INFO [karma-server]: Karma v6.4.2 server started at http://localhost:9877/test/
19 10 2023 01:21:37.138:INFO [launcher]: Launching browsers ChromeHeadless with concurrency unlimited
19 10 2023 01:21:37.140:INFO [launcher]: Starting browser ChromeHeadless
19 10 2023 01:21:37.460:INFO [Chrome Headless 101.0.4950.0 (Linux x86_64)]: Connected on socket wI7gV6e9X34_FdDxAAAB with id 34240864
Failed to load url /test/base/node_modules/.pnpm/jasmine-core@4.6.0/node_modules/jasmine-core/lib/jasmine-core/jasmine.js?4d3d165a31f4a0cfbea94aa42ec76e0330a3121f (resolved id: /test/base/node_modules/.pnpm/jasmine-core@4.6.0/node_modules/jasmine-core/lib/jasmine-core/jasmine.js?4d3d165a31f4a0cfbea94aa42ec76e0330a3121f). Does the file exist?
Failed to load url /test/base/node_modules/.pnpm/karma-jasmine@5.1.0_karma@6.4.2/node_modules/karma-jasmine/lib/boot.js?760d54bbca4f739f1f8b252c1636d76201cc4e88 (resolved id: /test/base/node_modules/.pnpm/karma-jasmine@5.1.0_karma@6.4.2/node_modules/karma-jasmine/lib/boot.js?760d54bbca4f739f1f8b252c1636d76201cc4e88). Does the file exist?
Failed to load url /test/base/node_modules/.pnpm/karma-jasmine@5.1.0_karma@6.4.2/node_modules/karma-jasmine/lib/adapter.js?db55991565c0f0381ab0fb3c340df5194b4bef99 (resolved id: /test/base/node_modules/.pnpm/karma-jasmine@5.1.0_karma@6.4.2/node_modules/karma-jasmine/lib/adapter.js?db55991565c0f0381ab0fb3c340df5194b4bef99). Does the file exist?
Failed to load url /test/base/test/button.spec.tsx?03e521cbeac3f1a61985d33904014ea7655cff37 (resolved id: /test/base/test/button.spec.tsx?03e521cbeac3f1a61985d33904014ea7655cff37). Does the file exist?

  button test
    ✓ button width
    ✓ button click event

Chrome Headless 101.0.4950.0 (Linux x86_64): Executed 2 of 2 SUCCESS (0.023 secs / 0.018 secs)
TOTAL: 2 SUCCESS

I realize Karma is deprecated, but it still has 2.5M weekly downloads on NPM and is a bit difficult to find an alternative for, so it would be nice to figure this out.

mglennwithers commented 5 months ago

I faced a similar issue. The solution was to provide an alias in the karma.conf Vite config. This was my alias. You might need '/test/base':'/test' or /test/base':'' instead of /base:''

vite: {
    config: {
        resolve: {
            alias: {
                '/base': '',
            }
        }
    }
}