question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Tests don't run on Windows without admin privileges

See original GitHub issue

Describe 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

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

3reactions
sapphi-redcommented, Mar 25, 2022

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…)

Now in Windows 10 Creators Update, a user (with admin rights) can first enable Developer Mode, and then any user on the machine can run the mklink command without elevating a command-line console. https://blogs.windows.com/windowsdeveloper/2016/12/02/symlinks-windows-10/

2reactions
j-maascommented, Mar 26, 2022

@sapphi-red Thanks a lot for the pointer to the code! It was surprisingly easy with your help.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found