Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: use Vitest public API instead of Vitest CLI #253

Merged
merged 64 commits into from
Mar 15, 2024
Merged
Show file tree
Hide file tree
Changes from 43 commits
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
6a0219f
feat: use Vitest public API to work with tests
sheremet-va Feb 19, 2024
373c67a
chore: cleanup
sheremet-va Feb 19, 2024
5fec34c
chore: cleanup
sheremet-va Feb 19, 2024
d4ce3cb
chore: improve API
sheremet-va Feb 19, 2024
744c99a
chore: cleanup
sheremet-va Feb 19, 2024
68b80db
chore: cleanup
sheremet-va Feb 19, 2024
600453b
chore: cleanup
sheremet-va Feb 19, 2024
fc03c30
chore: cleanup
sheremet-va Feb 19, 2024
c1f7fba
chore: correctly run tests with testNamePattern
sheremet-va Feb 20, 2024
50848cb
chore: partly support continues mode
sheremet-va Feb 20, 2024
ae8fbdf
feat: support continues run
sheremet-va Feb 20, 2024
3706256
chore: cleanup
sheremet-va Feb 20, 2024
f3493d3
chore: cleanup
sheremet-va Feb 20, 2024
2691c1d
fix: correctly run "all tests"
sheremet-va Feb 22, 2024
80c606f
chore: debug api
sheremet-va Feb 23, 2024
aba61d0
chore: cleanup
sheremet-va Feb 26, 2024
70e5b04
chore: use asVitestArgs
sheremet-va Feb 26, 2024
24b0206
chore: reuse worker process for debugger
sheremet-va Mar 3, 2024
e422809
chore: remove cac an types fro ipc
sheremet-va Mar 3, 2024
1ac4e88
chore: remove runhandler
sheremet-va Mar 3, 2024
05dd237
chore: use a single worker file for several folders
sheremet-va Mar 4, 2024
9539c3f
chore: cleanup
sheremet-va Mar 4, 2024
c2faa71
chore: fix runner
sheremet-va Mar 4, 2024
cbe94cb
chore: cleanup
sheremet-va Mar 4, 2024
2029ac3
chore: support debug
sheremet-va Mar 4, 2024
a610fdb
chore: support each, use dynamic port
sheremet-va Mar 4, 2024
c35e09b
chore: initiate Vitest as soon as possible
sheremet-va Mar 5, 2024
76009ea
feat: use Vitest API to collect tests
sheremet-va Mar 5, 2024
6364a3c
chore: cleanup
sheremet-va Mar 5, 2024
2f6f996
chore: logs and stop debugger
sheremet-va Mar 5, 2024
bb397d3
chore: fix loader flicker
sheremet-va Mar 5, 2024
dbbd031
feat: support windows
sheremet-va Mar 7, 2024
c9285d7
chore: remove unused
sheremet-va Mar 6, 2024
ed3158a
chore: remove unused from the config
sheremet-va Mar 6, 2024
b62c059
chore: update
sheremet-va Mar 8, 2024
6d1a72f
chore: cleanup
sheremet-va Mar 12, 2024
4d315a8
chore: experimenal yarn pnp support
sheremet-va Mar 12, 2024
ae58ffc
chore: refactor err
sheremet-va Mar 12, 2024
fae5a0e
chore: cleanup
sheremet-va Mar 12, 2024
89527de
chore: update test
sheremet-va Mar 12, 2024
454e584
chore: remove unused tests
sheremet-va Mar 12, 2024
210f61b
chore: never start an actual Vite server
sheremet-va Mar 12, 2024
000f61b
chore: cleanup
sheremet-va Mar 12, 2024
17bbdbb
chore: fix rerunning collection
sheremet-va Mar 12, 2024
1140cfc
refactor: cleanup
sheremet-va Mar 13, 2024
048acf1
chore: move methods to tree
sheremet-va Mar 13, 2024
5a7d064
refactor: cleanup
sheremet-va Mar 13, 2024
71350b4
chore: find vitest by configs
sheremet-va Mar 13, 2024
83319db
refactor: make run profile workspace specific
sheremet-va Mar 13, 2024
68e191f
chore: snapshot
sheremet-va Mar 13, 2024
075c71a
fix: don't reset test item statuses
sheremet-va Mar 13, 2024
80b3416
fix: allow running tests after the config was changed
sheremet-va Mar 13, 2024
7baa08b
chore: show error if workspace failed to initialise
sheremet-va Mar 13, 2024
1ddfc97
chore: cleanup
sheremet-va Mar 13, 2024
9544e75
fix: sort test items by position
sheremet-va Mar 13, 2024
a4b92cd
chore: store different requests
sheremet-va Mar 13, 2024
8413620
fix: gracefully exit the extension
sheremet-va Mar 14, 2024
a2933a2
refactor: run tests one after another if debugger is enabled
sheremet-va Mar 14, 2024
4f4a204
chore: end test runS
sheremet-va Mar 14, 2024
c35d429
test: add in-source example
sheremet-va Mar 15, 2024
4554fe5
chore: add warnings
sheremet-va Mar 15, 2024
aa9dd0c
fix: support test positions
sheremet-va Mar 15, 2024
bc5554e
chore: update test
sheremet-va Mar 15, 2024
f384aed
Merge branch 'main' into feat/dynamic-worker-vitest
sheremet-va Mar 15, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@ node_modules
.DS_Store
.eslintcache
test-results
.yarn
.pnp.*
10 changes: 10 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,16 @@
],
"outFiles": ["${workspaceFolder}/dist/**/*.js"]
},
{
"name": "Run Extension Yarn PnP Sample",
"type": "extensionHost",
"request": "launch",
"args": [
"--extensionDevelopmentPath=${workspaceFolder}",
"${workspaceFolder}/../vscode-vitest-pnp"
],
"outFiles": ["${workspaceFolder}/dist/**/*.js"]
},
{
"name": "Run Extension Multi-Root Workspace Sample",
"type": "extensionHost",
Expand Down
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,23 @@

- **Run**, **debug**, and **watch** Vitest tests in Visual Studio Code.
- NX support (see the [NX sample](./samples/monorepo-nx/)).
- A `@open` tag can be used when filtering tests, to only show the tests open in the editor.
- An `@open` tag can be used when filtering tests, to only show the tests open in the editor.

## Requirements

- Visual Studio Code version >= July 2021 (version 1.59).
- Vitest version >= v0.12.0

# Introduction

You can identify if your config is loaded by the extension with `process.env.VITEST_VSCODE` and change the configuration accordingly.

## Configuration

- `vitest.enable`: Extension will automatically detect if the current project is using Vitest. If detection fails, extension can be manually enabled via this option.
- `vitest.watchOnStartup`: Whether to activate Watch mode by default when the extension starts.
- `vitest.packagePath`: The path to a custom Vitest's `package.json` file. It will be used to resolve Vitest API paths.
sheremet-va marked this conversation as resolved.
Show resolved Hide resolved
- `vitest.nodeExecutable`: This extension spawns another process and will use this value as `execPath` argument.
- `vitest.nodeEnv`: Environment passed to the runner process in addition to
`process.env`
- `vitest.commandLine`: Command to execute Vitest tests. **It should have the ability
to append extra arguments**. For example
`npx vitest` or `yarn test --`. This is a workspace setting. Do not change it in
the user settings, since it will affect all the projects you open)
- `vitest.debugExclude`: Excludes files matching specified glob patterns from debugging. Default:
`[\"<node_internals>/**\", \"**/node_modules/**\"]`

Expand Down
44 changes: 10 additions & 34 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,23 +63,15 @@
"configuration": {
"title": "Vitest",
"properties": {
"vitest.enable": {
"description": "This plugin will try to detect whether the current project is set up with Vitest to activate itself. When it failed, you can enable the plugin manually.",
"type": "boolean",
"scope": "resource",
"default": false
},
"vitest.watchOnStartup": {
"description": "Start watching tests on startup",
"type": "boolean",
"scope": "resource",
"default": false
"vitest.packagePath": {
"description": "The path to the Vitest `package.json` file.",
"type": "string",
"scope": "resource"
},
"vitest.commandLine": {
"markdownDescription": "The command line to start vitest tests. **It should have with the ability to append extra arguments**. For example `npx vitest` or `yarn test --`\n\nThis is a workspace setting. Do not change it in the user setting directly, which will affect all the projects you open",
"vitest.nodeExecutable": {
"description": "The path to the Node.js executable. If not assigned, uses VSCode's Node.js instance.",
"type": "string",
"scope": "resource",
"default": ""
"scope": "window"
},
"vitest.debugExclude": {
"markdownDescription": "Automatically skip files covered by these glob patterns. \nDefault: `[\"<node_internals>/**\", \"**/node_modules/**\"]`",
Expand All @@ -98,24 +90,6 @@
],
"default": null,
"scope": "resource"
},
"vitest.showFailMessages": {
"description": "Get instant feedback when using Watch Mode. Pop-ups an error when a test fails.",
"type": "boolean",
"scope": "window",
"default": false
},
"vitest.changeBackgroundColor": {
"description": "Change background color of status bar item on failing tests.",
"type": "boolean",
"scope": "window",
"default": true
},
"vitest.disabledWorkspaceFolders": {
"description": "Disabled workspace folders names in multiroot environment",
"type": "array",
"scope": "resource",
"default": []
}
}
}
Expand All @@ -124,6 +98,7 @@
"vscode:prepublish": "pnpm compile",
"release": "bumpp package.json --commit --push --tag && git update-ref refs/heads/release refs/heads/main && git push origin release",
"compile": "tsup --minify",
"package": "vsce package --no-dependencies",
"watch": "tsup --watch --sourcemap",
"test": "vscode-test",
"test:watch": "vscode-test --watch-files src/**/*.ts --watch-files test/**/*.test.ts",
Expand All @@ -145,11 +120,12 @@
"@types/semver": "^7.3.9",
"@types/vscode": "^1.77.0",
"@types/ws": "^8.5.10",
"@vitest/utils": "^1.3.0",
"@vitest/ws-client": "^1.3.0",
"@vscode/test-cli": "^0.0.6",
"@vscode/test-electron": "^2.3.9",
"@vue/reactivity": "^3.2.33",
"birpc": "^0.2.15",
"birpc": "^0.2.17",
"bumpp": "^9.3.0",
"chai": "^5.1.0",
"changelogithub": "^0.13.3",
Expand Down
24 changes: 16 additions & 8 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions samples/basic/test/deep/deeper/deep.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { expect, it } from 'vitest'

it('test', () => {
expect(1).toBe(1)
})
61 changes: 0 additions & 61 deletions src/StatusBarItem.ts

This file was deleted.

Loading
Loading