Skip to content
/ jest Public
forked from jestjs/jest

Commit

Permalink
chore: update typebox (jestjs#15450)
Browse files Browse the repository at this point in the history
  • Loading branch information
SimenB authored Jan 15, 2025
1 parent 008127c commit 695097b
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 47 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
- `[jest-runtime]` Support `import.meta.resolve` ([#14930](https://github.com/jestjs/jest/pull/14930))
- `[jest-runtime]` [**BREAKING**] Make it mandatory to pass `globalConfig` to the `Runtime` constructor ([#15044](https://github.com/jestjs/jest/pull/15044))
- `[jest-runtime]` Add `unstable_unmockModule` ([#15080](https://github.com/jestjs/jest/pull/15080))
- `[@jest/schemas]` Upgrade `@sinclair/typebox` to v0.31 ([#14072](https://github.com/jestjs/jest/pull/14072))
- `[@jest/schemas]` Upgrade `@sinclair/typebox` to v0.34 ([#15450](https://github.com/jestjs/jest/pull/15450))
- `[@jest/types]` `test.each()`: Accept a readonly (`as const`) table properly ([#14565](https://github.com/jestjs/jest/pull/14565))
- `[@jest/types]` Improve argument type inference passed to `test` and `describe` callback functions from `each` tables ([#14920](https://github.com/jestjs/jest/pull/14920))
- `[jest-snapshot]` [**BREAKING**] Add support for [Error causes](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/cause) in snapshots ([#13965](https://github.com/facebook/jest/pull/13965))
Expand Down
2 changes: 1 addition & 1 deletion packages/jest-schemas/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"./package.json": "./package.json"
},
"dependencies": {
"@sinclair/typebox": "^0.33.0"
"@sinclair/typebox": "^0.34.0"
},
"engines": {
"node": "^16.10.0 || ^18.12.0 || >=20.0.0"
Expand Down
16 changes: 8 additions & 8 deletions packages/jest-schemas/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
* LICENSE file in the root directory of this source tree.
*/

import {type Static, Type} from '@sinclair/typebox';
import {RawFakeTimers, RawInitialOptions, RawSnapshotFormat} from './raw-types';
import type {Static} from '@sinclair/typebox';
import * as types from './raw-types';

export const SnapshotFormat = Type.Strict(RawSnapshotFormat);
export type SnapshotFormat = Static<typeof RawSnapshotFormat>;
export const SnapshotFormat = types.SnapshotFormat;
export type SnapshotFormat = Static<typeof SnapshotFormat>;

export const InitialOptions = Type.Strict(RawInitialOptions);
export type InitialOptions = Static<typeof RawInitialOptions>;
export const InitialOptions = types.InitialOptions;
export type InitialOptions = Static<typeof InitialOptions>;

export const FakeTimers = Type.Strict(RawFakeTimers);
export type FakeTimers = Static<typeof RawFakeTimers>;
export const FakeTimers = types.FakeTimers;
export type FakeTimers = Static<typeof FakeTimers>;
64 changes: 32 additions & 32 deletions packages/jest-schemas/src/raw-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

import {type Static, Type} from '@sinclair/typebox';

export const RawSnapshotFormat = Type.Partial(
export const SnapshotFormat = Type.Partial(
Type.Object({
callToJSON: Type.Boolean(),
compareKeys: Type.Null(),
Expand All @@ -34,12 +34,12 @@ export const RawSnapshotFormat = Type.Partial(
}),
);

const RawCoverageProvider = Type.Union([
const CoverageProvider = Type.Union([
Type.Literal('babel'),
Type.Literal('v8'),
]);

const RawCoverageThresholdValue = Type.Partial(
const CoverageThresholdValue = Type.Partial(
Type.Object({
branches: Type.Number({minimum: 0, maximum: 100}),
functions: Type.Number({minimum: 0, maximum: 100}),
Expand All @@ -48,15 +48,15 @@ const RawCoverageThresholdValue = Type.Partial(
}),
);

const RawCoverageThresholdBase = Type.Object(
{global: RawCoverageThresholdValue},
{additionalProperties: RawCoverageThresholdValue},
const CoverageThresholdBase = Type.Object(
{global: CoverageThresholdValue},
{additionalProperties: CoverageThresholdValue},
);

const RawCoverageThreshold = Type.Unsafe<{
global: Static<typeof RawCoverageThresholdValue>;
[path: string]: Static<typeof RawCoverageThresholdValue>;
}>(RawCoverageThresholdBase);
const CoverageThreshold = Type.Unsafe<{
global: Static<typeof CoverageThresholdValue>;
[path: string]: Static<typeof CoverageThresholdValue>;
}>(CoverageThresholdBase);

// TODO: add type test that these are all the colors available in chalk.ForegroundColor
export const ChalkForegroundColors = Type.Union([
Expand All @@ -80,13 +80,13 @@ export const ChalkForegroundColors = Type.Union([
Type.Literal('whiteBright'),
]);

const RawDisplayName = Type.Object({
const DisplayName = Type.Object({
name: Type.String(),
color: ChalkForegroundColors,
});

// TODO: verify these are the names of istanbulReport.ReportOptions
export const RawCoverageReporterNames = Type.Union([
export const CoverageReporterNames = Type.Union([
Type.Literal('clover'),
Type.Literal('cobertura'),
Type.Literal('html-spa'),
Expand All @@ -102,17 +102,17 @@ export const RawCoverageReporterNames = Type.Union([
Type.Literal('text-summary'),
]);

const RawCoverageReporters = Type.Array(
const CoverageReporters = Type.Array(
Type.Union([
RawCoverageReporterNames,
CoverageReporterNames,
Type.Tuple([
RawCoverageReporterNames,
CoverageReporterNames,
Type.Record(Type.String(), Type.Unknown()),
]),
]),
);

const RawGlobalFakeTimersConfig = Type.Partial(
const GlobalFakeTimersConfig = Type.Partial(
Type.Object({
enableGlobally: Type.Boolean({
description:
Expand All @@ -122,7 +122,7 @@ const RawGlobalFakeTimersConfig = Type.Partial(
}),
);

const RawFakeableAPI = Type.Union([
const FakeableAPI = Type.Union([
Type.Literal('Date'),
Type.Literal('hrtime'),
Type.Literal('nextTick'),
Expand All @@ -140,15 +140,15 @@ const RawFakeableAPI = Type.Union([
Type.Literal('clearTimeout'),
]);

const RawFakeTimersConfig = Type.Partial(
const FakeTimersConfig = Type.Partial(
Type.Object({
advanceTimers: Type.Union([Type.Boolean(), Type.Number({minimum: 0})], {
description:
'If set to `true` all timers will be advanced automatically by 20 milliseconds every 20 milliseconds. A custom ' +
'time delta may be provided by passing a number.',
default: false,
}),
doNotFake: Type.Array(RawFakeableAPI, {
doNotFake: Type.Array(FakeableAPI, {
description:
'List of names of APIs (e.g. `Date`, `nextTick()`, `setImmediate()`, `setTimeout()`) that should not be faked.' +
'\n\nThe default is `[]`, meaning all APIs are faked.',
Expand All @@ -173,7 +173,7 @@ const RawFakeTimersConfig = Type.Partial(
}),
);

const RawLegacyFakeTimersConfig = Type.Partial(
const LegacyFakeTimersConfig = Type.Partial(
Type.Object({
legacyFakeTimers: Type.Literal(true, {
description:
Expand All @@ -183,12 +183,12 @@ const RawLegacyFakeTimersConfig = Type.Partial(
}),
);

export const RawFakeTimers = Type.Intersect([
RawGlobalFakeTimersConfig,
Type.Union([RawFakeTimersConfig, RawLegacyFakeTimersConfig]),
export const FakeTimers = Type.Intersect([
GlobalFakeTimersConfig,
Type.Union([FakeTimersConfig, LegacyFakeTimersConfig]),
]);

const RawHasteConfig = Type.Partial(
const HasteConfig = Type.Partial(
Type.Object({
computeSha1: Type.Boolean({
description: 'Whether to hash files using SHA-1.',
Expand Down Expand Up @@ -225,7 +225,7 @@ const RawHasteConfig = Type.Partial(
}),
);

export const RawInitialOptions = Type.Partial(
export const InitialOptions = Type.Partial(
Type.Object({
automock: Type.Boolean(),
bail: Type.Union([Type.Boolean(), Type.Number()]),
Expand All @@ -239,16 +239,16 @@ export const RawInitialOptions = Type.Partial(
collectCoverageFrom: Type.Array(Type.String()),
coverageDirectory: Type.String(),
coveragePathIgnorePatterns: Type.Array(Type.String()),
coverageProvider: RawCoverageProvider,
coverageReporters: RawCoverageReporters,
coverageThreshold: RawCoverageThreshold,
coverageProvider: CoverageProvider,
coverageReporters: CoverageReporters,
coverageThreshold: CoverageThreshold,
dependencyExtractor: Type.String(),
detectLeaks: Type.Boolean(),
detectOpenHandles: Type.Boolean(),
displayName: Type.Union([Type.String(), RawDisplayName]),
displayName: Type.Union([Type.String(), DisplayName]),
expand: Type.Boolean(),
extensionsToTreatAsEsm: Type.Array(Type.String()),
fakeTimers: RawFakeTimers,
fakeTimers: FakeTimers,
filter: Type.String(),
findRelatedTests: Type.Boolean(),
forceCoverageMatch: Type.Array(Type.String()),
Expand All @@ -257,7 +257,7 @@ export const RawInitialOptions = Type.Partial(
globals: Type.Record(Type.String(), Type.Unknown()),
globalSetup: Type.Union([Type.String(), Type.Null()]),
globalTeardown: Type.Union([Type.String(), Type.Null()]),
haste: RawHasteConfig,
haste: HasteConfig,
id: Type.String(),
injectGlobals: Type.Boolean(),
reporters: Type.Array(
Expand Down Expand Up @@ -317,7 +317,7 @@ export const RawInitialOptions = Type.Partial(
slowTestThreshold: Type.Number(),
snapshotResolver: Type.String(),
snapshotSerializers: Type.Array(Type.String()),
snapshotFormat: RawSnapshotFormat,
snapshotFormat: SnapshotFormat,
errorOnDeprecated: Type.Boolean(),
testEnvironment: Type.String(),
testEnvironmentOptions: Type.Record(Type.String(), Type.Unknown()),
Expand Down
10 changes: 5 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3413,7 +3413,7 @@ __metadata:
version: 0.0.0-use.local
resolution: "@jest/schemas@workspace:packages/jest-schemas"
dependencies:
"@sinclair/typebox": ^0.33.0
"@sinclair/typebox": ^0.34.0
languageName: unknown
linkType: soft

Expand Down Expand Up @@ -4916,10 +4916,10 @@ __metadata:
languageName: node
linkType: hard

"@sinclair/typebox@npm:^0.33.0":
version: 0.33.7
resolution: "@sinclair/typebox@npm:0.33.7"
checksum: 96743096e8f15024148e2fcbaf236ada0cf4dd8d8f0c1b0d49a9de9003bda2b2a2b5084971d5587a2a0c64cd238a1f9dbbafe6c97af4154975f80dadf34ec0c0
"@sinclair/typebox@npm:^0.34.0":
version: 0.34.13
resolution: "@sinclair/typebox@npm:0.34.13"
checksum: abc841a407396e8f49afe9b42bf60133207029e9ac483861750b40bcc41a5de46b9b1b6026f5f34664de32a1941cad35e0de36e3a6f5f94c15c33a0d59260828
languageName: node
linkType: hard

Expand Down

0 comments on commit 695097b

Please sign in to comment.