Skip to content

feat: Add Vitest snippets #44

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

Merged
merged 4 commits into from
Jun 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
61 changes: 44 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,23 +59,23 @@ These snippets were made to speed up Vue 3 development. With it you can write bo

### Script

| Snippet | Purpose |
| ------------------------ | ------------------------------------------- |
| `vref` | Vue `ref` |
| `vreactive` | Vue `reactive` |
| `vcomputed` | Vue `computed` |
| `vwatch` | Watcher |
| `vwatcheffect` | Watch Effect |
| `vonmounted` | onMounted hook |
| `vonbeforemount` | onBeforeMount hook |
| `vonbeforeupdate` | onBeforeUpdate hook |
| `vonupdated` | onUpdated hook |
| `vonerrorcaptured` | onErrorCaptured hook |
| `vonunmounted` | onUnmounted hook |
| `vonbeforeunmount` | onBeforeUnmount hook |
| `vdefineprops` | Define props |
| `vdefineemits` | Define emits |
| `vsingleemit` | Single emit for defineEmits |
| Snippet | Purpose |
| ------------------ | --------------------------- |
| `vref` | Vue `ref` |
| `vreactive` | Vue `reactive` |
| `vcomputed` | Vue `computed` |
| `vwatch` | Watcher |
| `vwatcheffect` | Watch Effect |
| `vonmounted` | onMounted hook |
| `vonbeforemount` | onBeforeMount hook |
| `vonbeforeupdate` | onBeforeUpdate hook |
| `vonupdated` | onUpdated hook |
| `vonerrorcaptured` | onErrorCaptured hook |
| `vonunmounted` | onUnmounted hook |
| `vonbeforeunmount` | onBeforeUnmount hook |
| `vdefineprops` | Define props |
| `vdefineemits` | Define emits |
| `vsingleemit` | Single emit for defineEmits |

### CSS

Expand Down Expand Up @@ -151,6 +151,33 @@ These snippets were made to speed up Vue 3 development. With it you can write bo
| `hcontrols-text` | Histoire controls - Text |
| `hcontrols-textarea` | Histoire controls - Textarea |

### Vitest

| Snippet | Purpose |
| ------------------------- | ------------------------------ |
| `viconfig` | Vitest config for Vue 3 |
| `viconfig-nuxt` | Vitest config for Nuxt 3 |
| `videscribe` | Vitest Describe |
| `videscribe-concurrent` | Vitest Describe - Concurrent |
| `viit` | Vitest It |
| `viit-concurrent` | Vitest It - Concurrent |
| `viit-async` | Vitest It - Async |
| `viit-async-concurrent` | Vitest It - Async Concurrent |
| `viit-todo` | Vitest It - Todo |
| `vitest` | Vitest Test |
| `vitest-concurrent` | Vitest Test - Concurrent |
| `vitest-async` | Vitest Test - Async |
| `vitest-async-concurrent` | Vitest Test - Async Concurrent |
| `vitest-todo` | Vitest Test - Todo |
| `visnapshot` | Vitest Match Snapshot |
| `visnapshot-inline` | Vitest Match Snapshot - Inline |
| `vimount` | Vue Test Utils `mount` |
| `vicomponent` | Vue Test Utils Component |
| `vimount-suspended` | nuxt-vitest `mountSuspended` |
| `vimocknuxtimport` | nuxt-vitest `mockNuxtImport` |
| `vimockcomponent` | nuxt-vitest `mockComponent` |
| `viregisterendpoint` | nuxt-vitest `registerEndpoint` |

## Contributing

This is an open source project open to anyone. Contributors are welcome on [GitHub](https://github.com/exer7um/vue3-vscode-snippets).
Expand Down
24 changes: 24 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,30 @@
{
"language": "typescript",
"path": "./snippets/histoire/histoire-script.code-snippets"
},
{
"language": "javascript",
"path": "./snippets/vitest/vitest.code-snippets"
},
{
"language": "typescript",
"path": "./snippets/vitest/vitest.code-snippets"
},
{
"language": "javascript",
"path": "./snippets/vitest/vue.code-snippets"
},
{
"language": "typescript",
"path": "./snippets/vitest/vue.code-snippets"
},
{
"language": "javascript",
"path": "./snippets/vitest/nuxt.code-snippets"
},
{
"language": "typescript",
"path": "./snippets/vitest/nuxt.code-snippets"
}
]
}
Expand Down
49 changes: 49 additions & 0 deletions snippets/vitest/nuxt.code-snippets
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
{
"Vitest Config - Nuxt 3": {
"prefix": "viconfig-nuxt",
"body": [
"import { defineVitestConfig } from 'nuxt-vitest/config'",
"",
"export default defineVitestConfig({",
"\ttest: {",
"\t\tenvironment: 'nuxt'",
"\t}",
"})"
],
"description": "Vitest config for Nuxt 3"
},
"Vitest Nuxt Mount Suspended": {
"prefix": "vimount-suspended",
"body": [
"const wrapper = await mountSuspended(${0})",
],
"description": "nuxt-vitest mountSuspended"
},
"Vitest Nuxt Mock Import": {
"prefix": "vimocknuxtimport",
"body": [
"mockNuxtImport('${1:functionName}', () => {",
"\treturn () => {",
"\t\treturn { ${0} }",
"\t}",
"})"
],
"description": "nuxt-vitest mockNuxtImport"
},
"Vitest Nuxt Mock Component": {
"prefix": "vimockcomponent",
"body": [
"mockComponent('${0}')",
],
"description": "nuxt-vitest mockComponent"
},
"Vitest Nuxt Register Endpoint": {
"prefix": "viregisterendpoint",
"body": [
"registerEndpoint('/${1:endpoint}/', () => {",
"\t{0}",
"})"
],
"description": "nuxt-vitest registerEndpoint"
},
}
131 changes: 131 additions & 0 deletions snippets/vitest/vitest.code-snippets
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
{
"Vitest Config - Vue 3": {
"prefix": "viconfig",
"body": [
"import { defineConfig } from 'vitest/config'",
"",
"export default defineConfig({",
"\t${0}",
"})"
],
"description": "Vitest config for Vue 3"
},
"Vitest Describe": {
"prefix": "videscribe",
"body": [
"describe('${1:name}'), () => {",
"\t${0}",
"}"
],
"description": "Vitest Describe"
},
"Vitest Describe - Concurrent": {
"prefix": "videscribe-concurrent",
"body": [
"describe.concurrent('${1:name}'), () => {",
"\t${0}",
"}"
],
"description": "Vitest Describe Concurrent"
},
"Vitest It": {
"prefix": "viit",
"body": [
"it('${1:name}'), () => {",
"\t${0}",
"}"
],
"description": "Vitest It"
},
"Vitest It - Concurrent": {
"prefix": "viit-concurrent",
"body": [
"it.concurrent('${1:name}'), () => {",
"\t${0}",
"}"
],
"description": "Vitest It Concurrent"
},
"Vitest It - Async": {
"prefix": "viit-async",
"body": [
"it('${1:name}'), async () => {",
"\t${0}",
"}"
],
"description": "Vitest It Async"
},
"Vitest It - Async Concurrent": {
"prefix": "viit-async-concurrent",
"body": [
"it.concurrent('${1:name}'), async () => {",
"\t${0}",
"}"
],
"description": "Vitest It Async Concurrent"
},
"Vitest It - Todo": {
"prefix": "viit-todo",
"body": [
"it.todo('${1:name}')"
],
"description": "Vitest It Todo"
},
"Vitest Test": {
"prefix": "vitest",
"body": [
"test('${1:name}'), () => {",
"\t${0}",
"}"
],
"description": "Vitest Test"
},
"Vitest Test - Concurrent": {
"prefix": "vitest-concurrent",
"body": [
"test.concurrent('${1:name}'), () => {",
"\t${0}",
"}"
],
"description": "Vitest Test Concurrent"
},
"Vitest Test - Async": {
"prefix": "vitest-async",
"body": [
"test('${1:name}'), async () => {",
"\t${0}",
"}"
],
"description": "Vitest Test Async"
},
"Vitest Test - Async Concurrent": {
"prefix": "vitest-async-concurrent",
"body": [
"test.concurrent('${1:name}'), async () => {",
"\t${0}",
"}"
],
"description": "Vitest Test Async Concurrent"
},
"Vitest Test - Todo": {
"prefix": "vitest-todo",
"body": [
"test.todo('${1:name}')"
],
"description": "Vitest Test Todo"
},
"Vitest Match Snapshot": {
"prefix": "visnapshot",
"body": [
"expect(${0}).toMatchSnapshot()"
],
"description": "Vitest Match Snapshot"
},
"Vitest Match Snapshot - Inline": {
"prefix": "visnapshot-inline",
"body": [
"expect(${0}).toMatchInlineSnapshot()"
],
"description": "Vitest Match Inline Snapshot"
},
}
22 changes: 22 additions & 0 deletions snippets/vitest/vue.code-snippets
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"Vitest Vue Mount": {
"prefix": "vimount",
"body": [
"const wrapper = mount(${0})",
],
"description": "Vue Test Utils Mount"
},
"Vitest Test Component": {
"prefix": "vicomponent",
"body": [
"{",
"\ttemplate: '${0}'",
"\t\tdata() {",
"\t\t\treturn {",
"\t\t${2:variable}",
"\t}",
"}"
],
"description": "Vue Test Utils Component"
}
}
4 changes: 2 additions & 2 deletions snippets/vue/vue-script.code-snippets
Original file line number Diff line number Diff line change
Expand Up @@ -111,15 +111,15 @@
"prefix": "vdefineemits",
"body": [
"defineEmits<{",
"\t${1:eventName}: [${2}]",
"\t${1:eventName}: [${0}]",
"}>()"
],
"description": "Vue defineEmits"
},
"Vue Single Emit": {
"prefix": "vsingleemit",
"body": [
"${1:eventName}: [${2}]",
"${1:eventName}: [${0}]",
],
"description": "Vue single emit for defineEmits"
},
Expand Down