diff --git a/README.md b/README.md index 5debe71..94d8b77 100644 --- a/README.md +++ b/README.md @@ -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 @@ -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). diff --git a/package.json b/package.json index 45301c8..9e31698 100644 --- a/package.json +++ b/package.json @@ -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" } ] } diff --git a/snippets/vitest/nuxt.code-snippets b/snippets/vitest/nuxt.code-snippets new file mode 100644 index 0000000..b3f26a4 --- /dev/null +++ b/snippets/vitest/nuxt.code-snippets @@ -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" + }, +} diff --git a/snippets/vitest/vitest.code-snippets b/snippets/vitest/vitest.code-snippets new file mode 100644 index 0000000..ce6944c --- /dev/null +++ b/snippets/vitest/vitest.code-snippets @@ -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" + }, +} diff --git a/snippets/vitest/vue.code-snippets b/snippets/vitest/vue.code-snippets new file mode 100644 index 0000000..ea6ec08 --- /dev/null +++ b/snippets/vitest/vue.code-snippets @@ -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" + } +} diff --git a/snippets/vue/vue-script.code-snippets b/snippets/vue/vue-script.code-snippets index 602ab31..f9ef317 100644 --- a/snippets/vue/vue-script.code-snippets +++ b/snippets/vue/vue-script.code-snippets @@ -111,7 +111,7 @@ "prefix": "vdefineemits", "body": [ "defineEmits<{", - "\t${1:eventName}: [${2}]", + "\t${1:eventName}: [${0}]", "}>()" ], "description": "Vue defineEmits" @@ -119,7 +119,7 @@ "Vue Single Emit": { "prefix": "vsingleemit", "body": [ - "${1:eventName}: [${2}]", + "${1:eventName}: [${0}]", ], "description": "Vue single emit for defineEmits" },