@allwright.dev/vitest 0.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/README.md +13 -0
- package/dist/index.d.ts +17 -0
- package/dist/index.js +24 -0
- package/package.json +51 -0
package/README.md
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# @allwright.dev/vitest
|
|
2
|
+
|
|
3
|
+
Vitest fixtures for allwright with Playwright-style `browser` and `page` injection.
|
|
4
|
+
|
|
5
|
+
```ts
|
|
6
|
+
import { expect, test } from "@allwright.dev/vitest";
|
|
7
|
+
|
|
8
|
+
test("opens a page", async ({ page }) => {
|
|
9
|
+
await page.goto("https://example.com");
|
|
10
|
+
const title = await page.textContent("h1");
|
|
11
|
+
expect(title.text).toContain("Example");
|
|
12
|
+
});
|
|
13
|
+
```
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type Browser, type LaunchOptions, type Page } from "@allwright.dev/core";
|
|
2
|
+
import { expect } from "vitest";
|
|
3
|
+
export interface AllwrightVitestOptions {
|
|
4
|
+
launchOptions?: LaunchOptions;
|
|
5
|
+
serverAddr?: string;
|
|
6
|
+
}
|
|
7
|
+
export interface AllwrightVitestFixtures {
|
|
8
|
+
browser: Browser;
|
|
9
|
+
page: Page;
|
|
10
|
+
}
|
|
11
|
+
export declare const test: import("vitest").TestAPI<{
|
|
12
|
+
browser: Browser;
|
|
13
|
+
page: Page;
|
|
14
|
+
allwright: AllwrightVitestOptions;
|
|
15
|
+
}>;
|
|
16
|
+
export { expect };
|
|
17
|
+
export type { Browser, LaunchOptions, Page };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { chromium, setServerAddr, shutdown, } from "@allwright.dev/core";
|
|
2
|
+
import { expect, test as base } from "vitest";
|
|
3
|
+
export const test = base.extend({
|
|
4
|
+
allwright: async ({}, use) => {
|
|
5
|
+
await use({});
|
|
6
|
+
},
|
|
7
|
+
browser: async ({ allwright }, use) => {
|
|
8
|
+
if (allwright.serverAddr) {
|
|
9
|
+
setServerAddr(allwright.serverAddr);
|
|
10
|
+
}
|
|
11
|
+
const browser = await chromium.launch(allwright.launchOptions ?? {});
|
|
12
|
+
try {
|
|
13
|
+
await use(browser);
|
|
14
|
+
}
|
|
15
|
+
finally {
|
|
16
|
+
await browser.close().catch(() => undefined);
|
|
17
|
+
await shutdown();
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
page: async ({ browser }, use) => {
|
|
21
|
+
await use(browser.page());
|
|
22
|
+
},
|
|
23
|
+
});
|
|
24
|
+
export { expect };
|
package/package.json
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@allwright.dev/vitest",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "Vitest fixtures for the allwright TypeScript client.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/allwright-dev/allwright.git"
|
|
10
|
+
},
|
|
11
|
+
"homepage": "https://allwright.dev",
|
|
12
|
+
"bugs": {
|
|
13
|
+
"url": "https://github.com/allwright-dev/allwright/issues"
|
|
14
|
+
},
|
|
15
|
+
"keywords": [
|
|
16
|
+
"automation",
|
|
17
|
+
"testing",
|
|
18
|
+
"vitest",
|
|
19
|
+
"fixtures",
|
|
20
|
+
"playwright-style"
|
|
21
|
+
],
|
|
22
|
+
"main": "./dist/index.js",
|
|
23
|
+
"types": "./dist/index.d.ts",
|
|
24
|
+
"exports": {
|
|
25
|
+
".": {
|
|
26
|
+
"types": "./dist/index.d.ts",
|
|
27
|
+
"import": "./dist/index.js"
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
"files": [
|
|
31
|
+
"dist",
|
|
32
|
+
"README.md"
|
|
33
|
+
],
|
|
34
|
+
"publishConfig": {
|
|
35
|
+
"access": "public"
|
|
36
|
+
},
|
|
37
|
+
"scripts": {
|
|
38
|
+
"build": "tsc -p tsconfig.json",
|
|
39
|
+
"prepublishOnly": "npm run build"
|
|
40
|
+
},
|
|
41
|
+
"dependencies": {
|
|
42
|
+
"@allwright.dev/core": "0.0.1"
|
|
43
|
+
},
|
|
44
|
+
"devDependencies": {
|
|
45
|
+
"typescript": "^5.9.2",
|
|
46
|
+
"vitest": "^3.2.4"
|
|
47
|
+
},
|
|
48
|
+
"peerDependencies": {
|
|
49
|
+
"vitest": "^3.2.4"
|
|
50
|
+
}
|
|
51
|
+
}
|