@nikhil-qeas/api-core 0.6.0 → 0.8.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.
Files changed (66) hide show
  1. package/CHANGELOG.md +67 -0
  2. package/README.md +216 -5
  3. package/bin/qe-api.js +3 -0
  4. package/dist/contracts/assertions.d.ts +11 -0
  5. package/dist/contracts/assertions.js +31 -0
  6. package/dist/contracts/openapi.d.ts +28 -1
  7. package/dist/contracts/openapi.js +113 -0
  8. package/dist/graphql/graphql.d.ts +86 -0
  9. package/dist/graphql/graphql.js +312 -0
  10. package/dist/http/api-client.d.ts +20 -0
  11. package/dist/http/api-client.js +70 -9
  12. package/dist/http/cookies.d.ts +32 -0
  13. package/dist/http/cookies.js +116 -0
  14. package/dist/http/multipart.d.ts +20 -0
  15. package/dist/http/multipart.js +48 -0
  16. package/dist/http/trace.d.ts +26 -0
  17. package/dist/http/trace.js +43 -0
  18. package/dist/http/types.d.ts +22 -0
  19. package/dist/index.d.ts +31 -5
  20. package/dist/index.js +16 -3
  21. package/dist/integrations/mocha.d.ts +32 -0
  22. package/dist/integrations/mocha.js +81 -0
  23. package/dist/reporting/html-report.d.ts +23 -0
  24. package/dist/reporting/html-report.js +118 -0
  25. package/dist/reporting/junit.d.ts +11 -2
  26. package/dist/reporting/junit.js +9 -3
  27. package/dist/reporting/redaction.d.ts +10 -0
  28. package/dist/reporting/redaction.js +36 -2
  29. package/dist/security/authorization-matrix.d.ts +55 -0
  30. package/dist/security/authorization-matrix.js +102 -0
  31. package/dist/security/headers.d.ts +21 -0
  32. package/dist/security/headers.js +45 -0
  33. package/dist/security/policy.js +3 -2
  34. package/dist/security/sensitive-data.d.ts +22 -0
  35. package/dist/security/sensitive-data.js +76 -0
  36. package/dist/testing/json-path.d.ts +6 -0
  37. package/dist/testing/json-path.js +97 -0
  38. package/dist/testing/load.d.ts +85 -0
  39. package/dist/testing/load.js +134 -0
  40. package/dist/testing/matchers.d.ts +63 -0
  41. package/dist/testing/matchers.js +164 -0
  42. package/dist/testing/spec-cases.d.ts +136 -0
  43. package/dist/testing/spec-cases.js +1065 -0
  44. package/dist/testing/wait-for.d.ts +40 -0
  45. package/dist/testing/wait-for.js +82 -0
  46. package/package.json +1 -1
  47. package/templates/project/README.md +80 -5
  48. package/templates/project/__dot__env.example +4 -0
  49. package/templates/project/__dot__gitlab-ci.yml +1 -0
  50. package/templates/project/openapi/openapi.json +476 -19
  51. package/templates/project/src/clients/api.ts +4 -2
  52. package/templates/project/src/environment.ts +8 -0
  53. package/templates/project/src/observability.ts +15 -1
  54. package/templates/project/tests/negative/spec-cases.spec.ts +48 -0
  55. package/templates/project/tests/performance/health.spec.ts +22 -0
  56. package/templates/project/tests/security/authentication.spec.ts +3 -1
  57. package/templates/project/tests/security/authorization.spec.ts +29 -0
  58. package/templates/project/tests/security/hygiene.spec.ts +37 -0
  59. package/templates/project/tests/security/spec-cases.spec.ts +61 -0
  60. package/templates/project/tests/security/write-protection.spec.ts +2 -2
  61. package/templates/project/tests/setup/hooks.ts +32 -5
  62. package/templates/project/tests/smoke/health.spec.ts +3 -3
  63. package/templates/project/tests/smoke/tracing.spec.ts +48 -0
  64. package/templates/project/tests/support/approved-writes.ts +27 -0
  65. package/templates/project/tests/support/identities.ts +24 -0
  66. package/templates/project/tests/support/mock-api.ts +166 -3
@@ -0,0 +1,40 @@
1
+ import type { ClientClock } from '../http/retry.js';
2
+ /** Thrown when the condition did not become true in time. The message never includes results: see `lastValue` and `lastError` for debugging. */
3
+ export declare class WaitTimeoutError extends Error {
4
+ readonly attempts: number;
5
+ readonly elapsedMs: number;
6
+ readonly lastValue: unknown;
7
+ readonly lastError: unknown;
8
+ constructor(message: string, attempts: number, elapsedMs: number, lastValue: unknown, lastError: unknown);
9
+ }
10
+ export interface WaitForOptions<T> {
11
+ /** Give up after this long. Default 10000. */
12
+ timeoutMs?: number | undefined;
13
+ /** First wait between attempts. Default 250. */
14
+ intervalMs?: number | undefined;
15
+ /** Upper bound for the wait when it grows. Default 2000. */
16
+ maxIntervalMs?: number | undefined;
17
+ /** Multiplies the wait after each attempt. Default 1: a constant interval. */
18
+ backoffFactor?: number | undefined;
19
+ /** Give up after this many attempts, whatever the time. */
20
+ maxAttempts?: number | undefined;
21
+ /** What is being waited for, for the timeout message: "the export job to finish". */
22
+ description?: string | undefined;
23
+ /** A safe summary of a result for the timeout message, e.g. `response => \`HTTP ${response.status}\``. Results are never printed otherwise. */
24
+ describe?: ((value: T) => string) | undefined;
25
+ /** Treat an error thrown by the attempt as "not yet" (true, or a predicate choosing which errors). Default false: errors propagate at once. */
26
+ retryOnError?: boolean | ((error: unknown) => boolean) | undefined;
27
+ signal?: AbortSignal | undefined;
28
+ /** Replace to run waits instantly and deterministically in tests. */
29
+ clock?: ClientClock | undefined;
30
+ }
31
+ /**
32
+ * Polls until a condition holds, for eventually consistent APIs: a job that finishes later, a record that appears after a delay,
33
+ * a cache that expires. Returns the first value `until` accepts, or throws `WaitTimeoutError`.
34
+ *
35
+ * ```ts
36
+ * const job = await waitFor(() => api.request({ method: 'GET', path: `/jobs/${id}` }), r => r.body.state === 'done',
37
+ * { description: 'the job to finish', describe: r => `HTTP ${r.status}`, timeoutMs: 30_000 });
38
+ * ```
39
+ */
40
+ export declare function waitFor<T>(attempt: () => T | Promise<T>, until: (value: T) => boolean | Promise<boolean>, options?: WaitForOptions<T>): Promise<T>;
@@ -0,0 +1,82 @@
1
+ import { systemClock } from '../http/retry.js';
2
+ /** Thrown when the condition did not become true in time. The message never includes results: see `lastValue` and `lastError` for debugging. */
3
+ export class WaitTimeoutError extends Error {
4
+ attempts;
5
+ elapsedMs;
6
+ lastValue;
7
+ lastError;
8
+ constructor(message, attempts, elapsedMs, lastValue, lastError) {
9
+ super(message);
10
+ this.attempts = attempts;
11
+ this.elapsedMs = elapsedMs;
12
+ this.lastValue = lastValue;
13
+ this.lastError = lastError;
14
+ this.name = 'WaitTimeoutError';
15
+ }
16
+ }
17
+ function nonNegative(value, fallback, name) {
18
+ const resolved = value ?? fallback;
19
+ if (!Number.isFinite(resolved) || resolved < 0)
20
+ throw new Error(`Invalid waitFor option: ${name} must be a non-negative number`);
21
+ return resolved;
22
+ }
23
+ function sleepUnlessAborted(clock, ms, signal) {
24
+ if (!signal)
25
+ return clock.sleep(ms);
26
+ return new Promise((resolve, reject) => {
27
+ const onAbort = () => reject(signal.reason instanceof Error ? signal.reason : new Error('waitFor was aborted'));
28
+ signal.addEventListener('abort', onAbort, { once: true });
29
+ clock.sleep(ms).then(() => { signal.removeEventListener('abort', onAbort); resolve(); }, (error) => { signal.removeEventListener('abort', onAbort); reject(error instanceof Error ? error : new Error('waitFor sleep failed')); });
30
+ });
31
+ }
32
+ /**
33
+ * Polls until a condition holds, for eventually consistent APIs: a job that finishes later, a record that appears after a delay,
34
+ * a cache that expires. Returns the first value `until` accepts, or throws `WaitTimeoutError`.
35
+ *
36
+ * ```ts
37
+ * const job = await waitFor(() => api.request({ method: 'GET', path: `/jobs/${id}` }), r => r.body.state === 'done',
38
+ * { description: 'the job to finish', describe: r => `HTTP ${r.status}`, timeoutMs: 30_000 });
39
+ * ```
40
+ */
41
+ export async function waitFor(attempt, until, options = {}) {
42
+ const clock = options.clock ?? systemClock;
43
+ const timeoutMs = nonNegative(options.timeoutMs, 10_000, 'timeoutMs');
44
+ const maxInterval = nonNegative(options.maxIntervalMs, 2_000, 'maxIntervalMs');
45
+ const factor = nonNegative(options.backoffFactor, 1, 'backoffFactor');
46
+ let interval = nonNegative(options.intervalMs, 250, 'intervalMs');
47
+ const maxAttempts = options.maxAttempts === undefined ? Number.POSITIVE_INFINITY : nonNegative(options.maxAttempts, 0, 'maxAttempts');
48
+ const started = clock.now();
49
+ let attempts = 0;
50
+ let lastValue;
51
+ let lastError;
52
+ let hasValue = false;
53
+ for (;;) {
54
+ options.signal?.throwIfAborted();
55
+ attempts++;
56
+ try {
57
+ const value = await attempt();
58
+ lastValue = value;
59
+ hasValue = true;
60
+ lastError = undefined;
61
+ if (await until(value))
62
+ return value;
63
+ }
64
+ catch (error) {
65
+ const retry = options.retryOnError === true || (typeof options.retryOnError === 'function' && options.retryOnError(error));
66
+ if (!retry)
67
+ throw error;
68
+ lastError = error;
69
+ }
70
+ const elapsed = clock.now() - started;
71
+ if (elapsed >= timeoutMs || attempts >= maxAttempts) {
72
+ let message = `Timed out after ${Math.round(elapsed)}ms and ${attempts} attempt${attempts === 1 ? '' : 's'} waiting for ${options.description ?? 'the condition to hold'}`;
73
+ if (lastError !== undefined)
74
+ message += `; the last attempt failed with ${lastError instanceof Error ? lastError.name : 'an error'}`;
75
+ else if (hasValue && options.describe)
76
+ message += `; the last result was ${options.describe(lastValue)}`;
77
+ throw new WaitTimeoutError(message, attempts, Math.round(elapsed), lastValue, lastError);
78
+ }
79
+ await sleepUnlessAborted(clock, Math.min(interval, timeoutMs - elapsed), options.signal); // never sleep past the deadline
80
+ interval = Math.min(maxInterval, interval * factor);
81
+ }
82
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nikhil-qeas/api-core",
3
- "version": "0.6.0",
3
+ "version": "0.8.0",
4
4
  "description": "Reusable TypeScript API automation core with HTTP, auth, OpenAPI adapter, test isolation, reporting and CI",
5
5
  "private": false,
6
6
  "type": "module",
@@ -17,12 +17,13 @@ The sample tests start a local mock API (`tests/support/mock-api.ts`) and need n
17
17
  |---|---|
18
18
  | `openapi/openapi.json` | The API's OpenAPI document. **Replace it with your API's spec**: contract checks and coverage both read it. |
19
19
  | `src/clients/api.ts` | `createApiClient()`: read-only unless writes are approved, retries with backoff and `Retry-After`, OAuth2 when `OAUTH_*` is set, metrics and coverage hooks. |
20
- | `src/environment.ts` | Reads `API_BASE_URL`, the optional `OAUTH_*` settings, and the write-protection policy (`QE_ENV`, `QE_ALLOW_MUTATIONS`, `QE_APPROVAL`). |
20
+ | `src/environment.ts` | Reads `API_BASE_URL`, the optional `OAUTH_*` settings, the write-protection policy (`QE_ENV`, `QE_ALLOW_MUTATIONS`, `QE_APPROVAL`) and `QE_TRACE`. |
21
21
  | `src/openapi.ts` | Loads the spec and builds the Ajv-backed contract validator. |
22
- | `src/observability.ts` | Run-wide metrics and OpenAPI coverage collectors. |
23
- | `tests/smoke`, `contract`, `security` | Working samples. Any `tests/**/*.spec.ts` is picked up, so add folders such as `tests/regression` or `tests/negative` when you need them. |
24
- | `tests/setup/hooks.ts` | After the run: writes `reports/coverage/api.md` and `api.json` and can enforce a minimum. |
22
+ | `src/observability.ts` | Run-wide metrics and OpenAPI coverage collectors, and the trace id of the running test. |
23
+ | `tests/smoke`, `contract`, `security`, `negative`, `performance` | Working samples. Any `tests/**/*.spec.ts` is picked up, so add folders such as `tests/regression` or `tests/negative` when you need them. |
24
+ | `tests/setup/hooks.ts` | Mocha root hooks: a trace per test, each test's outcome for the HTML report, and after the run `reports/html/index.html`, `reports/coverage/api.md` and `api.json` (and a minimum, if you set one). |
25
25
  | `tests/support/mock-api.ts` | The local mock API and token endpoint the samples use. Delete it once you test a real environment. |
26
+ | `tests/support/approved-writes.ts`, `identities.ts` | Helpers for the generated suites: run a suite with writes approved for the mock, and send requests as one test identity (or as nobody). |
26
27
  | `.mocharc.json` | Mocha settings: TypeScript specs under `tests/`, the setup hooks, a 30 second timeout. |
27
28
  | `.env.example` | Every setting, with comments. Copy to `.env` locally; use your CI secret store in pipelines. |
28
29
 
@@ -33,11 +34,27 @@ The sample tests start a local mock API (`tests/support/mock-api.ts`) and need n
33
34
  | Command | What it does |
34
35
  |---|---|
35
36
  | `npm test` | Every test. |
36
- | `npm run test:smoke` / `test:contract` / `test:security` | Tests whose title contains `@smoke` / `@contract` / `@security`. Tag your own `describe` titles the same way. |
37
+ | `npm run test:smoke` / `test:contract` / `test:security` / `test:negative` / `test:fuzz` / `test:performance` | Tests whose title contains `@smoke` / `@contract` / `@security` / `@negative` / `@fuzz` / `@performance`. Tag your own `describe` titles the same way. |
37
38
  | `npm run test:ci` | Everything, with JUnit XML in `reports/junit/results.xml` for the pipeline. |
38
39
  | `npm run lint` | ESLint with type-aware rules: an unawaited request is a check that silently never runs. |
39
40
  | `npm run audit:security` | `npm audit` for high-severity advisories. |
40
41
 
42
+ ## Reports
43
+
44
+ Every run writes these (`reports/` is created by the run and is git-ignored; the pipeline keeps it as a job artifact):
45
+
46
+ | File | What it is |
47
+ |---|---|
48
+ | `reports/html/index.html` | One page to open in a browser: the verdict, failures first (with the message, and the trace id when `QE_TRACE=true`), tests that only passed after retries, the slowest tests, every test by suite, and the API coverage and request figures. It is self-contained: no scripts, nothing loaded from anywhere. |
49
+ | `reports/junit/results.xml` | `npm run test:ci` only: JUnit XML for the pipeline's test report. |
50
+ | `reports/coverage/api.md`, `api.json` | Which operations and documented responses of the spec the run exercised. |
51
+
52
+ **Retries and flaky tests.** `npm run test:ci -- --retries 2` runs a failing test again, up to twice (Mocha reads `--retries` from its configuration; setting it from a hook does nothing). A test that fails and then passes is not hidden: the HTML report lists it under "Passed only after retries" with the number of retries it needed. That is a flaky test to fix, not a pass to trust.
53
+
54
+ **A failed hook is not a test.** If a `before` or `after` hook fails, the tests it guards never run and have no entry, so the report names the failed hooks and says FAILED, whatever the listed tests did. Tests marked `it.skip` are not listed either (Mocha runs no hook for them).
55
+
56
+ **What a failure message can contain.** Messages are scrubbed of credentials and cut to 40 lines and 2000 characters, but an assertion that compares two bodies prints both, so a message can still quote data. The console and the JUnit report show the same text. To leave messages out of the HTML report, remove `messages: true` in `tests/setup/hooks.ts`.
57
+
41
58
  ## Contract checks and coverage
42
59
 
43
60
  ```ts
@@ -47,6 +64,64 @@ contract.assertResponse({ method: 'GET', path: '/accounts/{id}', status: respons
47
64
 
48
65
  Use the spec's path template, not the concrete URL. After every run `reports/coverage/api.md` lists the operations and documented responses the suite exercised, responses the API returned that the spec does not declare, and requests that match no operation. Set `QE_COVERAGE_MIN_OPERATIONS=80` on full runs to fail when coverage drops. Coverage counts requests, not passes.
49
66
 
67
+ ## Writing your own tests
68
+
69
+ The framework ships helpers for the things API tests keep needing. The sample smoke test uses two of them; the package README (`node_modules/@nikhil-qeas/api-core/README.md`) documents all of them.
70
+
71
+ ```ts
72
+ import { match, waitFor, expectBody, expectHeader, expectJsonPath } from '@nikhil-qeas/api-core';
73
+
74
+ expectBody(response, { id: match.uuid(), status: 'open', createdAt: match.dateTime() }); // objects only need to contain what you list
75
+ expectJsonPath(response, '$.items[*].price', match.number({ min: 0 }));
76
+ expectHeader(response, 'content-type', /^application\/json/);
77
+
78
+ const done = await waitFor(() => api.request({ method: 'GET', path: `/jobs/${id}` }), r => r.body.state === 'done', { description: 'the job to finish' });
79
+ ```
80
+
81
+ `createApiClient(baseUrl, { cookies: true })` keeps session cookies, `multipart: [...]` uploads files, and `responseType: 'binary'` downloads them.
82
+
83
+ ## Negative and fuzz tests
84
+
85
+ `tests/negative/spec-cases.spec.ts` generates test cases from `openapi/openapi.json`, so they follow your spec when you replace it:
86
+
87
+ - **`@negative`**: requests that each break exactly one rule of the spec (a missing required field, the wrong type, a string too long, a bad format or enum value, a number out of range, a missing parameter, malformed JSON, an unsupported content type). Every one must be rejected with a 4xx, and a valid request must be accepted. The failure message names the rule: `body.name is shorter than minLength 1 (body.name: minLength): invalid input was accepted with HTTP 201`.
88
+ - **`@fuzz`**: hostile and extreme values in every string and number field (injection strings, null bytes, unicode tricks, huge and odd numbers, 200-level nesting, a `__proto__` key). The API must answer without failing; 2xx and 4xx are both fine, a 5xx is a defect. The choice of cases is reproducible (seeded) and capped per operation.
89
+
90
+ If the generator cannot invent a valid value (a business rule, a complex pattern), supply known-good ones: `new OpenApiCases(loadSpec(), { baselines: { 'POST /accounts': { json: { name: 'Savings', currency: 'EUR' } } } })`. Form (`application/x-www-form-urlencoded`) and multipart bodies get cases too, built from text-aware values: the sample's `POST /oauth/token` is a form and `POST /accounts/{id}/documents` is a multipart upload with a file. XML bodies, and form or multipart bodies with a required nested object, get parameter cases only.
91
+
92
+ **These cases send writes and hostile payloads.** The sample suite approves writes for itself because it runs against the local mock. Against a real environment, approve writes (`QE_ALLOW_MUTATIONS=true` and `QE_APPROVAL=approved`) in the shell or CI job, only for an environment where that is acceptable, and never in production.
93
+
94
+ ## Security tests
95
+
96
+ Everything under `tests/security` is tagged `@security` (`npm run test:security`):
97
+
98
+ - **`spec-cases.spec.ts`: authentication, generated from the spec.** Every operation the spec protects (`security` on the operation, or on the document and not overridden with `security: []`) must refuse a request with no credentials, an invalid bearer token or API key (in the header, query or cookie the spec names), an empty token, and credentials of the wrong type, using 401 or 403. A server that only checks that an `Authorization` header exists fails. Declare the schemes under `components.securitySchemes`.
99
+ - **`spec-cases.spec.ts`: mass assignment, generated from the spec.** A client must not be able to set what the server owns. The suite sends each read-only property the spec declares (`accountNumber` in the sample) with a distinctive value, and, unless the spec forbids extra properties, privileged names such as `isAdmin`, `role` and `ownerId`. The API must reject the request or ignore the properties; the test fails when a response returns a value that was sent, and says which property. A response that merely mirrors the request body is flagged too.
100
+ - **`spec-cases.spec.ts`: server-side request forgery, generated from the spec.** Every field that holds an address (a `uri` format, or a name such as `url`, `callback`, `webhook` or `redirect`; `webhookUrl` in the sample) is sent the cloud metadata address, loopback and private addresses, and a local file. The API must answer with a 4xx. If an API deliberately checks addresses only when it fetches them, these cases will fail: skip that suite. Against a vulnerable API the server really contacts those addresses, so run them only against an environment that may be probed.
101
+ - **`authorization.spec.ts`: who may do what.** `AuthorizationMatrix` sends each rule's request as each identity and compares the status, covering function-level checks (a normal user calling an admin operation) and object-level checks (user B reading user A's data; add `deniedStatuses: [403, 404]` when the API hides what exists). Refusals are checked first, and a failure prints a table of statuses.
102
+ - **`hygiene.spec.ts`: what a response gives away.** `expectSecurityHeaders` checks `X-Content-Type-Options`, `Strict-Transport-Security` (with `https: true`), `Cache-Control: no-store` (with `sensitive: true`), version leaks in `Server` and `X-Powered-By`, and wildcard CORS. `expectNoSensitiveData` finds properties named like secrets that carry a value, and values that look like JWTs, private keys, cloud keys or card numbers (`allowKeys` for what belongs, such as `access_token` on a login response). Failures name the header or path, never its value.
103
+
104
+ The mock API's test identities (`tests/support/identities.ts`) stand in for the test accounts of your environment. Like the negative cases, these send requests an API should refuse, so run them only against environments where that is acceptable.
105
+
106
+ ## Performance smoke tests
107
+
108
+ `tests/performance/health.spec.ts` sends 50 requests, 5 at a time, and fails when the 95th percentile is above a budget or any request fails:
109
+
110
+ ```ts
111
+ const report = await runLoad(() => api.request({ method: 'GET', path: '/accounts/42' }), { requests: 50, concurrency: 5 });
112
+ expectLoad(report, { p95Ms: 300, maxErrorRate: 0.02 });
113
+ ```
114
+
115
+ A few warm-up requests go first and are left out of the figures. Failures are counted by status and error name, never by body, and the run stops early after 25 failures so a broken endpoint is not hammered. Because the requests go through `createApiClient()`, the read-only default applies: a write load is refused before anything is sent. This is a smoke test, capped at 1000 requests and 50 at a time; use k6 or Gatling for real load, and keep even this to test environments. Run it with `npm run test:performance`. The sample's limits are generous so it passes anywhere: set yours from what the API promises.
116
+
117
+ ## Tracing
118
+
119
+ Set `QE_TRACE=true` and every request carries a W3C `traceparent` header. Each test gets its own trace id (a root hook in `tests/setup/hooks.ts` starts one before every test), every request of that test joins it, and each attempt of a retried request is its own span of the same trace. When a test fails, its trace id is printed right after it: search for that id in the API's tracing backend (Jaeger, Tempo, Datadog, ...) to see what the server did. `tests/smoke/tracing.spec.ts` shows it against the mock API. This propagates trace context so the server side can correlate; it does not export spans, and it only helps if the API under test joins incoming traces. It is off by default because it adds a header to every request. To correlate with logs instead, `createApiClient` accepts `requestIdHeader: 'X-Request-Id'`, which sends each request's id (`result.requestId`) in that header.
120
+
121
+ ## GraphQL
122
+
123
+ `GraphQLClient` wraps the generated client: `new GraphQLClient(createApiClient()).execute({ query, variables })`, then `expectGraphQLSuccess(result)` or `expectGraphQLError(result, { code: 'FORBIDDEN' })`. A GraphQL query is a POST, but the client proves from the document that it is a query, so it is allowed in the default read-only run. A mutation is refused before it is sent, with the same read-only error as any other write, until you approve writes (see Safety below). `result.errors` matters as much as the status: a failed request is often HTTP 200. GraphQL APIs have no OpenAPI document, so their requests are listed as matching no operation in `reports/coverage/api.md`; that does not fail a run. The package README documents the details.
124
+
50
125
  ## Authentication
51
126
 
52
127
  Set `OAUTH_TOKEN_URL`, `OAUTH_CLIENT_ID`, `OAUTH_CLIENT_SECRET` (and optionally `OAUTH_SCOPE`) and `createApiClient()` sends a bearer token automatically. When the server answers 401 the client renews the token and resends once. Use `skipAuth: true` or your own `Authorization` header on a request for negative tests. `tests/security/authentication.spec.ts` shows both against the mock API.
@@ -15,5 +15,9 @@ QE_ALLOW_MUTATIONS=false
15
15
  # OAUTH_CLIENT_SECRET=
16
16
  # OAUTH_SCOPE=
17
17
 
18
+ # Send a W3C traceparent header with every request, one trace per test, so a failed test can be found in the API's tracing backend.
19
+ # The trace id of a failed test is printed right after it. Off by default.
20
+ # QE_TRACE=true
21
+
18
22
  # Fail the run when fewer than this percentage of OpenAPI operations were exercised (use on full runs only).
19
23
  # QE_COVERAGE_MIN_OPERATIONS=80
@@ -23,3 +23,4 @@ test:
23
23
  paths:
24
24
  - reports/junit/
25
25
  - reports/coverage/
26
+ - reports/html/