diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md deleted file mode 100644 index 994c0c84..00000000 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ /dev/null @@ -1,36 +0,0 @@ ---- -name: Bug report -about: Create a report to help us improve -title: "" -labels: bug -assignees: "" ---- - -**Describe the bug** -A clear and concise description of what the bug is. - -**To Reproduce** -Steps to reproduce the behavior on [the example project](https://github.com/zxch3n/vitest-ext-basic-example): - -1. Go to '...' -2. Click on '....' -3. Scroll down to '....' -4. See error - -**Expected behavior** -A clear and concise description of what you expected to happen. - -**Screenshots** -If applicable, add screenshots to help explain your problem. - -**Environment** - -(Paste info.txt content generated by [the example project](https://github.com/zxch3n/vitest-ext-basic-example)) - -- OS: [e.g. macOS] -- VSCode version: -- Vitest version: -- Vitest plugin version: - -**Additional context** -Add any other context about the problem here. diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml new file mode 100644 index 00000000..52b37dc1 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -0,0 +1,62 @@ +name: 🐞 Bug report +description: Report an issue with Vitest VSCode Extension +labels: [pending triage] +body: + - type: markdown + attributes: + value: | + Thanks for taking the time to fill out this bug report! + - type: textarea + id: bug-description + attributes: + label: Describe the bug + description: A clear and concise description of what the bug is. If you intend to submit a PR for this issue, tell us in the description. Thanks! + placeholder: Bug description + validations: + required: true + - type: textarea + id: reproduction + attributes: + label: Reproduction + description: Please provide a link to [StackBlitz](https://stackblitz.com/fork/github/vitest-dev/vitest/tree/main/examples/basic?initialPath=__vitest__/) (you can also use [examples](https://github.com/vitest-dev/vitest/tree/main/examples)) or a github repo that can reproduce the problem you ran into. A [minimal reproduction](https://stackoverflow.com/help/minimal-reproducible-example) is required unless you are absolutely sure that the issue is obvious and the provided information is enough to understand the problem. If a report is vague (e.g. just a generic error message) and has no reproduction, it will receive a "need reproduction" label. If no reproduction is provided after 3 days, it will be auto-closed. + placeholder: Reproduction + validations: + required: true + - type: textarea + id: system-info + attributes: + label: System Info + description: Output of `npx envinfo --system --npmPackages '{vitest,@vitest/*,vite,@vitejs/*}' --binaries --browsers --IDEs` + render: shell + placeholder: System, Binaries, IDEs, Browsers + validations: + required: true + - type: dropdown + id: package-manager + attributes: + label: Used Package Manager + description: Select the used package manager + options: + - npm + - yarn + - pnpm + validations: + required: true + - type: checkboxes + id: checkboxes + attributes: + label: Validations + description: Before submitting the issue, please make sure you do the following + options: + - label: Follow our [Code of Conduct](https://github.com/vitest-dev/vscode/blob/main/CODE_OF_CONDUCT.md) + required: true + - label: Read the [Contributing Guidelines](https://github.com/vitest-dev/vscode/blob/main/CONTRIBUTING.md). + required: true + - label: Read the [docs](https://vitest.dev/guide/). + required: true + - label: Check that there isn't [already an issue](https://github.com/vitest-dev/vscode/issues) that reports the same bug to avoid creating a duplicate. + required: true + - label: Check that this is a concrete bug. For Q&A open a [GitHub Discussion](https://github.com/vitest-dev/vscode/discussions) or join our [Discord Chat Server](https://chat.vitest.dev). + required: true + - label: The provided reproduction is a [minimal reproducible example](https://stackoverflow.com/help/minimal-reproducible-example) of the bug. + required: true diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml new file mode 100644 index 00000000..5beeabce --- /dev/null +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -0,0 +1,8 @@ +blank_issues_enabled: false +contact_links: + - name: Discord Chat + url: https://chat.vitest.dev + about: Ask questions and discuss with other Vitest users in real time. + - name: Questions & Discussions + url: https://github.com/vitest-dev/vscode/discussions + about: Use GitHub discussions for message-board style questions and discussions. diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md deleted file mode 100644 index 11fc491e..00000000 --- a/.github/ISSUE_TEMPLATE/feature_request.md +++ /dev/null @@ -1,20 +0,0 @@ ---- -name: Feature request -about: Suggest an idea for this project -title: '' -labels: enhancement -assignees: '' - ---- - -**Is your feature request related to a problem? Please describe.** -A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] - -**Describe the solution you'd like** -A clear and concise description of what you want to happen. - -**Describe alternatives you've considered** -A clear and concise description of any alternative solutions or features you've considered. - -**Additional context** -Add any other context or screenshots about the feature request here. diff --git a/.github/ISSUE_TEMPLATE/feature_request.yml b/.github/ISSUE_TEMPLATE/feature_request.yml new file mode 100644 index 00000000..2fb0f157 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.yml @@ -0,0 +1,46 @@ +name: 🚀 New feature proposal +description: Propose a new feature to be added to Vitest VSCode Extension +labels: ['enhancement: pending triage'] +body: + - type: markdown + attributes: + value: | + Thanks for your interest in the project and taking the time to fill out this feature report! + - type: textarea + id: feature-description + attributes: + label: Clear and concise description of the problem + description: 'As a developer using Vitest I want [goal / wish] so that [benefit]. If you intend to submit a PR for this issue, tell us in the description. Thanks!' + validations: + required: true + - type: textarea + id: suggested-solution + attributes: + label: Suggested solution + description: We could provide following implementation... + validations: + required: true + - type: textarea + id: alternative + attributes: + label: Alternative + description: Clear and concise description of any alternative solutions or features you've considered. + - type: textarea + id: additional-context + attributes: + label: Additional context + description: Any other context or screenshots about the feature request here. + - type: checkboxes + id: checkboxes + attributes: + label: Validations + description: Before submitting the issue, please make sure you do the following + options: + - label: Follow our [Code of Conduct](https://github.com/vitest-dev/vscode/blob/main/CODE_OF_CONDUCT.md) + required: true + - label: Read the [Contributing Guidelines](https://github.com/vitest-dev/vscode/blob/main/CONTRIBUTING.md). + required: true + - label: Read the [docs](https://vitest.dev/guide/). + required: true + - label: Check that there isn't already an issue that request the same feature to avoid creating a duplicate. + required: true diff --git a/.github/workflows/issue-close-require.yml b/.github/workflows/issue-close-require.yml new file mode 100644 index 00000000..66347d67 --- /dev/null +++ b/.github/workflows/issue-close-require.yml @@ -0,0 +1,17 @@ +name: Issue Close Require + +on: + schedule: + - cron: '0 0 * * *' + +jobs: + close-issues: + runs-on: ubuntu-latest + steps: + - name: needs reproduction + uses: actions-cool/issues-helper@v3 + with: + actions: close-issues + token: ${{ secrets.GITHUB_TOKEN }} + labels: needs reproduction + inactive-day: 3 diff --git a/.github/workflows/issue-labeled.yml b/.github/workflows/issue-labeled.yml new file mode 100644 index 00000000..97de158e --- /dev/null +++ b/.github/workflows/issue-labeled.yml @@ -0,0 +1,19 @@ +name: Issue Labeled + +on: + issues: + types: [labeled] + +jobs: + reply-labeled: + runs-on: ubuntu-latest + steps: + - name: needs reproduction + if: github.event.label.name == 'needs reproduction' + uses: actions-cool/issues-helper@v3 + with: + actions: create-comment + token: ${{ secrets.GITHUB_TOKEN }} + issue-number: ${{ github.event.issue.number }} + body: | + Hello @${{ github.event.issue.user.login }}. Please provide a [minimal reproduction](https://stackoverflow.com/help/minimal-reproducible-example) using a GitHub repository or [StackBlitz](https://vitest.new) (you can also use [examples](https://github.com/vitest-dev/vitest/tree/main/examples)). Issues marked with `needs reproduction` will be closed if they have no activity within 3 days. diff --git a/.github/workflows/lock-closed-issues.yml b/.github/workflows/lock-closed-issues.yml new file mode 100644 index 00000000..41f51ab5 --- /dev/null +++ b/.github/workflows/lock-closed-issues.yml @@ -0,0 +1,24 @@ +name: Lock Closed Issues + +on: + schedule: + - cron: '0 0 * * *' + +permissions: + issues: write + +jobs: + action: + if: github.repository == 'vitest-dev/vscode' + runs-on: ubuntu-latest + steps: + - uses: dessant/lock-threads@v5 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + issue-inactive-days: '14' + # issue-comment: | + # This issue has been locked since it has been closed for more than 14 days. + # + # If you have found a concrete bug or regression related to it, please open a new [bug report](https://github.com/vitejs/vite/issues/new/choose) with a reproduction against the latest Vite version. If you have any other comments you should join the chat at [Vite Land](https://chat.vitejs.dev) or create a new [discussion](https://github.com/vitejs/vite/discussions). + issue-lock-reason: '' + process-only: issues diff --git a/.vscode/settings.json b/.vscode/settings.json index efa8e5d3..5e1aadfa 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,17 +1,31 @@ // Place your settings in this file to overwrite default and user settings. { - "files.exclude": { - "out": false // set this to true to hide the "out" folder with the compiled JS files - }, - "search.exclude": { - "out": true // set this to false to include "out" folder in search results - }, + // Enable the ESlint flat config support + "eslint.experimental.useFlatConfig": true, + // Turn off tsc task auto detection since we have the necessary tasks as npm scripts "typescript.tsc.autoDetect": "off", - "[typescript]": { - "editor.defaultFormatter": "dbaeumer.vscode-eslint" - }, + // Disable the default formatter, use eslint instead + "prettier.enable": false, + "editor.formatOnSave": false, + + // Auto fix "editor.codeActionsOnSave": { + "source.fixAll.eslint": "explicit", "source.organizeImports": "never" - } + }, + + // Enable eslint for all supported languages + "eslint.validate": [ + "javascript", + "javascriptreact", + "typescript", + "typescriptreact", + "vue", + "html", + "markdown", + "json", + "jsonc", + "yaml" + ] } diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md new file mode 100644 index 00000000..8dc9c49b --- /dev/null +++ b/CODE_OF_CONDUCT.md @@ -0,0 +1,45 @@ +# Code Of Conduct + +## Our Pledge + +In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, political party, or sexual identity and orientation. Note, however, that religion, political party, or other ideological affiliation provide no exemptions for the behavior we outline as unacceptable in this Code of Conduct. + +## Our Standards + +Examples of behavior that contributes to creating a positive environment include: + +- Using welcoming and inclusive language +- Being respectful of differing viewpoints and experiences +- Gracefully accepting constructive criticism +- Focusing on what is best for the community +- Showing empathy towards other community members + +Examples of unacceptable behavior by participants include: + +- The use of sexualized language or imagery and unwelcome sexual attention or advances +- Trolling, insulting/derogatory comments, and personal or political attacks +- Public or private harassment +- Publishing others' private information, such as a physical or electronic address, without explicit permission +- Other conduct which could reasonably be considered inappropriate in a professional setting + +## Our Responsibilities + +Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior. + +Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful. + +## Scope + +This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers. + +## Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team by sending an e-mail to vitest.dev@gmail.com. All complaints will be reviewed and investigated and will result in a response that is deemed necessary and appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately. + +Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership. + +## Attribution + +This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html + +[homepage]: https://www.contributor-covenant.org diff --git a/README.md b/README.md index fed622b0..7fff75ee 100644 --- a/README.md +++ b/README.md @@ -1,74 +1,41 @@

-
- Vitest for VSCode Logo - + Vitest extension for Visual Studio Code logo

-

- Vitest for VSCode -

- -
+

Vitest extension for Visual Studio Code. Available on Visual Studio Marketplace.

![](https://i.ibb.co/bJCbCf2/202203292020.gif) -> This extension is powered by -> [vscode testing api](https://code.visualstudio.com/api/extension-guides/testing). +## Features -# Features - -- Run/debug vitest tests in vscode. +- **Run**, **debug**, and **watch** Vitest tests in Visual Studio Code. - NX support (see the [NX sample](./samples/monorepo-nx/)). -- Watch mode is supported 🎊. Test reruns are blazing fast. - A `@open` tag can be used when filtering tests, to only show the tests open in the editor. -![Watch Mode](https://i.ibb.co/YRhJj9f/Screen-Recording-2022-05-21-at-20-09-20.gif) - -# Requirements +## Requirements -- Require VSCode's version >= July 2021 (version 1.59). -- Require Vitest's version >= v0.12.0 +- Visual Studio Code version >= July 2021 (version 1.59). +- Vitest version >= v0.12.0 -# Config +## Configuration -- `vitest.enable`: This plugin will try to detect whether the current project is - set up with Vitest to activate itself. If detection fails, you can enable the plugin manually. -- `vitest.watchOnStartup`: Whether to activate Watch mode per default when the extension starts. -- `vitest.nodeEnv`: The env passed to runner process in addition to +- `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.nodeEnv`: Environment passed to the runner process in addition to `process.env` -- `vitest.commandLine`: The command line to start vitest tests. **It should have with the ability +- `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 setting directly, which will affect all the projects you open) -- `vitest.debugExclude`: Automatically skip files covered by these glob patterns. Default: + `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_modules/**\"]` -# Screenshots - -**Filter tests by status** - - - -**Debug** +## FAQs (Frequently Asked Questions) - - -**Inspect console output** - -![](https://i.ibb.co/gMZWXZQ/Screen-Recording-2022-03-29-at-20-59-31.gif) - -# FAQ - -#### **How can I use it in monorepo?** +### How can I use it in monorepo? See for monorepo support. -#### **How can I use this extension when tests are under a sub directory?** +### How can I use this extension when tests are under a sub directory? You can use VS Code command `add folder to workspace` to add the sub directory. The extension should work fine. - -#### **`test.each` is not working** - -Dynamic test name is not supported yet. This extension currently relies on the babel parser to calculate the positions of tests statically. - -Related issue: https://github.com/vitest-dev/vscode/issues/133 diff --git a/package.json b/package.json index d5a29140..a34050bc 100644 --- a/package.json +++ b/package.json @@ -123,8 +123,8 @@ "scripts": { "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 ./src/extension.ts --external vscode --minify", - "watch": "tsup ./src/extension.ts --external vscode --watch --sourcemap", + "compile": "tsup --minify", + "watch": "tsup --watch --sourcemap", "test": "vitest run --config vite.global-config.ts", "typecheck": "tsc --noEmit", "lint": "eslint --cache .", diff --git a/tsup.config.ts b/tsup.config.ts new file mode 100644 index 00000000..65065de3 --- /dev/null +++ b/tsup.config.ts @@ -0,0 +1,9 @@ +import { defineConfig } from 'tsup' + +export default defineConfig([ + { + entry: ['./src/extension.ts'], + external: ['vscode'], + format: 'cjs', + }, +])