@haste-health/testscript-runner 0.127.0 → 0.127.2

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.
Files changed (2) hide show
  1. package/README.md +52 -0
  2. package/package.json +7 -7
package/README.md CHANGED
@@ -1 +1,53 @@
1
1
  # @haste-health/testscript-runner
2
+
3
+ Runs FHIR [TestScript](https://hl7.org/fhir/R4/testscript.html) resources against a FHIR server and returns a [TestReport](https://hl7.org/fhir/R4/testreport.html). It drives the server through [`@haste-health/client`](https://www.npmjs.com/package/@haste-health/client), so it works against any FHIR R4 or R4B endpoint, not only Haste Health.
4
+
5
+ The `testscript run` command of the Haste Health TypeScript CLI is built on it. Haste Health's own conformance suites run on the Rust equivalent, [haste-testscript-runner](https://crates.io/crates/haste-testscript-runner), and publish their reports on the conformance pages linked below.
6
+
7
+ ## Install
8
+
9
+ ```bash
10
+ npm install @haste-health/testscript-runner @haste-health/client pino
11
+ ```
12
+
13
+ ## Usage
14
+
15
+ ```ts
16
+ import pino from "pino";
17
+ import createHTTPClient from "@haste-health/client/http";
18
+ import { R4 } from "@haste-health/fhir-types/versions";
19
+ import { run } from "@haste-health/testscript-runner";
20
+
21
+ const client = createHTTPClient({
22
+ url: "http://localhost:3000/w/my-tenant/my-project/api/v1/fhir",
23
+ getAccessToken: async () => token,
24
+ });
25
+
26
+ const report = await run(pino(), client, R4, testScript);
27
+
28
+ report.result; // "pass" or "fail"
29
+ report.test?.[0].action; // one TestReport action per TestScript action, with a message per assert
30
+ ```
31
+
32
+ `run(logger, client, fhirVersion, testScript, timeout?)` resolves the fixtures, runs `setup`, then every `test`, and always runs `teardown`, even when a step throws. `timeout` is a pause in milliseconds inserted after each operation, useful against servers that index search results asynchronously.
33
+
34
+ ## Supported TestScript features
35
+
36
+ | Area | Support |
37
+ | ---------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
38
+ | Fixtures | `fixture.resource` pointing at a contained resource (`#id`) or one read from the server (`Type/id`); a `Binary` fixture may carry FHIR JSON or a JSON Patch |
39
+ | Operations | `read`, `vread`, `create`, `update`, `patch`, `delete`, `search`, `history`, `batch`, `transaction` and `invoke` (operation code in `url`, `Parameters` in `sourceId`), using `resource`, `params`, `sourceId` and `targetId` |
40
+ | Results | `responseId` and `requestId` store the exchange as fixtures; `sourceId`, `direction` or the latest response select what an assert looks at |
41
+ | Variables | `${name}` in operation values, resolved from `TestScript.variable` entries with `expression` (FHIRPath) and an optional `sourceId` |
42
+ | Asserts | `resource` (resource type) and `expression` (FHIRPath) compared with `value` or `compareToSourceId` + `compareToSourceExpression` using the FHIR operators `equals`, `notEquals`, `in`, `notIn`, `greaterThan`, `lessThan`, `empty`, `notEmpty`, `contains`, `notContains`, `eval` |
43
+
44
+ Variables that use `defaultValue`, `headerField` or `path` instead of `expression` are not supported and make the run throw an `OperationError` from [`@haste-health/operation-outcomes`](https://www.npmjs.com/package/@haste-health/operation-outcomes). Assert fields other than `resource` and `expression` (`responseCode`, `headerField`, `path`, `minimumId`, ...) are not evaluated, so an assert that relies only on them passes.
45
+
46
+ ## Links
47
+
48
+ - [API reference](https://typescript.haste.health/modules/_haste-health_testscript-runner.html)
49
+ - [Source](https://github.com/HasteHealth/HasteHealth/tree/main/frontend/packages/testscript-runner)
50
+ - [Conformance overview](https://haste.health/docs/reference/conformance/overview) and [test coverage](https://haste.health/docs/reference/conformance/test-coverage), the reports produced from Haste Health's TestScripts
51
+ - Rust equivalent: [haste-testscript-runner](https://crates.io/crates/haste-testscript-runner)
52
+
53
+ Part of [Haste Health](https://haste.health), licensed under [Apache-2.0](https://github.com/HasteHealth/HasteHealth/blob/main/LICENSE).
package/package.json CHANGED
@@ -1,22 +1,22 @@
1
1
  {
2
2
  "name": "@haste-health/testscript-runner",
3
- "version": "0.127.0",
3
+ "version": "0.127.2",
4
4
  "target": "node",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",
7
7
  "types": "lib/index.d.ts",
8
8
  "dependencies": {
9
9
  "pino": "^9.14.0",
10
- "@haste-health/client": "^0.127.0",
11
- "@haste-health/fhir-pointer": "^0.127.0",
12
- "@haste-health/operation-outcomes": "^0.127.0",
13
- "@haste-health/x-fhir-query": "^0.127.0",
14
- "@haste-health/fhirpath": "^0.127.0"
10
+ "@haste-health/client": "^0.127.2",
11
+ "@haste-health/fhirpath": "^0.127.2",
12
+ "@haste-health/x-fhir-query": "^0.127.2",
13
+ "@haste-health/fhir-pointer": "^0.127.2",
14
+ "@haste-health/operation-outcomes": "^0.127.2"
15
15
  },
16
16
  "description": "Haste Health TestScript Runner library for TypeScript. Provides functionality to run FHIR TestScripts.",
17
17
  "devDependencies": {
18
18
  "typescript": "6.0.3",
19
- "@haste-health/fhir-types": "^0.127.0"
19
+ "@haste-health/fhir-types": "^0.127.2"
20
20
  },
21
21
  "files": [
22
22
  "lib/**"