vitest-browser-vue 2.0.0-beta.1 → 2.0.1
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/dist/index.d.ts +8 -11
- package/dist/index.js +9 -15
- package/dist/pure-DYF3m9PV.js +41 -0
- package/dist/pure-Dp75WA7l.d.ts +32 -0
- package/dist/pure.d.ts +2 -30
- package/dist/pure.js +3 -10
- package/package.json +11 -11
- package/dist/chunk-4TGQYMZ3.js +0 -52
package/dist/index.d.ts
CHANGED
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
import { render } from
|
|
2
|
-
export { ComponentRenderOptions, RenderResult, cleanup } from './pure.js';
|
|
3
|
-
export { config } from '@vue/test-utils';
|
|
4
|
-
import 'vitest/browser';
|
|
5
|
-
import 'vue';
|
|
1
|
+
import { a as render, i as config, n as RenderResult, r as cleanup, t as ComponentRenderOptions } from "./pure-Dp75WA7l.js";
|
|
6
2
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
3
|
+
//#region src/index.d.ts
|
|
4
|
+
declare module "vitest/browser" {
|
|
5
|
+
interface BrowserPage {
|
|
6
|
+
render: typeof render;
|
|
7
|
+
}
|
|
11
8
|
}
|
|
12
|
-
|
|
13
|
-
export { render };
|
|
9
|
+
//#endregion
|
|
10
|
+
export { type ComponentRenderOptions, type RenderResult, cleanup, config, render };
|
package/dist/index.js
CHANGED
|
@@ -1,21 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
cleanup,
|
|
3
|
-
config,
|
|
4
|
-
render
|
|
5
|
-
} from "./chunk-4TGQYMZ3.js";
|
|
6
|
-
|
|
7
|
-
// src/index.ts
|
|
1
|
+
import { n as config, r as render, t as cleanup } from "./pure-DYF3m9PV.js";
|
|
8
2
|
import { page } from "vitest/browser";
|
|
9
3
|
import { beforeEach } from "vitest";
|
|
4
|
+
|
|
5
|
+
//#region src/index.ts
|
|
10
6
|
page.extend({
|
|
11
|
-
|
|
12
|
-
|
|
7
|
+
render,
|
|
8
|
+
[Symbol.for("vitest:component-cleanup")]: cleanup
|
|
13
9
|
});
|
|
14
10
|
beforeEach(() => {
|
|
15
|
-
|
|
11
|
+
cleanup();
|
|
16
12
|
});
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
render
|
|
21
|
-
};
|
|
13
|
+
|
|
14
|
+
//#endregion
|
|
15
|
+
export { cleanup, config, render };
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { page, utils } from "vitest/browser";
|
|
2
|
+
import { config, mount } from "@vue/test-utils";
|
|
3
|
+
|
|
4
|
+
//#region src/pure.ts
|
|
5
|
+
const { debug, getElementLocatorSelectors } = utils;
|
|
6
|
+
const mountedWrappers = /* @__PURE__ */ new Set();
|
|
7
|
+
function render(Component, { container: customContainer, baseElement: customBaseElement,...mountOptions } = {}) {
|
|
8
|
+
const div = document.createElement("div");
|
|
9
|
+
const baseElement = customBaseElement || customContainer || document.body;
|
|
10
|
+
const container = customContainer || baseElement.appendChild(div);
|
|
11
|
+
if (mountOptions.attachTo) throw new Error("`attachTo` is not supported, use `container` instead");
|
|
12
|
+
const wrapper = mount(Component, {
|
|
13
|
+
...mountOptions,
|
|
14
|
+
attachTo: container
|
|
15
|
+
});
|
|
16
|
+
unwrapNode(wrapper.parentElement);
|
|
17
|
+
mountedWrappers.add(wrapper);
|
|
18
|
+
return {
|
|
19
|
+
container,
|
|
20
|
+
baseElement,
|
|
21
|
+
locator: page.elementLocator(container),
|
|
22
|
+
debug: (el = baseElement, maxLength, options) => debug(el, maxLength, options),
|
|
23
|
+
unmount: () => wrapper.unmount(),
|
|
24
|
+
emitted: ((name) => wrapper.emitted(name)),
|
|
25
|
+
rerender: (props) => wrapper.setProps(props),
|
|
26
|
+
...getElementLocatorSelectors(baseElement)
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
function cleanup() {
|
|
30
|
+
mountedWrappers.forEach((wrapper) => {
|
|
31
|
+
if (wrapper.element?.parentNode?.parentNode === document.body) document.body.removeChild(wrapper.element.parentNode);
|
|
32
|
+
wrapper.unmount();
|
|
33
|
+
mountedWrappers.delete(wrapper);
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
function unwrapNode(node) {
|
|
37
|
+
node.replaceWith(...node.childNodes);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
//#endregion
|
|
41
|
+
export { config as n, render as r, cleanup as t };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { Locator, LocatorSelectors, PrettyDOMOptions } from "vitest/browser";
|
|
2
|
+
import { ComponentMountingOptions, config } from "@vue/test-utils";
|
|
3
|
+
import { DefineComponent } from "vue";
|
|
4
|
+
|
|
5
|
+
//#region src/pure.d.ts
|
|
6
|
+
type ComponentProps<T$1> = T$1 extends (new (...angs: any) => {
|
|
7
|
+
$props: infer P;
|
|
8
|
+
}) ? NonNullable<P> : T$1 extends ((props: infer P, ...args: any) => any) ? P : {};
|
|
9
|
+
interface RenderResult<Props$1> extends LocatorSelectors {
|
|
10
|
+
container: HTMLElement;
|
|
11
|
+
baseElement: HTMLElement;
|
|
12
|
+
locator: Locator;
|
|
13
|
+
debug(el?: HTMLElement | HTMLElement[] | Locator | Locator[], maxLength?: number, options?: PrettyDOMOptions): void;
|
|
14
|
+
unmount(): void;
|
|
15
|
+
emitted<T = unknown>(): Record<string, T[]>;
|
|
16
|
+
emitted<T = unknown[]>(eventName: string): undefined | T[];
|
|
17
|
+
rerender(props: Partial<Props$1>): void;
|
|
18
|
+
}
|
|
19
|
+
interface ComponentRenderOptions<C, P$1 extends ComponentProps<C>> extends ComponentMountingOptions<C, P$1> {
|
|
20
|
+
container?: HTMLElement;
|
|
21
|
+
baseElement?: HTMLElement;
|
|
22
|
+
}
|
|
23
|
+
declare function render<T$1, C = (T$1 extends ((...args: any) => any) | (new (...args: any) => any) ? T$1 : T$1 extends {
|
|
24
|
+
props?: infer Props;
|
|
25
|
+
} ? DefineComponent<Props extends Readonly<(infer PropNames)[]> | (infer PropNames)[] ? { [key in PropNames extends string ? PropNames : string]?: any } : Props> : DefineComponent), P$1 extends ComponentProps<C> = ComponentProps<C>>(Component: T$1, {
|
|
26
|
+
container: customContainer,
|
|
27
|
+
baseElement: customBaseElement,
|
|
28
|
+
...mountOptions
|
|
29
|
+
}?: ComponentRenderOptions<C, P$1>): RenderResult<P$1>;
|
|
30
|
+
declare function cleanup(): void;
|
|
31
|
+
//#endregion
|
|
32
|
+
export { render as a, config as i, RenderResult as n, cleanup as r, ComponentRenderOptions as t };
|
package/dist/pure.d.ts
CHANGED
|
@@ -1,30 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
export { config } from '@vue/test-utils';
|
|
4
|
-
import { DefineComponent } from 'vue';
|
|
5
|
-
|
|
6
|
-
type ComponentProps<T> = T extends new (...angs: any) => {
|
|
7
|
-
$props: infer P;
|
|
8
|
-
} ? NonNullable<P> : T extends (props: infer P, ...args: any) => any ? P : {};
|
|
9
|
-
interface RenderResult<Props> extends LocatorSelectors {
|
|
10
|
-
container: HTMLElement;
|
|
11
|
-
baseElement: HTMLElement;
|
|
12
|
-
locator: Locator;
|
|
13
|
-
debug(el?: HTMLElement | HTMLElement[] | Locator | Locator[], maxLength?: number, options?: PrettyDOMOptions): void;
|
|
14
|
-
unmount(): void;
|
|
15
|
-
emitted<T = unknown>(): Record<string, T[]>;
|
|
16
|
-
emitted<T = unknown[]>(eventName: string): undefined | T[];
|
|
17
|
-
rerender(props: Partial<Props>): void;
|
|
18
|
-
}
|
|
19
|
-
interface ComponentRenderOptions<C, P extends ComponentProps<C>> extends ComponentMountingOptions<C, P> {
|
|
20
|
-
container?: HTMLElement;
|
|
21
|
-
baseElement?: HTMLElement;
|
|
22
|
-
}
|
|
23
|
-
declare function render<T, C = T extends ((...args: any) => any) | (new (...args: any) => any) ? T : T extends {
|
|
24
|
-
props?: infer Props;
|
|
25
|
-
} ? DefineComponent<Props extends Readonly<(infer PropNames)[]> | (infer PropNames)[] ? {
|
|
26
|
-
[key in PropNames extends string ? PropNames : string]?: any;
|
|
27
|
-
} : Props> : DefineComponent, P extends ComponentProps<C> = ComponentProps<C>>(Component: T, { container: customContainer, baseElement: customBaseElement, ...mountOptions }?: ComponentRenderOptions<C, P>): RenderResult<P>;
|
|
28
|
-
declare function cleanup(): void;
|
|
29
|
-
|
|
30
|
-
export { type ComponentRenderOptions, type RenderResult, cleanup, render };
|
|
1
|
+
import { a as render, i as config, n as RenderResult, r as cleanup, t as ComponentRenderOptions } from "./pure-Dp75WA7l.js";
|
|
2
|
+
export { ComponentRenderOptions, RenderResult, cleanup, config, render };
|
package/dist/pure.js
CHANGED
package/package.json
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vitest-browser-vue",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "2.0.
|
|
4
|
+
"version": "2.0.1",
|
|
5
5
|
"description": "Render Vue components in Vitest Browser Mode",
|
|
6
|
-
"author": "Vitest
|
|
6
|
+
"author": "Vitest Community",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"funding": "https://opencollective.com/vitest",
|
|
9
|
-
"homepage": "https://github.com/vitest-
|
|
9
|
+
"homepage": "https://github.com/vitest-community/vitest-browser-vue#readme",
|
|
10
10
|
"repository": {
|
|
11
11
|
"type": "git",
|
|
12
|
-
"url": "git+https://github.com/vitest-
|
|
12
|
+
"url": "git+https://github.com/vitest-community/vitest-browser-vue.git"
|
|
13
13
|
},
|
|
14
14
|
"bugs": {
|
|
15
|
-
"url": "https://github.com/vitest-
|
|
15
|
+
"url": "https://github.com/vitest-community/vitest-browser-vue/issues"
|
|
16
16
|
},
|
|
17
17
|
"keywords": [
|
|
18
18
|
"vue",
|
|
@@ -48,22 +48,22 @@
|
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
50
|
"@antfu/eslint-config": "^2.24.1",
|
|
51
|
-
"@vitejs/plugin-vue": "^
|
|
52
|
-
"@vitest/browser-playwright": "^4.0.
|
|
51
|
+
"@vitejs/plugin-vue": "^6.0.1",
|
|
52
|
+
"@vitest/browser-playwright": "^4.0.2",
|
|
53
53
|
"bumpp": "^9.4.2",
|
|
54
54
|
"changelogithub": "^0.13.9",
|
|
55
55
|
"eslint": "^9.8.0",
|
|
56
56
|
"playwright": "^1.55.1",
|
|
57
|
-
"
|
|
57
|
+
"tsdown": "^0.15.9",
|
|
58
58
|
"tsx": "^4.16.5",
|
|
59
59
|
"typescript": "^5.5.4",
|
|
60
|
-
"vitest": "^4.0.
|
|
60
|
+
"vitest": "^4.0.2",
|
|
61
61
|
"vue": "^3.4.35",
|
|
62
62
|
"zx": "^8.1.4"
|
|
63
63
|
},
|
|
64
64
|
"scripts": {
|
|
65
|
-
"build": "
|
|
66
|
-
"dev": "
|
|
65
|
+
"build": "tsdown",
|
|
66
|
+
"dev": "tsdown --watch --sourcemap",
|
|
67
67
|
"test": "vitest",
|
|
68
68
|
"publish-ci": "tsx scripts/publish-ci.ts",
|
|
69
69
|
"release": "tsx scripts/release.ts",
|
package/dist/chunk-4TGQYMZ3.js
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
// src/pure.ts
|
|
2
|
-
import { page, utils } from "vitest/browser";
|
|
3
|
-
import { mount } from "@vue/test-utils";
|
|
4
|
-
import { config } from "@vue/test-utils";
|
|
5
|
-
var { debug, getElementLocatorSelectors } = utils;
|
|
6
|
-
var mountedWrappers = /* @__PURE__ */ new Set();
|
|
7
|
-
function render(Component, {
|
|
8
|
-
container: customContainer,
|
|
9
|
-
baseElement: customBaseElement,
|
|
10
|
-
...mountOptions
|
|
11
|
-
} = {}) {
|
|
12
|
-
const div = document.createElement("div");
|
|
13
|
-
const baseElement = customBaseElement || customContainer || document.body;
|
|
14
|
-
const container = customContainer || baseElement.appendChild(div);
|
|
15
|
-
if (mountOptions.attachTo) {
|
|
16
|
-
throw new Error("`attachTo` is not supported, use `container` instead");
|
|
17
|
-
}
|
|
18
|
-
const wrapper = mount(Component, {
|
|
19
|
-
...mountOptions,
|
|
20
|
-
attachTo: container
|
|
21
|
-
});
|
|
22
|
-
unwrapNode(wrapper.parentElement);
|
|
23
|
-
mountedWrappers.add(wrapper);
|
|
24
|
-
return {
|
|
25
|
-
container,
|
|
26
|
-
baseElement,
|
|
27
|
-
locator: page.elementLocator(container),
|
|
28
|
-
debug: (el = baseElement, maxLength, options) => debug(el, maxLength, options),
|
|
29
|
-
unmount: () => wrapper.unmount(),
|
|
30
|
-
emitted: (name) => wrapper.emitted(name),
|
|
31
|
-
rerender: (props) => wrapper.setProps(props),
|
|
32
|
-
...getElementLocatorSelectors(baseElement)
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
function cleanup() {
|
|
36
|
-
mountedWrappers.forEach((wrapper) => {
|
|
37
|
-
if (wrapper.element?.parentNode?.parentNode === document.body) {
|
|
38
|
-
document.body.removeChild(wrapper.element.parentNode);
|
|
39
|
-
}
|
|
40
|
-
wrapper.unmount();
|
|
41
|
-
mountedWrappers.delete(wrapper);
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
function unwrapNode(node) {
|
|
45
|
-
node.replaceWith(...node.childNodes);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
export {
|
|
49
|
-
render,
|
|
50
|
-
cleanup,
|
|
51
|
-
config
|
|
52
|
-
};
|