Giter Site home page Giter Site logo

vscode's People

Contributors

c00 avatar esurnir avatar evanandrewrose avatar falynx avatar ffmathy avatar georgemickleburgh avatar hi-ogawa avatar huwshimi avatar igx89 avatar infinitexyy avatar joaovictor6 avatar john-griffin avatar keroxp avatar kitwon avatar lbm98 avatar mash-graz avatar milankovacic avatar ngirardin avatar remcohaszing avatar rentalhost avatar robertrosman avatar saitonakamura avatar seboran avatar sheremet-va avatar timoweave avatar tocseoj avatar tri-star avatar xon52 avatar ypetremann avatar zxch3n avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

vscode's Issues

Failing test highlight is on wrong line

Describe the bug
When running tests using the test runner the red bar highlighting the test title is 6 lines too high

To Reproduce
write tests - run tests using VSCode / extensions test runner - have one test fail

  1. See error

Expected behavior
the red bar to highlight the failing tests description

Screenshots
If applicable, add screenshots to help explain your problem.

Screenshot 2022-06-08 at 18 12 29

p.s this screetshot comes midway through a little refactor - don't mind the tests that don't make sense 😅

Environment

(Paste info.txt content generated by the example project)

  • OS: macOS
  • VSCode version: 1.67.2
  • Vitest version: ^0.14.1
  • Vitest plugin version: v0.2.12

Additional context

  • typescript
  • is testing a utility function for a svelte app

Windows Run Tests still failing

Unfortunately I still have a windows bug where tests are instantly failing.
The output file does not exist in this case so I will investigate some more:
image

When I pull this extension and use locally, I can successfully Run Tests with expected results which makes this a lot harder to debug:
image

Not working on macOS

Describe the bug
Maybe I didn't use the addon in the correct way? But simply put, the addon is not working at all. After installing it, I saw the testing tab, I saw the little error beside the test, but no matter where I click, the test is not running.

To Reproduce

  1. Git clone this repository: https://github.com/zxch3n/vitest-ext-basic-example
  2. Run node setup.mjs.
  3. Open it with VSCode.
  4. Click on the arrow beside the test to start testing. Nothing happens.

Expected behavior
It should start testing.

Screenshots
image

Environment

{
  "System": {
    "OS": "macOS 12.4"
  },
  "Binaries": {
    "Node": {
      "version": "18.2.0",
      "path": "~/.nvm/versions/node/v18.2.0/bin/node"
    },
    "Yarn": {
      "version": "1.22.18",
      "path": "/usr/local/bin/yarn"
    },
    "npm": {
      "version": "8.9.0",
      "path": "~/.nvm/versions/node/v18.2.0/bin/npm"
    }
  },
  "IDEs": {
    "VSCode": {
      "version": "1.67.2",
      "path": "/usr/local/bin/code"
    }
  },
  "npmPackages": {
    "vite": {
      "installed": "2.9.9",
      "wanted": "^2.9.9"
    },
    "vitest": {
      "installed": "0.12.10",
      "wanted": "^0.12.6"
    }
  }
}

Tests not runnable on Linux

Describe the bug
While the extension will install, it does not activate automatically. Forcing it to turn on in the settings does not resolve it.

To Reproduce
Steps to reproduce the behavior:

  1. Install the extension
  2. Go to the "Testing" panel - note there are no controls to run tests (not enabled)
  3. Go to the extensions settings page, check the first checkbox to force enable it.
  4. Observe the green triangles appear, but they do not execute any tests.

Expected behavior
The extension should auto-detect vitest and enable itself. Clicking the green triangles should run tests.

Screenshots
image

Environment

  • OS: Linux Mint 19.3 (Ubuntu-based)
  • VSCode version: 1.67.1
  • Vitest version: 0.10.1
  • Vitest plugin version: 0.1.27

Additional context
Following up on thread started on Discord. Tried one or two attempted fixes published but the issue remains.
Tried building/testing this repo itself and the same error occurs.

Unable to install vitest-ext-basic-example on Ubuntu 20.04/WSL2/Node v18.5.0

Describe the bug
Running node setup.mjs as described in https://github.com/zxch3n/vitest-ext-basic-example fails with error message:
`/bin/sh: 1: /mnt/c/Users/niels/AppData/Local/Programs/Microsoft: not found
node:internal/process/promises:288
triggerUncaughtException(err, true /* fromPromise */);
^

[UnhandledPromiseRejection: This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). The promise rejected with the reason "undefined".] {
code: 'ERR_UNHANDLED_REJECTION'
}`

To Reproduce

  1. Run npm install yarn -g
  2. Follow instructions in https://github.com/zxch3n/vitest-ext-basic-example
  3. Step 2 in step 2 above will fail

Expected behavior
Installation will work as described in https://github.com/zxch3n/vitest-ext-basic-example

Screenshots
image

Environment
Host Name: DESKTOP-XXXXXX
OS Name: Microsoft Windows 11 Pro
OS Version: 10.0.22000 N/A Build 22000
OS Manufacturer: Microsoft Corporation
OS Configuration: Standalone Workstation
OS Build Type: Multiprocessor Free
Registered Owner: [email protected]
Registered Organization: N/A
Product ID: 00330-80000-00000-AA030
Original Install Date: 3/26/2022, 4:21:27 PM
System Boot Time: 7/14/2022, 2:51:17 AM
System Manufacturer: Dell Inc.
System Model: XPS 15 9570
System Type: x64-based PC
Processor(s): 1 Processor(s) Installed.
[01]: Intel64 Family 6 Model 158 Stepping 10 GenuineIntel ~2208 Mhz
BIOS Version: Dell Inc. 1.24.0, 3/21/2022
Windows Directory: C:\WINDOWS
System Directory: C:\WINDOWS\system32
Boot Device: \Device\HarddiskVolume1
System Locale: en-us;English (United States)
Input Locale: en-us;English (United States)
Time Zone: (UTC-08:00) Pacific Time (US & Canada)
Total Physical Memory: 32,502 MB
Available Physical Memory: 8,882 MB
Virtual Memory: Max Size: 52,982 MB
Virtual Memory: Available: 11,552 MB
Virtual Memory: In Use: 41,430 MB
Page File Location(s): C:\pagefile.sys
Domain: WORKGROUP
Logon Server: \DESKTOP-XXXXXX
Hotfix(s): 4 Hotfix(s) Installed.
[01]: KB5013889
[02]: KB5007575
[03]: KB5015814
[04]: KB5016353
Network Card(s): 3 NIC(s) Installed.
[01]: DisplayLink Network Adapter NCM
Connection Name: Ethernet
DHCP Enabled: Yes
DHCP Server: 10.0.0.1
IP address(es)
[01]: 10.0.0.239
[02]: fe80::8199:a49a:663a:8413
[02]: Killer Wireless-n/a/ac 1535 Wireless Network Adapter
Connection Name: Wi-Fi
Status: Media disconnected
[03]: Bluetooth Device (Personal Area Network)
Connection Name: Bluetooth Network Connection
Status: Media disconnected

WSL: Linux DESKTOP-XXXXXXX 5.10.102.1-microsoft-standard-WSL2 #1 SMP Wed Mar 2 00:30:59 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux

vitest/0.18.1 linux-x64 node-v18.5.0

Support monorepo

Great extension! Is it possible to support a monorepo without vitest.config.ts in the root folder?
Thanks!

vitest doc section for VS Code

Hi VS Code PM here 👋

We are currently in the process of making the testing story more discoverable in vscode.
As part of that we are writing docs for the VS Code testing framework, and we really like your testing extension and we want to have a section on it.

This is the draft PR microsoft/vscode-docs#5332
Do you have some good docs to point us to that we could reuse? Or would you like to contribute to our PR directly?

Thanks

Run tests on save

Hi,

is there an option to run all test from the file by save automatic like in the jest runner?

Test file cannot be found if the test file or the directory contains uppercase characters.

Describe the bug
Test file cannot be found if the test file or the directory contains uppercase characters.

For example,
If the test file located in Category directory, such as /app/src/components/Category/CategoryContainer.test.js, the test file cannot be found.

To Reproduce
Click the test button if the test file or the directory contains uppercase characters.

Screenshots
test file and directory setup
image

example test
image

Run the test and Test file can not be found and it create a new file located as /app/src/components/category/categorycontainer.test.js instead.
image

Expected behavior
Test file can be found and run the test.

Environment

  • OS: Windows 10 running in DevContainer
  • VSCode version: 1.69.0
  • Vitest version: 0.18.0
  • Vitest plugin version: v0.2.20

Cannot get vitest version

Describe the bug
Vscode say "cannot get vitest version"

log:

[INFO 11:09:51 AM] Error: Cannot get vitest version from "{"cmd":"/Users/orange/ShuDongProjects/aina/community-ui-pc/node_modules/.bin/vitest","args":[]}"
[INFO 11:09:51 AM] process.env.PATH = /usr/bin:/bin:/usr/sbin:/sbin
[INFO 11:09:51 AM] vitest.nodeEnv = null
[INFO 11:09:51 AM] Vitest Workspace [community-ui-pc]: Vitest version = undefined

Environment

(Paste info.txt content generated by the example project)

{
  "System": {
    "OS": "macOS 12.4"
  },
  "Binaries": {
    "Node": {
      "version": "16.15.0",
      "path": "~/.nvm/versions/node/v16.15.0/bin/node"
    },
    "Yarn": {
      "version": "1.22.5",
      "path": "~/.yarn/bin/yarn"
    },
    "npm": {
      "version": "8.5.5",
      "path": "~/.nvm/versions/node/v16.15.0/bin/npm"
    }
  },
  "IDEs": {
    "VSCode": {
      "version": "1.69.1",
      "path": "/usr/local/bin/code"
    }
  },
  "npmPackages": {
    "vite": {
      "installed": "2.9.14",
      "wanted": "^2.9.9"
    },
    "vitest": {
      "installed": "0.12.10",
      "wanted": "^0.12.6"
    }
  }
}

Debug specific test filter not applied on Windows

Describe the bug
When trying to debug a specific test block, the debug process just runs all tests in the file on Windows with Yarn.

To Reproduce
Steps to reproduce the behavior on the example project:

  1. yarn install
  2. Add a second test block
import { describe, it, expect} from 'vitest';

describe('add', () => {
  it ('1 + 1', () => {
    expect(1 + 1).toBe(2);
  })

  it ('2 + 2', () => {
    expect(2 + 2).toBe(4);
  })
})
  1. Add a breakpoint on line 5, inside the "1 + 1" test
  2. Open the Vitest sidebar and select "Debug test" on "2 + 2"
  3. The breakpoint is hit, indicating "1 + 1" is being run

Expected behavior
When debugging a specific test, I expect to only run that test

Screenshots
If applicable, add screenshots to help explain your problem.
image
Shown above: "2 + 2" is being debugged, but the debugger has broken inside "1 + 1"

The full output for the debug test run:

"C:\Program Files\nodejs\node.exe" .\node_modules\vitest\vitest.mjs test D:/vitest-ext-basic-example/add.test.ts -t ""add 2 + 2"" --api 52918
 DEV  v0.12.10 d:/vitest-ext-basic-example
node_modules/vitest/dist/chunk-vite-node-externalize.464ab3dd.js:10480
      API started at http://localhost:52918
node_modules/vitest/dist/chunk-vite-node-externalize.464ab3dd.js:10480
Could not read source map for file:///d:/vitest-ext-basic-example/@vite/env: ENOENT: no such file or directory, open 'd:\vitest-ext-basic-example\@vite\env.mjs.map'

Environment

(Paste info.txt content generated by the example project)

  • OS: [e.g. macOS] Windows 11
  • VSCode version: 1.69.2
  • Vitest version: 0.12.10
  • Vitest plugin version: v0.2.23 (prerelease)

(filled manually, the setup script does not work on Windows either)

Vitest settings updated
'C:\Users\a-typ\AppData\Local\Programs\Microsoft' is not recognized as an internal or external command,
operable program or batch file.
node:internal/process/promises:246
          triggerUncaughtException(err, true /* fromPromise */);
          ^

[UnhandledPromiseRejection: This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). The promise rejected with the reason "undefined".] {
  code: 'ERR_UNHANDLED_REJECTION'
}

[Monorepo only error] document is not defined

Describe the bug
The test shows error document is not defined in monorepo only

To Reproduce

I have a monorepo and have a unit test that test a vue component with @vueuse/core. So the document is used inside the component.

reproduce repo https://github.com/hunterliu1003/vitest-vscode-poc

  1. The issue only occur when I open vscode with the root workspace
code vitest-vscode-poc

vitest plugin show error document is not defined
image

  1. However, if I open vscode the the packages/lib directly
code vitest-vscode-poc/packages/lib

vitest plugin run test correctly
image

  1. Run test command is also pass
git clone [email protected]:hunterliu1003/vitest-vscode-poc.git
pnpm i
pnpm test

image

Expected behavior
The vitest vscode plugin should support monorepo, or I miss some configuration thanks.

Testing tab does not show after installation

Describe the bug
The 'Testing' tab, as shown in the extension screenshots, does not show after installation. Whether manually Enabled or not.

To Reproduce

  1. Install Vitest extension

Expected behavior
'Testing' tab available like shown in screenshots.

Screenshots
Screen Shot 2022-05-25 at 11 30 17 PM

Environment

  • OS: macOS Monterey (12.0.1)
  • VSCode version: 1.67.2 (May 2022)
  • Vitest version: 0.12.9
  • Vitest plugin version: 0.2.11 (Pre-release)

Could not start debug with pnpm project.

Describe the bug
Could not start debug with pnpm project than do not has direct vite dependency, and "vitest.commandLine" could not be applied to debug.

To Reproduce
Steps to reproduce the behavior on the example project:

  1. Edit 'package.json' and remove vite.
  2. Install pnpm globally
  3. change package manager to 'pnpm' in setup.mjs. (do not use npm install or yarn before,if so,remove node_modules).
  4. Start a debug with the extension.
  5. The debug session closed with error: "cannot find module 'vite'"

Expected behavior
Successfully run the debug.

Additional context
I tried to use different methods to start vitest in terminal,all the flollwing commands are run successfully.

pnpx vitest
npx vitest
./node_modules/.bin/vitest

but the following command could not run with pnpm:

node ./node_modules/vitest/vitest.mjs

with the same error mentioned previously.

also, I've edited "vitest.commandLine" to different values and it seems have no impact on debug.

Running and watch has no issues.

Possibly a minor change here?

program: getVitestPath(workspaceFolder.uri.fsPath),

Environment
{
"System": {
"OS": "macOS 12.5"
},
"Binaries": {
"Node": {
"version": "14.16.0",
"path": "/.nvm/versions/node/v14.16.0/bin/node"
},
"Yarn": {
"version": "1.22.19",
"path": "
/.nvm/versions/node/v14.16.0/bin/yarn"
},
"npm": {
"version": "6.14.11",
"path": "~/.nvm/versions/node/v14.16.0/bin/npm"
}
},
"IDEs": {
"VSCode": {
"version": "1.69.2",
"path": "/usr/local/bin/code"
}
},
"npmPackages": {
"vite": {
"installed": "2.9.14",
"wanted": "^2.9.9"
},
"vitest": {
"installed": "0.12.10",
"wanted": "^0.12.6"
}
}
}

The `brace-expansion` dependency is missing in 0.1.14

The brace-expansion dependency appears to be missing in 0.1.14

Here is a require stack

[2022-03-30 18:08:37.894] [exthost] [error] Activating extension ZixuanChen.vitest-explorer failed due to an error:
[2022-03-30 18:08:37.894] [exthost] [error] Error: Cannot find module 'brace-expansion'
Require stack:
- /Users/me/.vscode/extensions/zixuanchen.vitest-explorer-0.1.14/node_modules/minimatch/minimatch.js
- /Users/me/.vscode/extensions/zixuanchen.vitest-explorer-0.1.14/out/vscodeUtils.js
- /Users/me/.vscode/extensions/zixuanchen.vitest-explorer-0.1.14/out/TestData.js
- /Users/me/.vscode/extensions/zixuanchen.vitest-explorer-0.1.14/out/discover.js
- /Users/me/.vscode/extensions/zixuanchen.vitest-explorer-0.1.14/out/extension.js
- /Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/loader.js

Originally posted by @calebboyd in #11 (comment)

Support yarn pnp vitest installs

The resolution of the vitest version is dependent on the node_modules folder. However, with Yarn pnp installs, there is no node_modules and so the detection of the vitest version fails with Cannot get vitest version from "undefined".

It would be great to have this detection algorithm take Yarn pnp installs into account. There are two ways I could see this happening.

  1. Look for the pnp package itself, which in my case is (relative to the folder root): .yarn/cache/vitest-npm-0.18.0-a8155f7bdc-20e76b0de9.zip
  2. Look for the entry in the .pnp.cjs file, which in my case is in the folder root (pretty sure that's always the case?)
...
    ["vitest", [\
      ["npm:0.18.0", {\
        "packageLocation": "./.yarn/cache/vitest-npm-0.18.0-a8155f7bdc-20e76b0de9.zip/node_modules/vitest/",\
        "packageDependencies": [\
          ["vitest", "npm:0.18.0"]\
        ],\
        "linkType": "SOFT"\
      }],\
...

I'd be glad to look into this more and see if I can get a PR working, but it would have to be at a later date since I'm well past the Ballmer Peak tonight.

"Test result not found" for all tests

I have the same problem as in this already closed issue #8 tests are working fine on the terminal (separate or VSCode integrated) but the tests are all failing in the extension:

image

From testing around I found that without any configuration, the result is this

 RUN  v0.14.1 E:/repos/project


⎯⎯⎯⎯⎯⎯ Failed Suites 1 ⎯⎯⎯⎯⎯⎯⎯

 FAIL  test/code.test.ts [ test/code.test.ts ]
Error: No test suite found in file E:/repos/project/test/code.test.ts
⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[1/1]⎯

Test Files  1 failed (1)
     Tests  no tests
      Time  1.84s (in thread 0ms, Infinity%)

And with "vitest.commandLine": "yarn test", it actually runs the test, but still displays everything as failed (probably because of the bottom part):

 RUN  v0.14.1 E:/repos/project


⎯⎯⎯⎯⎯⎯ Failed Suites 1 ⎯⎯⎯⎯⎯⎯⎯

 FAIL  test/code.test.ts [ test/code.test.ts ]
TypeError: params.map is not a function
...

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[1/1]⎯

Test Files  1 failed (1)
     Tests  no tests
      Time  1.70s (in thread 0ms, Infinity%)

JSON report written to C:/Users/xxx/AppData/Local/Temp/vitest-report-2v2t12.json
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Cannot find test file:///e%3A/repos/project/test/code.test.ts/function01 given no parameters should be defined@2Cannot find test file:///e%3A/repos/project/test/code.test.ts/function01 given no parameters should instantiate@3Cannot find test file:///e%3A/repos/project/test/code.test.ts/function01 given parameters should be defined@5Cannot find test file:///e%3A/repos/project/test/code.test.ts/function01 given parameters should work with parameters@6Cannot find test file:///e%3A/repos/project/test/code.test.ts/function02 should be defined@9Cannot find test file:///e%3A/repos/project/test/code.test.ts/function03 should be defined@11

System

  • Windows 11 21H2
  • VSCode 1.67.2
  • Extension v0.2.12
  • TypeScript 4.7.3

vite.config.js

import { defineConfig } from 'vite'

export default defineConfig({})

There is also an issue in the vitest repo:
vitest-dev/vitest#1407

Make it official

Thank you @zxch3n and contributors making and maintaining this extension. After the discussion with the team, we are happy to make this extension our official one and maintain it in the org together.

@zxch3n I have sent you the invitation to join the team, if you'd like, you can transfer this repo into the org (ping me to set up the permissions if needed). And you can send PR to fulfill your info in our docs.

Cheers!

Cannot stop "watch"

Describe the bug
Title. I clicked "Run Tests (Watch Mode)" but I can't find any way to stop it. I had to restart vscode.

To Reproduce
Steps to reproduce the behavior on the example project:

  1. Start it
  2. Try to stop it

Update snapshots?

Loving this plugin, can't wait to see it evolve.

However, we constantly use snapshots and couldn't figure out how to "update" snapshots via the plugin.

This functionality is coming or does it exist already?

Test peeker shows escape characters instead of ANSI colors

Tests show ANSI escape characters instead of colors in vscode on Mac.

It doesn't show the actual colors. Instead the output looks like this:
Unable to find an element by: [data-testid="label-text"]

Ignored nodes: comments, <script />, <style />
�[36m�[39m
�[36m

�[39m
�[36m<div�[39m
�[33mclass�[39m=�[32m"userIconContainer"�[39m
�[33mdata-testid�[39m=�[32m"label-div"�[39m
�[33mstyle�[39m=�[32m"background-image: url(/src/assets/img/default-avatar.svg);"�[39m
�[36m/>�[39m
�[36m
�[39m
�[36m�[39m

image

  • OS: macOS 12.3.1
  • VSCode version: 1.67.1
  • Vitest version: 0.12.6
  • Vitest plugin version: v0.2.2

Support .skipIf().concurrent

Describe the bug

Tests that use Vitest's .skipIf (and I presume .runIf) show up failed because "Test result not found.".

To Reproduce

Try for example:

const isDev = true

describe.skipIf(isDev)("suite 1", () => {
  test("skipped if isDev", () => {
    expect(true).toBe(true)
  })
})

describe("suite 2", () => {
  test.skipIf(isDev)("also skipped if isDev", () => {
    expect(true).toBe(true)
  })
})

Expected behavior

Tests like this should not automatically err out.

Ideally they should be ignored or included depending on the result of the condition (perhaps assume that a missing test result means that it was skipped?) - or in the worst case perhaps just treat them like skipped tests?

Screenshots

Screen Shot 2022-05-19 at 19 17 29

Environment

  • OS: macOS
  • VSCode version: 1.67.2 (Universal)
  • Vitest version: 0.12.6
  • Vitest plugin version: v0.2.3

Activating extension on windows

[2022-03-29 10:29:43.348] [exthost] [error] Activating extension ZixuanChen.vitest-explorer failed due to an error:
[2022-03-29 10:29:43.348] [exthost] [error] Error: ENOENT: no such file or directory, open 'C:\c:\Users\andye\Development\notebunker\package.json'

When the extension tries to activate on windows, it ends up duplicating the C:\ drive identifier at the beginning of the path.

Add logging for child.stderr

Currently the extension is only logging child.stdout when running spawn. All error generated by the spawn command are ignored. Maybe it's good to add also logging for child.stderr

Extension is unable run test with same in same file scope with describe

The extension will fail with

Test result not found. 

Can you run vitest successfully on this file? Does it need custom option to run?

Does this file contain test case with the same name? 

if the following setup is present:

describe('example', () => {
    describe('scope 1', () => {
        test('potential same name', () => {
         ...
        });
    })
    describe('scope 2', () => {
        test('potential same name', () => {
         ...
        });
    })
})

It this a deliberate choice?

Nested package structure

Is your feature request related to a problem? Please describe.

When you have a nested pkg structure like root/frontend/... the extension still tries to find your package.json at root/package.json instead of root/frontend/package.json

Describe the solution you'd like
Make the root path customizable

Unable to run tests with v0.1.13

I reloaded my VSCode window and lost the ability to run tests. I only have a "Go to Test" icon in the left testing pane, and when I right-click the symbol next to the test, I get this menu:

Screen Sharing Picture March 30, 2022 at 11 24 32 CDT

I tried setting the command line to npx vitest in the extension settings, but that didn't help.

I noticed that you posted a new version yesterday, so that version may be the problem.

VSCode v1.65.2

the extension should not be activated if the project does not use `vitest`

Describe the bug
The extension gives me warnings when I open a project that has no tests.

To Reproduce

  1. Open a project that doesn't have vitest installed.
  2. Wait for the extension to load.
  3. It now should show a warning that an older vitest version is installed.

Expected behavior
The extension should not show anything if vitest is not installed in a project.

Screenshots

image

Environment

  • OS: Windows 11
  • VSCode version: 1.69.2
  • Vitest version: none
  • Vitest plugin version: 0.2.20

Debugging cannot find any test files

Describe the bug
When telling VSC to debug the tests (all of them, a single test, a single file, or a single describe), will result in nothing happening, apart from a log in the debug console saying no test files were found.

To Reproduce

  1. Go to the testing panel
  2. Click the "Debug Tests" button
  3. If its not open already, open the debug console

Expected behavior
The tests to run, using the debugger to stop at breakpoints and such

Screenshots

C:\Program Files\nodejs\node.exe .\node_modules\vitest\vitest.mjs vitest D:/projects/Kronos/tests/util/common.test.ts --api 65426
 DEV  v0.17.1 d:/projects/Kronos
      API started at http://localhost:65426
filter:  vitest, D:/projects/Kronos/tests/util/common.test.ts
include: **/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}
watch exclude:  **/node_modules/**, **/dist/**

No test files found, exiting with code 1
Process exited with code 1

Environment

  • OS: windows
  • VSCode version: 1.69.0
  • Vitest version: 0.17.1
  • Vitest plugin version: 0.2.20

Additional context

Using the launch.json config to run tests on the open tests file works as expected. I noticed there appears to be an extra vitest in the command its running in the debug console, which then appears in the filter list. I suspect this is the root of the issue - it's filtering for test files that include "vitest" in their name, which is none of them.

How to disable rerun on save?

It seems it automatically reruns the test file on file save even watch mode is off

To Reproduce
just save the test file

Expected behavior
Should not rerun on save because watch mode is off

Screenshots
image

Environment

(Paste info.txt content generated by the example project)

  • OS: macOS m1
  • VSCode version: 1.69.2
  • Vitest version: ^0.12.6
  • Vitest plugin version: v0.2.23

Test result not found error when running any test

Hi, I'm trying to get the extension to run on Windows and I seem to be getting the same "Test result not found" error when running any of the tests.

I did a debug run of a test to see what was running and the output was:

"E:\Program Files\nodejs\node.exe" .\node_modules\vitest\vitest.mjs run /Users/George/frontend-v8/src/composables/__tests__/auth.test.ts --testNamePattern "auth composable should start with a null current user and account" --reporter=default --reporter=json --outputFile C:\Users\George\AppData\Local\Temp\vitest-report-b18l2.json

 RUN  v0.8.0 c:/Users/George/frontend-v8

Could not read source map for file:///c:/Users/George/frontend-v8/@vite/env: ENOENT: no such file or directory, open 'c:\Users\George\frontend-v8\@vite\env.mjs.map'
⎯⎯⎯⎯⎯⎯ Failed Suites 1 ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯

 FAIL  src/composables/__tests__/auth.test.ts [ src/composables/__tests__/auth.test.ts ]

Error: No test suite found in file c:/Users/George/frontend-v8/src/composables/__tests__/auth.test.test

 ❯ runFiles node_modules/vitest/dist/entry.js:870:18
 ❯ startTests node_modules/vitest/dist/entry.js:880:9
 ❯ async node_modules/vitest/dist/entry.js:907:7
 ❯ async withEnv node_modules/vitest/dist/entry.js:504:5
 ❯ async run node_modules/vitest/dist/entry.js:906:5
⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[1/1]⎯

Test Files  1 failed (1)
     Tests  no tests
      Time  5.98s (in thread 0ms, Infinity%)
JSON report written to C:/Users/George/AppData/Local/Temp/vitest-report-b18l2.json
Process exited with code 1

If I run the exact same command within from the Terminal inside VSCode I get the expected result:

"E:\Program Files\nodejs\node.exe" .\node_modules\vitest\vitest.mjs run /Users/George/frontend-v8/src/composables/__tests__/auth.test.ts --testNamePattern "auth composable should start with a null current user and account" --reporter=default --reporter=json --outputFile C:\Users\George\AppData\Local\Temp\vitest-report-b18l2.json

 RUN  v0.8.0 C:/Users/George/frontend-v8

 √ src/composables/__tests__/auth.test.ts (5)

Test Files  1 passed (1)
     Tests  1 passed | 4 skipped (5)
      Time  2.90s (in thread 3ms, 114416.96%)

JSON report written to C:/Users/George/AppData/Local/Temp/vitest-report-b18l2.json

I'm not sure the if the source map error is relevant (seems to be missing the node_modules in the path), but it doesn't seem to be finding any tests. I get the same error for each test if I try and do the global run.

Feature request: rerun tests on save

Ideally this extension would have ability to rerun tests automatically when I save a spec file.
Currently I have to go and manually click or invoke a vscode command.

Change Icon

I would recommend changing to Icon to easily associate the extension with a Test Explorer Adapter.

I've created this Icon inspired by the other Adapters:
vitest-icon

[not support [email protected]] test successfully, but loading infinitely.

Describe the bug
A clear and concise description of what the bug is.
I installed vitest V0.18.0,and it doesn`t work.

To Reproduce
Steps to reproduce the behavior on the example project:

  1. npx degit SoonIter/sooniter-lib-template-monorepo my-lib-name
  2. run ni
  3. go to the "test" folder
  4. run this one is Ok,

image

but the extension works fail

image

Expected behavior
work well

Screenshots
image

Maybe the problem is to run-once or run-watch.
Version 0.2.20

Ignores tests with () or [] in name

I cannot run individual tests if their names contain something in brackets

describe('test', () => {
  it('case (e)', () => {
    assert.equal(1, 2)
  })
})

When I click run test it runs and I see next:

In test panel:
image

In file:
image

It doesn't work with squared brackets 'case [e]'
It works if I run describe
It works with curly brackets 'case {e}'
It works with empty brackets 'case ()'

Test file cannot be found if the directory contains uppercase characters.

Describe the bug
Test file cannot be found if the directory contains uppercase characters.

Related issue: #54 but it didn't fix if the directory contains uppercase characters.

For example,
If the test file located in Category directory, such as /app/src/components/Category/CategoryContainer.test.js, the test file cannot be found.

To Reproduce
Click the test button if the directory contains uppercase characters.

Screenshots
test file and directory setup
image

example test
image

Run the test and Test file can not be found and it create a new file located as /app/src/components/category/categorycontainer.test.js instead.
image

Expected behavior
Test file can be found and run the test.

Environment

  • OS: Windows 10 running in DevContainer
  • VSCode version: 1.69.0
  • Vitest version: 0.18.0
  • Vitest plugin version: v0.2.20

Show assertion/expect failures inline on the line that actually failed

Currently test results are shown for the entire test as a whole, which for tests that have several expects makes it hard to figure out what actually failed.

It would be better, IMO, to show the failure where it actually happened in the context of the source code, such as is done with Jest Test Explorer or the terminal runner for vitest - see screenshots.

Current output

Screen Shot 2022-05-20 at 09 51 55

Better - Vitest terminal output

Screen Shot 2022-05-20 at 09 49 38

Best - Jest explorer - inlined with source code

Screen Shot 2022-05-20 at 09 47 15

vitest.exclude not working

vitest.exclude not working, VSCode UI still show vitest exclude tests

image

I have settings.json

	////////// vitest //////////
	"vitest.include": ["**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx,svelte}"],
	"vitest.exclude": ["**/node_modules/**", "**/dist/**", "**/cypress/**", "**/.{idea,git,cache,output,temp}/**", "**/ignored.test.ts", "tests/**"],
import { sveltekit } from '@sveltejs/kit/vite';
import path from 'path';
import { configDefaults, defineConfig } from 'vitest/config';

/** @type {import('vite').UserConfig} */
export default defineConfig({
	define: {
		// Eliminate in-source test code
		'import.meta.vitest': 'undefined'
	},

	test: {
		// jest like globals
		globals: true,
		environment: 'jsdom',
		// in-source testing
		includeSource: ['src/**/*.{js,ts,svelte}'],
		exclude: [...configDefaults.exclude, 'tests'],
		// msw setup
		setupFiles: ['./src/mocks/setup.ts'],
		coverage: {
			exclude: ['src/mocks']
		},
		deps: {
			// Put Svelte component here, e.g., inline: [/svelte-multiselect/, /msw/]
			inline: [/msw/]
		}
	},

	resolve: {
		alias: {
			$stores: path.resolve('./src/lib/stores'),
			$blocks: path.resolve('./src/lib/blocks')
		}
	},
	envPrefix: ['VITE_', 'CONFY_'],

	plugins: [sveltekit()]
});

Feature Request: Allow configuration of `skipFiles`

There are times when there's an issue within a node_module package—or indeed we're trying to gain a better understanding of what a package is doing internally—where it would be useful to easily step through the code.

Unfortunately as skipFiles is hardcoded, it's impossible to enable this.

Would be great if we could override the default skipFiles setting.

Unexpected Token in JSON error when running tests

Describe the bug
@testing-library/react: 13.1.1
vitest: 0.12.9

When running any test from the plugin the run fails with "SyntaxError: Unexpected token in JSON at position 52".

From the output It appears that the plugin is trying to write invalid JSON to a file and then read it back

JSON report written to /var/folders/nh/f9txjbr50mg66b89_51z2d2w0000gn/T/vitest-report-eqem9.json
JUNIT report written to /var/folders/nh/f9txjbr50mg66b89_51z2d2w0000gn/T/vitest-report-eqem9.json
Done in 1.09s.
Run test failed 
SyntaxError: Unexpected token 
                               in JSON at position 52

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.