@qawolf/testkit 1.0.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/LICENSE +21 -0
- package/README.md +48 -0
- package/dist/client.d.ts +21 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +17 -0
- package/dist/client.js.map +1 -0
- package/dist/clientScope.d.ts +5 -0
- package/dist/clientScope.d.ts.map +1 -0
- package/dist/clientScope.js +11 -0
- package/dist/clientScope.js.map +1 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +33 -0
- package/dist/index.js.map +1 -0
- package/dist/types.d.ts +27 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/dist/web/index.d.ts +7 -0
- package/dist/web/index.d.ts.map +1 -0
- package/dist/web/index.js +20 -0
- package/dist/web/index.js.map +1 -0
- package/package.json +58 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 QA Wolf Inc.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# @qawolf/testkit
|
|
2
|
+
|
|
3
|
+
`@qawolf/testkit` is a TypeScript toolkit designed to help you use QA Wolf flow
|
|
4
|
+
helpers and runner integrations for cases outside normal browser or mobile
|
|
5
|
+
automation.
|
|
6
|
+
|
|
7
|
+
To learn more about how to use `@qawolf/testkit`, check out the
|
|
8
|
+
[API Reference](https://docs.qawolf.com/qawolf/libraries/testkit/api-reference/index)
|
|
9
|
+
and [Documentation](https://docs.qawolf.com/qawolf/libraries/testkit).
|
|
10
|
+
|
|
11
|
+
## Install
|
|
12
|
+
|
|
13
|
+
```sh
|
|
14
|
+
npm install @qawolf/testkit
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Usage
|
|
18
|
+
|
|
19
|
+
Generate an OTP to complete a two-factor challenge inside your flow.
|
|
20
|
+
|
|
21
|
+
```ts
|
|
22
|
+
import { otp } from "@qawolf/testkit";
|
|
23
|
+
|
|
24
|
+
const code = otp.fromUri(process.env["OTP_URI"]!);
|
|
25
|
+
|
|
26
|
+
await page.getByLabel("Verification code").fill(code);
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
Decode a QR code from the page when your app uses QR-based setup or login.
|
|
30
|
+
|
|
31
|
+
```ts
|
|
32
|
+
import { readQRCode } from "@qawolf/testkit/web";
|
|
33
|
+
|
|
34
|
+
const qrValue = await readQRCode(page, "[data-testid='qr-code']");
|
|
35
|
+
|
|
36
|
+
if (!qrValue) throw new Error("QR code was not visible");
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
Use runner-backed helpers for environment setup, such as connecting through
|
|
40
|
+
OpenVPN before the rest of the flow runs.
|
|
41
|
+
|
|
42
|
+
```ts
|
|
43
|
+
import { startOpenVpn } from "@qawolf/testkit";
|
|
44
|
+
|
|
45
|
+
await startOpenVpn({
|
|
46
|
+
configPath: "/tmp/client.ovpn",
|
|
47
|
+
});
|
|
48
|
+
```
|
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { MountCifsShareOptions, SaveBaselineScreenshot, SaveSnapshot, StartOpenVpnOptions, StartWireGuardOptions, TestkitPorts } from "./types.js";
|
|
2
|
+
export type { MountCifsShareOptions, SaveBaselineScreenshot, SaveSnapshot, Screenshotable, StartOpenVpnOptions, StartWireGuardOptions, TestkitPorts, } from "./types.js";
|
|
3
|
+
export type TestkitClientWithBaseline = {
|
|
4
|
+
mountCifsShare: (options: MountCifsShareOptions) => Promise<string>;
|
|
5
|
+
saveBaselineScreenshot: SaveBaselineScreenshot;
|
|
6
|
+
startOpenVpn: (options: StartOpenVpnOptions) => Promise<string>;
|
|
7
|
+
startWireGuard: (options: StartWireGuardOptions) => Promise<string>;
|
|
8
|
+
};
|
|
9
|
+
export type TestkitClientWithoutBaseline = {
|
|
10
|
+
mountCifsShare: (options: MountCifsShareOptions) => Promise<string>;
|
|
11
|
+
saveBaselineScreenshot?: undefined;
|
|
12
|
+
startOpenVpn: (options: StartOpenVpnOptions) => Promise<string>;
|
|
13
|
+
startWireGuard: (options: StartWireGuardOptions) => Promise<string>;
|
|
14
|
+
};
|
|
15
|
+
export type TestkitClient = TestkitClientWithBaseline | TestkitClientWithoutBaseline;
|
|
16
|
+
export type TestkitClientOptions = TestkitPorts;
|
|
17
|
+
export declare function createTestkitClient(options: TestkitClientOptions & {
|
|
18
|
+
saveSnapshot: SaveSnapshot;
|
|
19
|
+
}): TestkitClientWithBaseline;
|
|
20
|
+
export declare function createTestkitClient(options: TestkitClientOptions): Test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C5B,GACA,yBAAyB,CAAC;AAC7B,wBAAgB,mBAAmB,CACjC,OAAO,EAAE,oBAAoB,GAC5B,aAAa,CAAC"}
|
package/dist/client.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
function createSaveBaselineScreenshot(saveSnapshot) {
|
|
2
|
+
return async function saveBaselineScreenshot(pageOrLocator, name, screenshotOptions) {
|
|
3
|
+
const screenshot = await pageOrLocator.screenshot(screenshotOptions);
|
|
4
|
+
await saveSnapshot(name, screenshot);
|
|
5
|
+
};
|
|
6
|
+
}
|
|
7
|
+
export function createTestkitClient({ mountCifsShare, saveSnapshot, startOpenVpn, startWireGuard, }) {
|
|
8
|
+
return {
|
|
9
|
+
mountCifsShare,
|
|
10
|
+
saveBaselineScreenshot: saveSnapshot
|
|
11
|
+
? createSaveBaselineScreenshot(saveSnapshot)
|
|
12
|
+
: undefined,
|
|
13
|
+
startOpenVpn,
|
|
14
|
+
startWireGuard,
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAwCA,SAAS,4BAA4B,CACnC,YAA0B;IAE1B,OAAO,KAAK,UAAU,sBAAsB,CAC1C,aAA6B,EAC7B,IAAI,EACJ,iBAAiB;QAEjB,MAAM,UAAU,GAAG,MAAM,aAAa,CAAC,UAAU,CAAC,iBAAiB,CAAC,CAAC;QACrE,MAAM,YAAY,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;IACvC,CAAC,CAAC;AACJ,CAAC;AAUD,MAAM,UAAU,mBAAmB,CAAC,EAClC,cAAc,EACd,YAAY,EACZ,YAAY,EACZ,cAAc,GACO;IACrB,OAAO;QACL,cAAc;QACd,sBAAsB,EAAE,YAAY;YAClC,CAAC,CAAC,4BAA4B,CAAC,YAAY,CAAC;YAC5C,CAAC,CAAC,SAAS;QACb,YAAY;QACZ,cAAc;KACf,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { TestkitClient } from "./client.js";
|
|
2
|
+
export declare function configureTestkitClient(client: TestkitClient): void;
|
|
3
|
+
export declare function resetTestkitClient(): void;
|
|
4
|
+
export declare function getCurrentTestkitClient(): TestkitClient | undefined;
|
|
5
|
+
//# sourceMappingURL=clientScope.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"clientScope.d.ts","sourceRoot":"","sources":["../src/clientScope.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAIjD,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,aAAa,GAAG,IAAI,CAElE;AAED,wBAAgB,kBAAkB,IAAI,IAAI,CAEzC;AAED,wBAAgB,uBAAuB,IAAI,aAAa,GAAG,SAAS,CAEnE"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
let currentClient;
|
|
2
|
+
export function configureTestkitClient(client) {
|
|
3
|
+
currentClient = client;
|
|
4
|
+
}
|
|
5
|
+
export function resetTestkitClient() {
|
|
6
|
+
currentClient = undefined;
|
|
7
|
+
}
|
|
8
|
+
export function getCurrentTestkitClient() {
|
|
9
|
+
return currentClient;
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=clientScope.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"clientScope.js","sourceRoot":"","sources":["../src/clientScope.ts"],"names":[],"mappings":"AAEA,IAAI,aAAwC,CAAC;AAE7C,MAAM,UAAU,sBAAsB,CAAC,MAAqB;IAC1D,aAAa,GAAG,MAAM,CAAC;AACzB,CAAC;AAED,MAAM,UAAU,kBAAkB;IAChC,aAAa,GAAG,SAAS,CAAC;AAC5B,CAAC;AAED,MAAM,UAAU,uBAAuB;IACrC,OAAO,aAAa,CAAC;AACvB,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { MountCifsShareOptions, Screenshotable, StartOpenVpnOptions } from "./types.js";
|
|
2
|
+
export { configureTestkitClient, getCurrentTestkitClient, resetTestkitClient, } from "./clientScope.js";
|
|
3
|
+
export type { MountCifsShareOptions, SaveBaselineScreenshot, Screenshotable, StartOpenVpnOptions, } from "./types.js";
|
|
4
|
+
export declare const otp: {
|
|
5
|
+
fromUri(uri: string): string;
|
|
6
|
+
};
|
|
7
|
+
export declare function mountCifsShare(options: MountCifsShareOptions): Promise<string>;
|
|
8
|
+
export declare function startOpenVpn(options: StartOpenVpnOptions): Promise<string>;
|
|
9
|
+
export declare function saveBaselineScreenshot(pageOrLocator: Screenshotable, name: string, screenshotOptions?: unknown): Promise<void>;
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,qBAAqB,EACrB,cAAc,EACd,mBAAmB,EACpB,MAAM,YAAY,CAAC;AAEpB,OAAO,EACL,sBAAsB,EACtB,uBAAuB,EACvB,kBAAkB,GACnB,MAAM,kBAAkB,CAAC;AAE1B,YAAY,EACV,qBAAqB,EACrB,sBAAsB,EACtB,cAAc,EACd,mBAAmB,GACpB,MAAM,YAAY,CAAC;AAEpB,eAAO,MAAM,GAAG;iBACD,MAAM,GAAG,MAAM;CAG7B,CAAC;AAcF,wBAAsB,cAAc,CAClC,OAAO,EAAE,qBAAqB,GAC7B,OAAO,CAAC,MAAM,CAAC,CAEjB;AAED,wBAAsB,YAAY,CAChC,OAAO,EAAE,mBAAmB,GAC3B,OAAO,CAAC,MAAM,CAAC,CAEjB;AAED,wBAAsB,sBAAsB,CAC1C,aAAa,EAAE,cAAc,EAC7B,IAAI,EAAE,MAAM,EACZ,iBAAiB,CAAC,EAAE,OAAO,GAC1B,OAAO,CAAC,IAAI,CAAC,CAUf"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import * as OTPAuth from "otpauth";
|
|
2
|
+
import { getCurrentTestkitClient } from "./clientScope.js";
|
|
3
|
+
export { configureTestkitClient, getCurrentTestkitClient, resetTestkitClient, } from "./clientScope.js";
|
|
4
|
+
export const otp = {
|
|
5
|
+
fromUri(uri) {
|
|
6
|
+
return OTPAuth.URI.parse(uri).generate();
|
|
7
|
+
},
|
|
8
|
+
};
|
|
9
|
+
function requireClient(helperName) {
|
|
10
|
+
const client = getCurrentTestkitClient();
|
|
11
|
+
if (!client) {
|
|
12
|
+
throw Error(`@qawolf/testkit ${helperName}() requires a client. Call ` +
|
|
13
|
+
"configureTestkitClient(...) once at startup before calling " +
|
|
14
|
+
`${helperName}().`);
|
|
15
|
+
}
|
|
16
|
+
return client;
|
|
17
|
+
}
|
|
18
|
+
export async function mountCifsShare(options) {
|
|
19
|
+
return requireClient("mountCifsShare").mountCifsShare(options);
|
|
20
|
+
}
|
|
21
|
+
export async function startOpenVpn(options) {
|
|
22
|
+
return requireClient("startOpenVpn").startOpenVpn(options);
|
|
23
|
+
}
|
|
24
|
+
export async function saveBaselineScreenshot(pageOrLocator, name, screenshotOptions) {
|
|
25
|
+
const client = requireClient("saveBaselineScreenshot");
|
|
26
|
+
if (!client.saveBaselineScreenshot) {
|
|
27
|
+
throw Error("@qawolf/testkit saveBaselineScreenshot() requires a testkit client " +
|
|
28
|
+
"with screenshot support (pass a saveSnapshot port to " +
|
|
29
|
+
"createTestkitClient from @qawolf/testkit/client).");
|
|
30
|
+
}
|
|
31
|
+
return client.saveBaselineScreenshot(pageOrLocator, name, screenshotOptions);
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,SAAS,CAAC;AAGnC,OAAO,EAAE,u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|
1
|
+
export type MountCifsShareOptions = {
|
|
2
|
+
mountPoint: string;
|
|
3
|
+
password: string;
|
|
4
|
+
share: string;
|
|
5
|
+
username: string;
|
|
6
|
+
};
|
|
7
|
+
export type Screenshotable = {
|
|
8
|
+
screenshot: (screenshotOptions?: unknown) => Promise<Buffer>;
|
|
9
|
+
};
|
|
10
|
+
export type SaveBaselineScreenshot = (pageOrLocator: Screenshotable, name: string, screenshotOptions?: unknown) => Promise<void>;
|
|
11
|
+
export type SaveSnapshot = (name: string, bytes: Buffer) => Promise<void>;
|
|
12
|
+
export type StartOpenVpnOptions = {
|
|
13
|
+
configPath: string;
|
|
14
|
+
routeHosts?: string[];
|
|
15
|
+
routeIps?: string[];
|
|
16
|
+
routeNoPull?: boolean;
|
|
17
|
+
};
|
|
18
|
+
export type StartWireGuardOptions = {
|
|
19
|
+
configPath: string;
|
|
20
|
+
};
|
|
21
|
+
export type TestkitPorts = {
|
|
22
|
+
mountCifsShare: (options: MountCifsShareOptions) => Promise<string>;
|
|
23
|
+
saveSnapshot?: SaveSnapshot;
|
|
24
|
+
startOpenVpn: (options: StartOpenVpnOptions) => Promise<string>;
|
|
25
|
+
startWireGuard: (options: StartWireGuardOptions) => Promise<string>;
|
|
26
|
+
};
|
|
27
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,qBAAqB,GAAG;IAClC,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG;IAC3B,UAAU,EAAE,CAAC,iBAAiB,CAAC,EAAE,OAAO,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;CAC9D,CAAC;AAEF,MAAM,MAAM,sBAAsB,GAAG,CACnC,aAAa,EAAE,cAAc,EAC7B,IAAI,EAAE,MAAM,EACZ,iBAAiB,CAAC,EAAE,OAAO,KACxB,OAAO,CAAC,IAAI,CAAC,CAAC;AAEnB,MAAM,MAAM,YAAY,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;AAE1E,MAAM,MAAM,mBAAmB,GAAG;IAChC,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IACtB,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB,CAAC;AAEF,MAAM,MAAM,qBAAqB,GAAG;IAClC,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG;IACzB,cAAc,EAAE,CAAC,OAAO,EAAE,qBAAqB,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;IACpE,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B,YAAY,EAAE,CAAC,OAAO,EAAE,mBAAmB,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;IAChE,cAAc,EAAE,CAAC,OAAO,EAAE,qBAAqB,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;CACrE,CAAC"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Page } from "playwright";
|
|
2
|
+
/**
|
|
3
|
+
* Screenshot the element at `selector` on `page` and decode the QR code it
|
|
4
|
+
* contains. Returns the decoded text, or `undefined` when no QR code is found.
|
|
5
|
+
*/
|
|
6
|
+
export declare function readQRCode(page: Page, selector: string): Promise<string | undefined>;
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/web/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAGvC;;;GAGG;AACH,wBAAsB,UAAU,CAC9B,IAAI,EAAE,IAAI,EACV,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAgB7B"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import jsQRPkg from "jsqr";
|
|
2
|
+
import pngjs from "pngjs";
|
|
3
|
+
/**
|
|
4
|
+
* Screenshot the element at `selector` on `page` and decode the QR code it
|
|
5
|
+
* contains. Returns the decoded text, or `undefined` when no QR code is found.
|
|
6
|
+
*/
|
|
7
|
+
export async function readQRCode(page, selector) {
|
|
8
|
+
const buffer = await page.locator(selector).screenshot();
|
|
9
|
+
const png = await new Promise((resolve, reject) => {
|
|
10
|
+
new pngjs.PNG().parse(Buffer.from(buffer), function (error, data) {
|
|
11
|
+
if (error)
|
|
12
|
+
reject(error);
|
|
13
|
+
else
|
|
14
|
+
resolve(data);
|
|
15
|
+
});
|
|
16
|
+
});
|
|
17
|
+
const code = jsQRPkg.default(Uint8ClampedArray.from(png.data), png.width, png.height);
|
|
18
|
+
return code?.data ?? undefined;
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/web/index.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,MAAM,CAAC;AAE3B,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,UAAU,CAC9B,IAAU,EACV,QAAgB;IAEhB,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,UAAU,EAAE,CAAC;IACzD,MAAM,GAAG,GAAG,MAAM,IAAI,OAAO,CAAY,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QAC3D,IAAI,KAAK,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,UAAU,KAAK,EAAE,IAAI;YAC9D,IAAI,KAAK;gBAAE,MAAM,CAAC,KAAK,CAAC,CAAC;;gBACpB,OAAO,CAAC,IAAI,CAAC,CAAC;QACrB,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,MAAM,IAAI,GAAG,OAAO,CAAC,OAAO,CAC1B,iBAAiB,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,EAChC,GAAG,CAAC,KAAK,EACT,GAAG,CAAC,MAAM,CACX,CAAC;IAEF,OAAO,IAAI,EAAE,IAAI,IAAI,SAAS,CAAC;AACjC,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@qawolf/testkit",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"private": false,
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"sideEffects": false,
|
|
7
|
+
"type": "module",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.js"
|
|
12
|
+
},
|
|
13
|
+
"./client": {
|
|
14
|
+
"types": "./dist/client.d.ts",
|
|
15
|
+
"import": "./dist/client.js"
|
|
16
|
+
},
|
|
17
|
+
"./web": {
|
|
18
|
+
"types": "./dist/web/index.d.ts",
|
|
19
|
+
"import": "./dist/web/index.js"
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
"types": "./dist/index.d.ts",
|
|
23
|
+
"files": [
|
|
24
|
+
"/dist",
|
|
25
|
+
"/LICENSE",
|
|
26
|
+
"/README.md"
|
|
27
|
+
],
|
|
28
|
+
"scripts": {
|
|
29
|
+
"build": "rm -rf ./dist && tsc -p tsconfig.build.json",
|
|
30
|
+
"lint:ci": "npm run lint:non-fixable; NON_FIXABLE_EXIT=$?; npm run lint:fixable && exit $NON_FIXABLE_EXIT",
|
|
31
|
+
"lint:dev": "npm run lint:fixable",
|
|
32
|
+
"lint:fixable": "eslint . --ext cjs,cts,js,jsx,mjs,ts,tsx --fix --quiet && prettier --log-level=warn --write .",
|
|
33
|
+
"lint:non-fixable": "dpdm --exit-code circular:1 --no-tree --no-warning --transform --include='.*' --exclude='/(dist|node_modules)/' '**/*'",
|
|
34
|
+
"prepublishOnly": "nx run testkit:build",
|
|
35
|
+
"test": "NODE_OPTIONS=\"--experimental-vm-modules\" NODE_NO_WARNINGS=1 jest",
|
|
36
|
+
"test:watch": "npm run test -- --watch",
|
|
37
|
+
"tsc:check": "tsc"
|
|
38
|
+
},
|
|
39
|
+
"dependencies": {
|
|
40
|
+
"jsqr": "^1.4.0",
|
|
41
|
+
"otpauth": "9.3.6",
|
|
42
|
+
"playwright": "1.58.2",
|
|
43
|
+
"pngjs": "^6.0.0",
|
|
44
|
+
"tslib": "^2.5.3"
|
|
45
|
+
},
|
|
46
|
+
"devDependencies": {
|
|
47
|
+
"@types/pngjs": "^6.0.5",
|
|
48
|
+
"typescript": "^5.9.2"
|
|
49
|
+
},
|
|
50
|
+
"engines": {
|
|
51
|
+
"node": ">=22.22.0 <25"
|
|
52
|
+
},
|
|
53
|
+
"nx": {
|
|
54
|
+
"targets": {
|
|
55
|
+
"npm:publish": {}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|