Tests don't run on Windows without admin privileges
See original GitHub issueDescribe the bug
When I try to run the tests, I get a crash because a symlink cannot be created.
$ pnpm run test
> vite-monorepo@ test C:\Users\Johannes\Code\vite
> run-s test-serve test-build
> vite-monorepo@ test-serve C:\Users\Johannes\Code\vite
> jest
Error: Jest: Got error running globalSetup - C:\Users\Johannes\Code\vite\scripts\jestGlobalSetup.cjs, reason: EPERM: operation not permitted, symlink 'C:\Users\Johannes\Code\vite\packages\plugin-vue-jsx' -> 'C:\Users\Johannes\Code\vite\packages\temp\worker\node_modules\@vitejs\plugin-vue-jsx'
ELIFECYCLE Command failed with exit code 1.
ERROR: "test-serve" exited with 1.
ELIFECYCLE Test failed. See above for more details.
I can get around this by opening VSCode with admin privileges (in the startup menu, search for “VSCode”, right-click, and run as admin). Some of the tests do still fail, but it’s only 4 out of 465.[^1]
It is possible that I have not set up my development environment correctly. I’m running Git Bash (MINGW64) in VSCode as my terminal, but I get the same error in Cmd (if I run Cmd as an admin, it works).
[^1]: Failed tests:
FAIL packages/playground/ssr-webworker/__tests__/ssr-webworker.spec.ts (46.281 s)
● /
thrown: "Exceeded timeout of 30000 ms for a hook.
Use jest.setTimeout(newTimeout) to increase the timeout value, if this is a long-running test."
57 | }
58 |
> 59 | beforeAll(async () => {
| ^
60 | const page = global.page
61 | if (!page) {
62 | return
at Object.<anonymous> (scripts/jestPerTestSetup.ts:59:1)
● Test suite failed to run
listen EADDRINUSE: address already in use :::9528
32 | return new Promise((resolve, reject) => { 33 | try {
> 34 | const server = app.listen(port, () => {
| ^
35 | resolve({
36 | // for test teardown
37 | async close() {
at packages/playground/ssr-webworker/__tests__/serve.js:34:26
at serve (packages/playground/ssr-webworker/__tests__/serve.js:32:10)
at scripts/jestPerTestSetup.ts:88:20
FAIL packages/playground/ssr-pug/__tests__/ssr-pug.spec.ts (31.084 s)
● injected inline scripts › no injected inline scripts are present
thrown: "Exceeded timeout of 30000 ms for a hook.
Use jest.setTimeout(newTimeout) to increase the timeout value, if this is a long-running test."
57 | }
58 |
> 59 | beforeAll(async () => {
| ^
60 | const page = global.page
61 | if (!page) {
62 | return
at Object.<anonymous> (scripts/jestPerTestSetup.ts:59:1)
● injected inline scripts › injected script proxied
correctly
thrown: "Exceeded timeout of 30000 ms for a hook.
Use jest.setTimeout(newTimeout) to increase the timeout value, if this is a long-running test."
57 | }
58 |
> 59 | beforeAll(async () => {
| ^
60 | const page = global.page
61 | if (!page) {
62 | return
at Object.<anonymous> (scripts/jestPerTestSetup.ts:59:1)
● Test suite failed to run
listen EADDRINUSE: address already in use :::9530
17 | return new Promise((resolve, reject) => { 18 | try {
> 19 | const server = app.listen(port, () => {
| ^
20 | resolve({
21 | // for test teardown
22 | async close() {
at Function.listen (node_modules/.pnpm/express@4.17.2/node_modules/express/lib/application.js:618:24)
at packages/playground/ssr-pug/__tests__/serve.js:19:26
at serve (packages/playground/ssr-pug/__tests__/serve.js:17:10)
at scripts/jestPerTestSetup.ts:88:20
Test Suites: 3 failed, 61 passed, 64 total
Tests: 4 failed, 461 passed, 465 total
Snapshots: 61 passed, 61 total
Time: 74.32 s
Ran all test suites.
ELIFECYCLE Command failed with exit code 1.
ERROR: "test-serve" exited with 1.
ELIFECYCLE Test failed. See above for more details.
Reproduction
https://github.com/vitejs/vite
System Info
System:
OS: Windows 10 10.0.19043
CPU: (8) x64 Intel(R) Core(TM) i7-2600 CPU @ 3.40GHz
Memory: 9.60 GB / 15.97 GB
Binaries:
Node: 14.15.5 - C:\Program Files\nodejs\node.EXE
Yarn: 1.22.17 - ~\AppData\Roaming\npm\yarn.CMD
npm: 8.1.4 - C:\Program Files\nodejs\npm.CMD
Browsers:
Chrome: 99.0.4844.74
Edge: Spartan (44.19041.1266.0), Chromium (99.0.1150.46)
Internet Explorer: 11.0.19041.1566
npmPackages:
vite: workspace:* => 2.9.0-beta.4
Used Package Manager
pnpm
Logs
No response
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.
- Make sure this is a Vite issue and not a framework-specific issue. For example, if it’s a Vue SFC related bug, it should likely be reported to https://github.com/vuejs/core instead.
- 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.
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (6 by maintainers)
Top Results From Across the Web
Force a program to run *without* administrator privileges or ...
Disable UAC on Windows 7: Start, type "user". Click on "User Account Control Settings". Drag the choice bar all the way to the...
Read more >running tests requires admin privileges? - MSDN - Microsoft
I'm running from the IDE. I would expect a TestResults folder under my solution folder. However, my solution is certainly not under "Program ......
Read more >Checking if app can run without admin rights? - Stack Overflow
Create a test account that has the permissions as the domain users of your application Login in as this user on a non-development...
Read more >How to Run Program without Admin Privileges and to Bypass ...
An app may need the administrator privileges to modify some files (logs, configs, etc.) in its own folder in the C:\Program Files (x86)\SomeApp....
Read more >Allow a Standard User Run Programs With Admin Rights
In today's video, I will show you how you can allow a standard user with no administrator privileges to run a program or...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I think it is not fixable. But it maybe helpful for windows users to mention about this in the document.
It seems if you turn on developer mode, it allows you to create symlinks without being an admin. It worked for me too. (I was always running scripts in admin among this situation…)
@sapphi-red Thanks a lot for the pointer to the code! It was surprisingly easy with your help.