Skip to content

feat(vitest): Add base Vitest snippets #67

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
May 13, 2024
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
39 changes: 21 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -164,24 +164,27 @@ These snippets were made to speed up Vue 3 development. With it you can write bo

### 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 |
| Snippet | Purpose |
| ------------------------- | --------------------------------------- |
| `vibase` | Base for Vitest file |
| `vibase-vue` | Base for Vitest file for Vue component |
| `vibase-nuxt` | Base for Vitest file for Nuxt component |
| `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 |

### Vitest Vue

Expand Down
23 changes: 23 additions & 0 deletions snippets/vitest/nuxt.code-snippets
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,27 @@
],
"description": "nuxt-vitest registerEndpoint"
},
"Vitest Nuxt Base": {
"prefix": "vibase-nuxt",
"body": [
"// @vitest-environment nuxt",
"import type { VueWrapper } from '@vue/test-utils'",
"import { mountSuspended } from '@nuxt/test-utils/runtime'",
"import { afterEach, beforeEach, describe, expect } from 'vitest'",
"import ${TM_FILENAME/\\..*//} from '~/components/${TM_FILENAME/\\..*//}.vue'",
"",
"describe('${TM_FILENAME/\\..*//}', () => {",
"\tlet wrapper: VueWrapper",
"\t",
"\tbeforeEach(async () => {",
"\t\twrapper = await mountSuspended(${TM_FILENAME/\\..*//})",
"\t})",
"\t",
"\tafterEach(() => {",
"\t\twrapper.unmount()",
"\t})",
"})"
],
"description": "Base for Vitest file for Vue component"
}
}
12 changes: 12 additions & 0 deletions snippets/vitest/vitest.code-snippets
Original file line number Diff line number Diff line change
Expand Up @@ -128,4 +128,16 @@
],
"description": "Vitest Match Inline Snapshot"
},
"Vitest Base": {
"prefix": "vibase",
"body": [
"// @vitest-environment node",
"import { describe, expect } from 'vitest'",
"",
"describe('${TM_FILENAME/\\..*//}', () => {",
"\t${0}",
"})"
],
"description": "Base for Vitest file"
},
}
22 changes: 22 additions & 0 deletions snippets/vitest/vue.code-snippets
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,27 @@
"}"
],
"description": "Vue Test Utils Component"
},
"Vitest Vue Base": {
"prefix": "vibase-vue",
"body": [
"import type { VueWrapper } from '@vue/test-utils'",
"import { mount } from '@vue/test-utils'",
"import { afterEach, beforeEach, describe, expect } from 'vitest'",
"import ${TM_FILENAME/\\..*//} from '~/components/${TM_FILENAME/\\..*//}.vue'",
"",
"describe('${TM_FILENAME/\\..*//}', () => {",
"\tlet wrapper: VueWrapper",
"\t",
"\tbeforeEach(() => {",
"\t\twrapper = mount(${TM_FILENAME/\\..*//})",
"\t})",
"\t",
"\tafterEach(() => {",
"\t\twrapper.unmount()",
"\t})",
"})"
],
"description": "Base for Vitest file for Vue component"
}
}