diff --git a/.vscode/settings.json b/.vscode/settings.json
index ac9aab1..d27cae5 100644
--- a/.vscode/settings.json
+++ b/.vscode/settings.json
@@ -2,6 +2,7 @@
"cSpell.words": [
"cfrv",
"deinsoftware",
+ "eatg",
"Equiman",
"github",
"mrvo",
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 891ea0b..5f515b6 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -9,6 +9,15 @@ Fixed for any bug fixes.
Security to invite users to upgrade in case of vulnerabilities.
-->
+## 1.6.0 - 2023/04/04
+
+### Added
+
+- expect any TypeScript
+- afterEach mock clear and reset
+- extra imports for vitest
+- vi.mock
+
## 1.5.1 - 2023/04/04
### Fixed
diff --git a/README.md b/README.md
index ab62706..f2e342a 100644
--- a/README.md
+++ b/README.md
@@ -27,6 +27,7 @@ The quick and easy way to create and use Vitest with [VS Code](https://code.visu
- [It](#it)
- [Test](#test)
- [Expect](#expect)
+ - [Any](#any)
- [Assertion](#assertion)
- [Keyboard](#keyboard)
- [Settings](#settings)
@@ -78,20 +79,21 @@ Below is a list of all available snippets and the triggers of each one. The `░
### Import
-| Trigger | Result |
-| -------: | ----------------------------------------------------------------- |
-| `iv→` | `import { it, expect, describe } from 'vitest'█` |
+| Trigger | Result |
+| -------: | ---------------------------------------------------------------------------- |
+| `iv→` | `import { it, expect, describe } from 'vitest'█` |
+| `ive→` | `import { beforeEach, afterEach, it, expect, describe, vi } from 'vitest'█` |
### Setup
| Trigger | Result |
| -------: | --------------------------------------------------------------- |
-| `ae→` | afterEach(() => {
█
})
|
-| `aa→` | afterAll(() => {
█
})
|
-| `be→` | beforeEach(() => {
█
})
|
-| `bea→` | beforeEach(async () => {
█
})
|
| `ba→` | beforeAll(() => {
█
})
|
| `baa→` | beforeAll(async () => {
█
})
|
+| `be→` | beforeEach(() => {
█
})
|
+| `bea→` | beforeEach(async () => {
█
})
|
+| `ae→` | afterEach(() => {
█
})
|
+| `aa→` | afterAll(() => {
█
})
|
### Describe
@@ -104,18 +106,21 @@ Below is a list of all available snippets and the triggers of each one. The `░
### Mock
-| Trigger | Result |
-| -------: | ------------------------------------------------------------------------------ |
-| `vf→` | `vi.fn()█` |
-| `vfrv→` | `vi.fn().mockResolvedValue(█)` |
-| `cf→` | `const ░nameMock = vi.fn()█` |
-| `cfrv→` | `const ░nameMock = vi.fn().mockResolvedValue(█)` |
-| `mrv→` | `░mock.mockReturnValue(█)` |
-| `mrvo→` | `░mock.mockReturnValueOnce(█)` |
-| `vs→` | `vi.spyOn(░global, '░method')█` |
-| `vsi→` | `vi.spyOn(░global, '░method').mockImplementation(() => █)` |
-| `cs→` | `const ░methodSpy = vi.spyOn(░global, '░method')█` |
-| `csi→` | `const ░methodSpy = vi.spyOn(░global, '░method').mockImplementation(() => █)` |
+| Trigger | Result |
+| -------: | ------------------------------------------------------------------------------------------------------------- |
+| `aevcr→` | afterEach(() => {
vi.clearAllMocks()
vi.resetAllMocks()
})█
|
+| `vm→` | `vi.mock('░path')█` |
+| `vmrv→` | `vi.mock('░path').mockResolvedValue(█)` |
+| `vf→` | `vi.fn()█` |
+| `vfrv→` | `vi.fn().mockResolvedValue(█)` |
+| `cf→` | `const ░nameMock = vi.fn()█` |
+| `cfrv→` | `const ░nameMock = vi.fn().mockResolvedValue(█)` |
+| `mrv→` | `░mock.mockReturnValue(█)` |
+| `mrvo→` | `░mock.mockReturnValueOnce(█)` |
+| `vs→` | `vi.spyOn(░global, '░method')█` |
+| `vsi→` | `vi.spyOn(░global, '░method').mockImplementation(() => █)` |
+| `cs→` | `const ░methodSpy = vi.spyOn(░global, '░method')█` |
+| `csi→` | `const ░methodSpy = vi.spyOn(░global, '░method').mockImplementation(() => █)` |
### It
@@ -146,7 +151,20 @@ Below is a list of all available snippets and the triggers of each one. The `░
| `ea→` | `expect.assertions(█)` |
| `eha→` | `expect.hasAssertions()█` |
| `erj→` | `expect(░).rejects█` |
-| `ers→` | `expect(░).resolves█` |
+| `ers→` | `expect(░).resolves█` |
+
+### Any
+
+| Trigger | Result |
+| -------: | ------------------------ |
+| `eav→` | `expect.any(░)█` |
+| `eas→` | `expect.any(String)█` |
+| `ean→` | `expect.any(Number)█` |
+| `eab→` | `expect.any(Boolean)█` |
+| `ead→` | `expect.any(Date)█` |
+| `eaf→` | `expect.any(Function)█` |
+| `eaa→` | `expect.any(Array)█` |
+| `eat→` | `expect.anything()█` |
### Assertion
diff --git a/package.json b/package.json
index 481ea5e..1165723 100644
--- a/package.json
+++ b/package.json
@@ -1,7 +1,7 @@
{
"name": "vitest-snippets",
"description": "VS Code Vitest snippets for JS and TS",
- "version": "1.5.1",
+ "version": "1.6.0",
"displayName": "Vitest Snippets",
"publisher": "deinsoftware",
"icon": "images/light-icon.png",
diff --git a/snippets/import.json b/snippets/import.json
index 5a945de..ccf18bd 100644
--- a/snippets/import.json
+++ b/snippets/import.json
@@ -3,5 +3,10 @@
"prefix": "iv",
"body": "import { it, expect, describe } from 'vitest'$0",
"description": "essential imports for vitest"
+ },
+ "import.vitest.extra": {
+ "prefix": "ive",
+ "body": "import { beforeEach, afterEach, it, expect, describe, vi } from 'vitest'$0",
+ "description": "extra imports for vitest"
}
}
diff --git a/snippets/mock.json b/snippets/mock.json
index feaff42..c8db50e 100644
--- a/snippets/mock.json
+++ b/snippets/mock.json
@@ -1,4 +1,24 @@
{
+ "vi.afterEach.mockClearReset": {
+ "prefix": "aevcr",
+ "body": [
+ "afterEach(() => {",
+ "\tvi.clearAllMocks()",
+ "\tvi.resetAllMocks()",
+ "})$0"
+ ],
+ "description": "afterEach mock clear and reset functions called once after each spec"
+ },
+ "vi.mock": {
+ "prefix": "vm",
+ "body": "vi.mock('${1:path}')$0",
+ "description": "creates vi.mock()"
+ },
+ "vi.mock.mockResolvedValue": {
+ "prefix": "vmrv",
+ "body": "vi.mock('${1:path}').mockResolvedValue($0)",
+ "description": "creates vi.mock() with resolved value"
+ },
"vi.fn": {
"prefix": "vf",
"body": "vi.fn()$0",
diff --git a/snippets/type.json b/snippets/type.json
new file mode 100644
index 0000000..493a92f
--- /dev/null
+++ b/snippets/type.json
@@ -0,0 +1,42 @@
+{
+ "expect.any.type": {
+ "prefix": "eav",
+ "body": "expect.any($1)$0",
+ "description": "expect any value type"
+ },
+ "expect.any.string": {
+ "prefix": "eas",
+ "body": "expect.any(String)$0",
+ "description": "expect any string type"
+ },
+ "expect.any.number": {
+ "prefix": "ean",
+ "body": "expect.any(Number)$0",
+ "description": "expect any number type"
+ },
+ "expect.any.boolean": {
+ "prefix": "eab",
+ "body": "expect.any(Boolean)$0",
+ "description": "expect any boolean type"
+ },
+ "expect.any.date": {
+ "prefix": "ead",
+ "body": "expect.any(Date)$0",
+ "description": "expect any date type"
+ },
+ "expect.any.function": {
+ "prefix": "eaf",
+ "body": "expect.any(Function)$0",
+ "description": "expect any function type"
+ },
+ "expect.any.array": {
+ "prefix": "eaa",
+ "body": "expect.any(Array)$0",
+ "description": "expect any array type"
+ },
+ "expect.any.thing": {
+ "prefix": "eat",
+ "body": "expect.anything()$0",
+ "description": "expect anything"
+ }
+}
diff --git a/test/snippets.test.js b/test/snippets.test.js
index bcadbf5..2af4edc 100644
--- a/test/snippets.test.js
+++ b/test/snippets.test.js
@@ -8,6 +8,7 @@ const itSnippets = require("../snippets/it.json")
const testSnippets = require("../snippets/test.json")
const expectSnippets = require("../snippets/expect.json")
const assertionSnippets = require("../snippets/assertion.json")
+const typeSnippets = require("../snippets/type.json")
const snippets = {
...importSnippets,
@@ -18,6 +19,7 @@ const snippets = {
...testSnippets,
...expectSnippets,
...assertionSnippets,
+ ...typeSnippets,
}
const unique = (xs) => [...new Set(xs)]