-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Description
Describe the bug
I am trying to follow the example provided on the Vitest homepage for browser.testerScripts:
browser: {
testerScripts: [
{
src: 'https://code.jquery.com/jquery-3.3.1.min.js',
},
],
},According to the documentation, browser.testerScripts is a custom script injection feature for the browser environment. The script source and content should be processed by Vite plugins, and this feature seems ideal for injecting polyfills or external libraries required for certain browser tests.
However, when I attempt to inject an external script (in this case, jQuery), the URL is transformed to:
http://localhost:5173/@fs//https://code.jquery.com/jquery-3.3.1.min.js
This results in a failed request with a 404 error, as the transformation to the local server address is incorrect for external URLs.
Expected behaviour:
External URLs provided in browser.testerScripts should not be transformed by Vite or should be handled correctly so that the script can be loaded and injected into the browser test environment.
Reproduction
- Configure browser.testerScripts with an external script URL, e.g., jQuery:
browser: {
testerScripts: [
{
src: 'https://code.jquery.com/jquery-3.3.1.min.js',
},
],
},- Run Vitest in the browser.
- Check the network tab for the failed script request with the transformed URL.
System Info
System:
OS: macOS 14.4.1
CPU: (10) arm64 Apple M1 Pro
Memory: 3.51 GB / 16.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 18.20.3 - ~/.nvm/versions/node/v18.20.3/bin/node
Yarn: 1.22.22 - ~/.nvm/versions/node/v18.20.3/bin/yarn
npm: 10.7.0 - ~/.nvm/versions/node/v18.20.3/bin/npm
pnpm: 9.5.0 - ~/Library/pnpm/pnpm
bun: 1.1.27 - ~/.bun/bin/bun
Browsers:
Chrome: 129.0.6668.101
Edge: 130.0.2849.46
Safari: 17.4.1
npmPackages:
@vitejs/plugin-vue: ^5.0.3 => 5.0.3
@vitest/browser: ^2.1.3 => 2.1.3
vite: ^5.0.12 => 5.0.12
vitest: ^2.1.3 => 2.1.3Used Package Manager
pnpm
Validations
- Follow our Code of Conduct
- Read the Contributing Guidelines.
- Read the docs.
- Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.
- The provided reproduction is a minimal reproducible example of the bug.