Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 13 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,12 @@ if (!result.valid) {
result.errors?.forEach(err => console.error(err.message))
}

// Validate against a published historical schema
const historicalResult = validate(report, { specVersion: '0.0.2' })

// `latest` is an alias for the current published specification
validateStrict(report, { specVersion: 'latest' })

// Strict validation (throws on invalid)
try {
validateStrict(report)
Expand Down Expand Up @@ -247,8 +253,8 @@ import {
} from 'ctrf'

REPORT_FORMAT // 'CTRF'
CURRENT_SPEC_VERSION // '0.0.0'
SUPPORTED_SPEC_VERSIONS // ['0.0.0']
CURRENT_SPEC_VERSION // '0.1.0'
SUPPORTED_SPEC_VERSIONS // ['0.0.1', '0.0.2', '0.0.3', '0.0.4', '0.1.0']
TEST_STATUSES // ['passed', 'failed', 'skipped', 'pending', 'other']
CTRF_NAMESPACE // UUID namespace for deterministic IDs
```
Expand Down Expand Up @@ -283,10 +289,11 @@ import { schema, getSchema, getCurrentSpecVersion, getSupportedSpecVersions } fr
// Get the current JSON Schema
console.log(schema)

// Get schema for specific version
const v0_0Schema = getSchema('0.0.0')
// Get schemas for a specific version or the latest published specification
const v0_0_2Schema = getSchema('0.0.2')
const latestSchema = getSchema('latest')

// Get version info
const version = getCurrentSpecVersion() // '0.0.0'
const supported = getSupportedSpecVersions() // ['0.0.0']
const version = getCurrentSpecVersion() // '0.1.0'
const supported = getSupportedSpecVersions() // ['0.0.1', '0.0.2', '0.0.3', '0.0.4', '0.1.0']
```
2 changes: 1 addition & 1 deletion docs/classes/ReportBuilder.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Defined in: [builder.ts:50](https://github.com/ctrf-io/ctrf-js/blob/main/src/bui

```typescript
const report = new ReportBuilder()
.specVersion('1.0.0')
.specVersion('0.1.0')
.tool({ name: 'jest', version: '29.0.0' })
.environment({ branchName: 'main' })
.addTest(
Expand Down
2 changes: 1 addition & 1 deletion docs/functions/getCurrentSpecVersion.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

> **getCurrentSpecVersion**(): `string`

Defined in: [schema.ts:88](https://github.com/ctrf-io/ctrf-js/blob/main/src/schema.ts#L88)
Defined in: [schema.ts:93](https://github.com/ctrf-io/ctrf-js/blob/main/src/schema.ts#L93)

## Returns

Expand Down
10 changes: 5 additions & 5 deletions docs/functions/getSchema.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@

> **getSchema**(`version`): `object`

Defined in: [schema.ts:69](https://github.com/ctrf-io/ctrf-js/blob/main/src/schema.ts#L69)
Defined in: [schema.ts:82](https://github.com/ctrf-io/ctrf-js/blob/main/src/schema.ts#L82)

## Parameters

### version

`string`
[`SchemaSelector`](../type-aliases/SchemaSelector.md)

The spec version (MAJOR.MINOR.PATCH) to get the schema for
A supported spec version or `latest`

## Returns

Expand All @@ -31,6 +31,6 @@ SchemaVersionError if the version is not supported
## Example

```typescript
const v0_0Schema = getSchema('0.0.0');
const v1_0Schema = getSchema('1.0.0');
const historicalSchema = getSchema('0.0.2');
const latestSchema = getSchema('latest');
```
2 changes: 1 addition & 1 deletion docs/functions/getSupportedSpecVersions.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

> **getSupportedSpecVersions**(): readonly `string`[]

Defined in: [schema.ts:99](https://github.com/ctrf-io/ctrf-js/blob/main/src/schema.ts#L99)
Defined in: [schema.ts:104](https://github.com/ctrf-io/ctrf-js/blob/main/src/schema.ts#L104)

## Returns

Expand Down
2 changes: 1 addition & 1 deletion docs/functions/hasInsights.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

> **hasInsights**(`report`): `boolean`

Defined in: [validate.ts:285](https://github.com/ctrf-io/ctrf-js/blob/main/src/validate.ts#L285)
Defined in: [validate.ts:315](https://github.com/ctrf-io/ctrf-js/blob/main/src/validate.ts#L315)

## Parameters

Expand Down
2 changes: 1 addition & 1 deletion docs/functions/isAttemptHistoryEntry.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

> **isAttemptHistoryEntry**(`obj`): `obj is AttemptHistoryEntry`

Defined in: [validate.ts:255](https://github.com/ctrf-io/ctrf-js/blob/main/src/validate.ts#L255)
Defined in: [validate.ts:285](https://github.com/ctrf-io/ctrf-js/blob/main/src/validate.ts#L285)

## Parameters

Expand Down
2 changes: 1 addition & 1 deletion docs/functions/isCTRFReport.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

> **isCTRFReport**(`report`): `report is { reportFormat: "CTRF" }`

Defined in: [validate.ts:196](https://github.com/ctrf-io/ctrf-js/blob/main/src/validate.ts#L196)
Defined in: [validate.ts:226](https://github.com/ctrf-io/ctrf-js/blob/main/src/validate.ts#L226)

## Parameters

Expand Down
2 changes: 1 addition & 1 deletion docs/functions/isRetryAttempt.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

> **isRetryAttempt**(`obj`): `obj is AttemptHistoryEntry`

Defined in: [validate.ts:273](https://github.com/ctrf-io/ctrf-js/blob/main/src/validate.ts#L273)
Defined in: [validate.ts:303](https://github.com/ctrf-io/ctrf-js/blob/main/src/validate.ts#L303)

Backward-compatible alias for [isAttemptHistoryEntry](isAttemptHistoryEntry.md).

Expand Down
2 changes: 1 addition & 1 deletion docs/functions/isTest.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

> **isTest**(`obj`): `obj is { name: string; status: string; duration: number }`

Defined in: [validate.ts:215](https://github.com/ctrf-io/ctrf-js/blob/main/src/validate.ts#L215)
Defined in: [validate.ts:245](https://github.com/ctrf-io/ctrf-js/blob/main/src/validate.ts#L245)

## Parameters

Expand Down
2 changes: 1 addition & 1 deletion docs/functions/isTestStatus.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

> **isTestStatus**(`value`): value is "skipped" \| "failed" \| "other" \| "pending" \| "passed"

Defined in: [validate.ts:238](https://github.com/ctrf-io/ctrf-js/blob/main/src/validate.ts#L238)
Defined in: [validate.ts:268](https://github.com/ctrf-io/ctrf-js/blob/main/src/validate.ts#L268)

## Parameters

Expand Down
10 changes: 8 additions & 2 deletions docs/functions/isValid.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@

# Function: isValid()

> **isValid**(`report`): `report is CTRFReport`
> **isValid**(`report`, `options?`): `report is CTRFReport`

Defined in: [validate.ts:141](https://github.com/ctrf-io/ctrf-js/blob/main/src/validate.ts#L141)
Defined in: [validate.ts:164](https://github.com/ctrf-io/ctrf-js/blob/main/src/validate.ts#L164)

## Parameters

Expand All @@ -18,6 +18,12 @@ Defined in: [validate.ts:141](https://github.com/ctrf-io/ctrf-js/blob/main/src/v

The object to validate

### options?

[`ValidateOptions`](../interfaces/ValidateOptions.md) = `{}`

Validation options (e.g., a specific spec version or `latest`)

## Returns

`report is CTRFReport`
Expand Down
6 changes: 3 additions & 3 deletions docs/functions/validate.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

> **validate**(`report`, `options?`): [`ValidationResult`](../interfaces/ValidationResult.md)

Defined in: [validate.ts:97](https://github.com/ctrf-io/ctrf-js/blob/main/src/validate.ts#L97)
Defined in: [validate.ts:110](https://github.com/ctrf-io/ctrf-js/blob/main/src/validate.ts#L110)

Validate a CTRF report against the JSON schema and normative cross-field
rules that JSON Schema cannot express.
Expand All @@ -25,7 +25,7 @@ The object to validate

[`ValidateOptions`](../interfaces/ValidateOptions.md) = `{}`

Validation options (e.g., specific spec version)
Validation options (e.g., a specific spec version or `latest`)

## Returns

Expand All @@ -42,5 +42,5 @@ if (!result.valid) {
}

// Validate against specific version
const result = validate(report, { specVersion: '1.0.0' });
const result = validate(report, { specVersion: '0.0.2' });
```
10 changes: 8 additions & 2 deletions docs/functions/validateStrict.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@

# Function: validateStrict()

> **validateStrict**(`report`): `asserts report is CTRFReport`
> **validateStrict**(`report`, `options?`): `asserts report is CTRFReport`

Defined in: [validate.ts:166](https://github.com/ctrf-io/ctrf-js/blob/main/src/validate.ts#L166)
Defined in: [validate.ts:193](https://github.com/ctrf-io/ctrf-js/blob/main/src/validate.ts#L193)

## Parameters

Expand All @@ -18,6 +18,12 @@ Defined in: [validate.ts:166](https://github.com/ctrf-io/ctrf-js/blob/main/src/v

The object to validate

### options?

[`ValidateOptions`](../interfaces/ValidateOptions.md) = `{}`

Validation options (e.g., a specific spec version or `latest`)

## Returns

`asserts report is CTRFReport`
Expand Down
2 changes: 2 additions & 0 deletions docs/globals.md
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,8 @@ The current version CTRF JSON Schema object.

## Type Aliases

- [SupportedSpecVersion](type-aliases/SupportedSpecVersion.md)
- [SchemaSelector](type-aliases/SchemaSelector.md)
- [LabelPrimitive](type-aliases/LabelPrimitive.md)
- [LabelValue](type-aliases/LabelValue.md)

Expand Down
12 changes: 6 additions & 6 deletions docs/interfaces/Attachment.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

# Interface: Attachment

Defined in: [types.ts:242](https://github.com/ctrf-io/ctrf-js/blob/main/src/types.ts#L242)
Defined in: [types.ts:244](https://github.com/ctrf-io/ctrf-js/blob/main/src/types.ts#L244)

File attachment

Expand All @@ -16,7 +16,7 @@ File attachment

> `optional` **attachmentId?**: `string`

Defined in: [types.ts:244](https://github.com/ctrf-io/ctrf-js/blob/main/src/types.ts#L244)
Defined in: [types.ts:246](https://github.com/ctrf-io/ctrf-js/blob/main/src/types.ts#L246)

Identifier for this attachment reference instance

Expand All @@ -26,7 +26,7 @@ Identifier for this attachment reference instance

> **name**: `string`

Defined in: [types.ts:246](https://github.com/ctrf-io/ctrf-js/blob/main/src/types.ts#L246)
Defined in: [types.ts:248](https://github.com/ctrf-io/ctrf-js/blob/main/src/types.ts#L248)

Attachment name

Expand All @@ -36,7 +36,7 @@ Attachment name

> **contentType**: `string`

Defined in: [types.ts:248](https://github.com/ctrf-io/ctrf-js/blob/main/src/types.ts#L248)
Defined in: [types.ts:250](https://github.com/ctrf-io/ctrf-js/blob/main/src/types.ts#L250)

MIME content type

Expand All @@ -46,7 +46,7 @@ MIME content type

> **path**: `string`

Defined in: [types.ts:250](https://github.com/ctrf-io/ctrf-js/blob/main/src/types.ts#L250)
Defined in: [types.ts:252](https://github.com/ctrf-io/ctrf-js/blob/main/src/types.ts#L252)

Path to the attachment file

Expand All @@ -56,6 +56,6 @@ Path to the attachment file

> `optional` **extra?**: `Record`\<`string`, `unknown`\>

Defined in: [types.ts:252](https://github.com/ctrf-io/ctrf-js/blob/main/src/types.ts#L252)
Defined in: [types.ts:254](https://github.com/ctrf-io/ctrf-js/blob/main/src/types.ts#L254)

Custom metadata
Loading
Loading