@diagonal-hq/cli 0.21.3 → 0.22.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 +23 -0
- package/dist/cli.mjs +772 -169
- package/dist/index.d.ts +23 -24
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1252,14 +1252,12 @@ type TestSignInTarget =
|
|
|
1252
1252
|
| ({ id: string } & Record<string, unknown>)
|
|
1253
1253
|
| { resource: string; id: string };
|
|
1254
1254
|
|
|
1255
|
-
/** `Sdk` in the test function.
|
|
1256
|
-
export type TestSdk
|
|
1255
|
+
/** `Sdk` in the test function. */
|
|
1256
|
+
export type TestSdk = {
|
|
1257
1257
|
/** The workspace that the run acts on. */
|
|
1258
1258
|
readonly workspace: { readonly id: string; readonly name: string; readonly baseUrl: string };
|
|
1259
1259
|
/** An absolute URL on the run's workspace. */
|
|
1260
1260
|
url(path?: string): string;
|
|
1261
|
-
/** The object that setup returned, or `{}` without a setup function. */
|
|
1262
|
-
readonly setup: S;
|
|
1263
1261
|
/** Signs `page` in as a record that setup returned, or as `{ resource, id }`, then opens `redirectTo` (default `/`). */
|
|
1264
1262
|
loginAs(record: TestSignInTarget, options?: { redirectTo?: string }): Promise<void>;
|
|
1265
1263
|
/** Opens a second browser signed in as another record and returns its page. */
|
|
@@ -1293,39 +1291,40 @@ export type TestSdk<S> = {
|
|
|
1293
1291
|
};
|
|
1294
1292
|
|
|
1295
1293
|
/** The values that the runner gives the test function. */
|
|
1296
|
-
export type TestFixtures<
|
|
1294
|
+
export type TestFixtures<C> = {
|
|
1297
1295
|
page: import('@playwright/test').Page;
|
|
1298
1296
|
context: import('@playwright/test').BrowserContext;
|
|
1299
1297
|
request: import('@playwright/test').APIRequestContext;
|
|
1300
1298
|
browser: import('@playwright/test').Browser;
|
|
1301
1299
|
expect: import('@playwright/test').Expect;
|
|
1302
|
-
Sdk: TestSdk
|
|
1300
|
+
Sdk: TestSdk;
|
|
1301
|
+
/** The object that setup returned, or `{}` without a setup function. A change to it reaches assert. */
|
|
1302
|
+
ctx: C;
|
|
1303
1303
|
};
|
|
1304
1304
|
|
|
1305
1305
|
/**
|
|
1306
|
-
* The functions of a test.
|
|
1307
|
-
*
|
|
1308
|
-
*
|
|
1309
|
-
*
|
|
1310
|
-
*
|
|
1311
|
-
*
|
|
1306
|
+
* The functions of a test. They share one ctx: setup gets it empty, and the object that setup
|
|
1307
|
+
* returns is the ctx of the test function and of assert. A change that the test function makes to
|
|
1308
|
+
* ctx reaches assert. The run sends ctx between them as JSON.
|
|
1309
|
+
*
|
|
1310
|
+
* `setup` and `assert` run once in the test workspace as embedded scripts, as the acting account,
|
|
1311
|
+
* with the `test` script profile. To act as another identity, call `workflow.run` with a workflow
|
|
1312
|
+
* that sets Run As. `test` runs in the browser runner as the body of a Playwright test, so it can
|
|
1313
|
+
* use only its fixtures: no import or helper of its file.
|
|
1312
1314
|
*/
|
|
1313
|
-
export type TestHandlers<
|
|
1314
|
-
/** Creates the records that the test needs and returns them.
|
|
1315
|
-
setup?: (
|
|
1316
|
-
test: (fixtures: TestFixtures<Awaited<
|
|
1317
|
-
/**
|
|
1318
|
-
|
|
1319
|
-
* the object that `setup` returned, or `{}` without a setup.
|
|
1320
|
-
*/
|
|
1321
|
-
assert?: (setup: Awaited<S>, ctx: WorkflowContext) => void | Promise<void>;
|
|
1315
|
+
export type TestHandlers<C> = {
|
|
1316
|
+
/** Creates the records that the test needs and returns them. They become ctx. */
|
|
1317
|
+
setup?: (ctx: Record<string, unknown>) => C | Promise<C>;
|
|
1318
|
+
test: (fixtures: TestFixtures<Awaited<C>>) => Promise<void>;
|
|
1319
|
+
/** Reads the records after the test, and calls `fail(...)` when a value is wrong. */
|
|
1320
|
+
assert?: (ctx: Awaited<C>) => void | Promise<void>;
|
|
1322
1321
|
};
|
|
1323
1322
|
|
|
1324
1323
|
/**
|
|
1325
1324
|
* The default export of `tests/<suite>/<key>.ts`, one E2E test of the suite in the folder. The
|
|
1326
1325
|
* file name is the test key.
|
|
1327
1326
|
*/
|
|
1328
|
-
export declare function defineTest<
|
|
1327
|
+
export declare function defineTest<C = {}>(
|
|
1329
1328
|
config: TestConfig,
|
|
1330
|
-
handlers: TestHandlers<
|
|
1331
|
-
): { readonly config: TestConfig } & TestHandlers<
|
|
1329
|
+
handlers: TestHandlers<C>
|
|
1330
|
+
): { readonly config: TestConfig } & TestHandlers<C>;
|