vitest-browser-vue 0.0.1 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +17 -1
- package/dist/{chunk-S4673CTL.js → chunk-ELIMMUCX.js} +3 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +3 -1
- package/dist/pure.d.ts +1 -0
- package/dist/pure.js +3 -1
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# vitest-browser-vue
|
|
2
2
|
|
|
3
|
-
Render Vue components in Vitest Browser Mode. This library follows `testing-library` principles and exposes only [locators](https://vitest.dev/guide/browser/locators) and utilities that encourage you to write tests that closely resemble how your Vue components are used.
|
|
3
|
+
Render Vue components in Vitest Browser Mode. This library follows [`testing-library` principles](https://testing-library.com/docs/guiding-principles/) and exposes only [locators](https://vitest.dev/guide/browser/locators) and utilities that encourage you to write tests that closely resemble how your Vue components are used.
|
|
4
4
|
|
|
5
5
|
Requires `vitest` and `@vitest/browser` 2.1.0 or higher.
|
|
6
6
|
|
|
@@ -33,6 +33,10 @@ export default defineConfig({
|
|
|
33
33
|
// "compilerOptions.types" in your tsconfig or
|
|
34
34
|
// import `vitest-browser-vue` manually so TypeScript can pick it up
|
|
35
35
|
setupFiles: ['vitest-browser-vue'],
|
|
36
|
+
browser: {
|
|
37
|
+
name: 'chromium',
|
|
38
|
+
enabled: true,
|
|
39
|
+
},
|
|
36
40
|
},
|
|
37
41
|
})
|
|
38
42
|
```
|
|
@@ -53,6 +57,18 @@ test('counter button increments the count', async () => {
|
|
|
53
57
|
|
|
54
58
|
Unlike `@testing-library/vue`, `vitest-browser-vue` cleans up the component before the test starts instead of after, so you can see the rendered result in your UI. To avoid auto-cleanup, import the `render` function from `vitest-browser-vue/pure`.
|
|
55
59
|
|
|
60
|
+
## Configuration
|
|
61
|
+
|
|
62
|
+
You can change the global configuration by modifying the `config` export. You can import it from both `vitest-browser-vue` and `vitest-browser-vue/pure`. See [documentation](https://test-utils.vuejs.org/api/#config).
|
|
63
|
+
|
|
64
|
+
```js
|
|
65
|
+
import { config } from 'vitest-browser-vue'
|
|
66
|
+
|
|
67
|
+
config.global.mocks = {
|
|
68
|
+
$t: text => text
|
|
69
|
+
}
|
|
70
|
+
```
|
|
71
|
+
|
|
56
72
|
## Special thanks
|
|
57
73
|
|
|
58
74
|
- Powered by [`@vue/test-utils`](https://github.com/vuejs/test-utils/)
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// src/pure.ts
|
|
2
2
|
import { mount } from "@vue/test-utils";
|
|
3
3
|
import { debug, getElementLocatorSelectors } from "@vitest/browser/utils";
|
|
4
|
+
import { config } from "@vue/test-utils";
|
|
4
5
|
var mountedWrappers = /* @__PURE__ */ new Set();
|
|
5
6
|
function render(Component, {
|
|
6
7
|
container: customContainer,
|
|
@@ -44,5 +45,6 @@ function unwrapNode(node) {
|
|
|
44
45
|
|
|
45
46
|
export {
|
|
46
47
|
render,
|
|
47
|
-
cleanup
|
|
48
|
+
cleanup,
|
|
49
|
+
config
|
|
48
50
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { render } from './pure.js';
|
|
2
2
|
export { ComponentRenderOptions, RenderResult, cleanup } from './pure.js';
|
|
3
|
+
export { config } from '@vue/test-utils';
|
|
3
4
|
import '@vitest/browser/context';
|
|
4
|
-
import '@vue/test-utils';
|
|
5
5
|
import 'vue';
|
|
6
6
|
import '@vitest/browser/utils';
|
|
7
7
|
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
2
|
cleanup,
|
|
3
|
+
config,
|
|
3
4
|
render
|
|
4
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-ELIMMUCX.js";
|
|
5
6
|
|
|
6
7
|
// src/index.ts
|
|
7
8
|
import { page } from "@vitest/browser/context";
|
|
@@ -15,5 +16,6 @@ beforeEach(() => {
|
|
|
15
16
|
});
|
|
16
17
|
export {
|
|
17
18
|
cleanup,
|
|
19
|
+
config,
|
|
18
20
|
render
|
|
19
21
|
};
|
package/dist/pure.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { LocatorSelectors, Locator } from '@vitest/browser/context';
|
|
2
2
|
import { ComponentMountingOptions } from '@vue/test-utils';
|
|
3
|
+
export { config } from '@vue/test-utils';
|
|
3
4
|
import { DefineComponent } from 'vue';
|
|
4
5
|
import { PrettyDOMOptions } from '@vitest/browser/utils';
|
|
5
6
|
|
package/dist/pure.js
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vitest-browser-vue",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0
|
|
4
|
+
"version": "0.2.0",
|
|
5
5
|
"description": "Render Vue components in Vitest Browser Mode",
|
|
6
6
|
"author": "Vitest Team",
|
|
7
7
|
"license": "MIT",
|
|
@@ -42,8 +42,8 @@
|
|
|
42
42
|
"node": "^18.0.0 || >=20.0.0"
|
|
43
43
|
},
|
|
44
44
|
"peerDependencies": {
|
|
45
|
-
"@vitest/browser": "^2.1.0-
|
|
46
|
-
"vitest": "^2.1.0-
|
|
45
|
+
"@vitest/browser": "^2.1.0 || ^3.0.0-0",
|
|
46
|
+
"vitest": "^2.1.0 || ^3.0.0-0",
|
|
47
47
|
"vue": "^3.0.0"
|
|
48
48
|
},
|
|
49
49
|
"dependencies": {
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
"devDependencies": {
|
|
53
53
|
"@antfu/eslint-config": "^2.24.1",
|
|
54
54
|
"@vitejs/plugin-vue": "^5.1.2",
|
|
55
|
-
"@vitest/browser": "^
|
|
55
|
+
"@vitest/browser": "^3.0.0",
|
|
56
56
|
"bumpp": "^9.4.2",
|
|
57
57
|
"changelogithub": "^0.13.9",
|
|
58
58
|
"eslint": "^9.8.0",
|
|
@@ -60,7 +60,7 @@
|
|
|
60
60
|
"tsup": "^8.2.4",
|
|
61
61
|
"tsx": "^4.16.5",
|
|
62
62
|
"typescript": "^5.5.4",
|
|
63
|
-
"vitest": "^
|
|
63
|
+
"vitest": "^3.0.0",
|
|
64
64
|
"vue": "^3.4.35",
|
|
65
65
|
"zx": "^8.1.4"
|
|
66
66
|
},
|