@isentinel/jest-roblox 0.3.6 → 0.3.7

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.
@@ -788,7 +788,12 @@ type _Except<ObjectType, KeysType extends keyof ObjectType, Options extends Requ
788
788
  //#region src/config/resolve-typecheck-config.d.ts
789
789
  /** Host-only Type Test config. Valid at root `test:` and per-project `test:`. */
790
790
  interface TypecheckConfig {
791
+ /**
792
+ * Enable Type Tests (`*.spec-d.ts`/`*.test-d.ts`). This is the only gate —
793
+ * setting other typecheck fields does not auto-enable. Default `false`.
794
+ */
791
795
  enabled?: boolean;
796
+ /** Globs excluded from Type Test discovery. */
792
797
  exclude?: Array<string>;
793
798
  /**
794
799
  * When `false` (default), type errors in non-test source files surface as
@@ -796,10 +801,20 @@ interface TypecheckConfig {
796
801
  * discovered Type Test files are suppressed.
797
802
  */
798
803
  ignoreSourceErrors?: boolean;
804
+ /**
805
+ * Globs selecting Type Test files. When unset, derived from the project's
806
+ * runtime `include` (`.spec.` → `.spec-d.`).
807
+ */
799
808
  include?: Array<string>;
809
+ /** Run only Type Tests and skip Runtime Tests. Implies `enabled`. Default `false`. */
800
810
  only?: boolean;
801
- /** Milliseconds the tsgo spawn may run before it is killed and the pass throws. */
811
+ /**
812
+ * Milliseconds to wait for the tsgo process to start before the pass
813
+ * throws. Bounds only startup, not the type-check itself — a slow check is
814
+ * governed by the run-level `timeout`. Default `10000`.
815
+ */
802
816
  spawnTimeout?: number;
817
+ /** Custom tsconfig used for type checking (root-only in projects mode). */
803
818
  tsconfig?: string;
804
819
  }
805
820
  //#endregion
@@ -807,39 +822,90 @@ interface TypecheckConfig {
807
822
  type Backend = "auto" | "open-cloud" | "studio";
808
823
  type CoverageReporter = keyof ReportOptions;
809
824
  type FormatterEntry = [string, Record<string, unknown>] | string;
825
+ /** pretty-format options controlling how snapshots are serialized. */
810
826
  interface SnapshotFormatOptions {
827
+ /** Call a value's `toJSON` method (when present) before serializing it. */
811
828
  callToJSON?: boolean;
829
+ /** Escape regex special characters in string snapshots. */
812
830
  escapeRegex?: boolean;
831
+ /** Escape backslashes and quotes in string snapshots. */
813
832
  escapeString?: boolean;
833
+ /** Number of spaces per indentation level. */
814
834
  indent?: number;
835
+ /** Maximum depth of nested objects/arrays to print before collapsing. */
815
836
  maxDepth?: number;
837
+ /** Print on a single line with no indentation. */
816
838
  min?: boolean;
839
+ /** Print the `Object`/class prototype name for plain objects. */
817
840
  printBasicPrototype?: boolean;
841
+ /** Print function names instead of `[Function]`. */
818
842
  printFunctionName?: boolean;
819
843
  }
844
+ /** A reporter label with a colour, used to tag a project's output. */
820
845
  interface DisplayName {
846
+ /** The label shown in reporter output. */
821
847
  name: string;
848
+ /** Colour applied to the label (e.g. `"magenta"`, `"white"`). */
822
849
  color: string;
823
850
  }
824
851
  /** Jest-passthrough keys valid both at `test:` and per-project. */
825
852
  interface SharedTestConfig {
853
+ /** Automatically mock every required module. Default `false`. */
826
854
  automock?: boolean;
855
+ /**
856
+ * Clear `mock.calls`/`instances`/`results` on every mock before each test
857
+ * (like `jest.clearAllMocks()`). Default `false`.
858
+ */
827
859
  clearMocks?: boolean;
860
+ /**
861
+ * Inject Jest's globals (`describe`, `it`, `expect`, …) into the test
862
+ * environment instead of requiring them explicitly. Default `true`.
863
+ */
828
864
  injectGlobals?: boolean;
865
+ /**
866
+ * Swap the live Roblox DataModel for a fresh mock instance per test file so
867
+ * tests can mutate the tree in isolation. Default `false`.
868
+ */
829
869
  mockDataModel?: boolean;
870
+ /**
871
+ * Reset mock state and remove any mocked implementation before each test
872
+ * (like `jest.resetAllMocks()`). Default `false`.
873
+ */
830
874
  resetMocks?: boolean;
875
+ /**
876
+ * Reset the module registry before each test so every test re-requires a
877
+ * fresh module graph. Default `false`.
878
+ */
831
879
  resetModules?: boolean;
880
+ /**
881
+ * Restore `spyOn` mocks to their original implementations before each test
882
+ * (like `jest.restoreAllMocks()`). Default `false`.
883
+ */
832
884
  restoreMocks?: boolean;
885
+ /** DataModel paths to scripts run once before the test framework is installed. */
833
886
  setupFiles?: Array<string>;
887
+ /**
888
+ * DataModel paths to scripts run after the framework is installed, before
889
+ * each test file — the place for global hooks and custom matchers.
890
+ */
834
891
  setupFilesAfterEnv?: Array<string>;
892
+ /** Seconds after which a single test is reported as slow. Default `5`. */
835
893
  slowTestThreshold?: number;
894
+ /** pretty-format options controlling how snapshots are serialized. */
836
895
  snapshotFormat?: SnapshotFormatOptions;
896
+ /** DataModel paths to custom snapshot serializer modules. */
837
897
  snapshotSerializers?: Array<string>;
898
+ /** Test environment used to run the tests. */
838
899
  testEnvironment?: string;
900
+ /** Options forwarded to the test environment. */
839
901
  testEnvironmentOptions?: Record<string, unknown> | string;
902
+ /** Glob patterns Jest uses to detect test files. */
840
903
  testMatch?: Array<string>;
904
+ /** Regex patterns; a test file is skipped when its path matches any of them. */
841
905
  testPathIgnorePatterns?: Array<string>;
906
+ /** Regex pattern(s) Jest uses to detect test files (alternative to `testMatch`). */
842
907
  testRegex?: Array<string> | string;
908
+ /** Default per-test timeout in milliseconds. Default `5000`. */
843
909
  testTimeout?: number;
844
910
  /**
845
911
  * Host-only Type Test config. Never forwarded to the Roblox runtime.
@@ -849,10 +915,27 @@ interface SharedTestConfig {
849
915
  }
850
916
  /** Jest-passthrough keys valid only per-project (under `projects[N].test`). */
851
917
  interface ProjectTestConfig extends SharedTestConfig {
918
+ /**
919
+ * Reporter label identifying this project's tests — a string, or
920
+ * `{ name, color }` to tint it. Must be unique across projects.
921
+ */
852
922
  displayName: DisplayName | string;
923
+ /** Globs subtracted from this project's Runtime Test discovery. */
853
924
  exclude?: Array<string>;
925
+ /**
926
+ * Globs (with TS extensions) selecting this project's test files, relative
927
+ * to `root`. The static directory prefix of each glob maps to a Rojo
928
+ * `$path`/DataModel mount.
929
+ */
854
930
  include: Array<string>;
931
+ /**
932
+ * Compiled-output directory the project's `.luau` lives in. Setting it pins
933
+ * the project to a single DataModel mount (exact Rojo lookup, no
934
+ * auto-expand). roblox-ts users point this at the compiled output (e.g.
935
+ * `"out/client"`), not `"src/…"`.
936
+ */
855
937
  outDir?: string;
938
+ /** Base path prepended to this project's `include`, `exclude`, and `outDir`. */
856
939
  root?: string;
857
940
  }
858
941
  interface InlineProjectConfig {
@@ -890,47 +973,104 @@ interface WorkspaceConfig {
890
973
  type ProjectEntry = InlineProjectConfig | string;
891
974
  /** Jest-passthrough keys valid only at root `test:` (not per-project). */
892
975
  interface GlobalTestConfig extends SharedTestConfig {
976
+ /**
977
+ * Report coverage for every file matched by the coverage globs, even those
978
+ * no test exercised (untested files count as 0%). Default `false`.
979
+ */
893
980
  all?: boolean;
981
+ /**
982
+ * Stop the run after `n` failing test suites (`true` ⇒ after the first).
983
+ * Default `0` (never bail).
984
+ */
894
985
  bail?: boolean | number;
986
+ /** Run only tests affected by files changed since the given git ref. */
895
987
  changedSince?: string;
988
+ /** Assume a CI environment, which disables writing new snapshots. */
896
989
  ci?: boolean;
990
+ /** Clear Jest's transform cache before running, then exit. */
897
991
  clearCache?: boolean;
992
+ /** Collect code coverage during the run. Default `false`. */
898
993
  collectCoverage?: boolean;
994
+ /** Globs selecting which source files coverage is collected from. */
899
995
  collectCoverageFrom?: Array<string>;
996
+ /** Alias for {@link collectCoverage}. */
900
997
  coverage?: boolean;
998
+ /** Directory coverage reports are written to. Default `"coverage"`. */
901
999
  coverageDirectory?: string;
1000
+ /** Globs excluded from coverage collection. */
902
1001
  coveragePathIgnorePatterns?: Array<string>;
1002
+ /**
1003
+ * Istanbul reporters to emit (e.g. `"text"`, `"lcov"`, `"html"`). Default
1004
+ * `["text", "lcov"]`.
1005
+ */
903
1006
  coverageReporters?: Array<CoverageReporter>;
1007
+ /**
1008
+ * Minimum coverage percentages (0–100); the run fails when any is not met.
1009
+ */
904
1010
  coverageThreshold?: {
905
1011
  branches?: number;
906
1012
  functions?: number;
907
1013
  lines?: number;
908
1014
  statements?: number;
909
1015
  };
1016
+ /** Print Jest's resolved config and debugging info. */
910
1017
  debug?: boolean;
1018
+ /** Reporter label for the whole run — a string, or `{ name, color }`. */
911
1019
  displayName?: DisplayName | string;
1020
+ /** Test environment to use, forwarded to the Jest runtime. */
912
1021
  env?: string;
1022
+ /**
1023
+ * Globs subtracted from Runtime Test discovery. Applies to single-,
1024
+ * multi-project, and `--workspace` runs (skipped for explicit file args).
1025
+ */
913
1026
  exclude?: Array<string>;
1027
+ /** Show full diffs and error output instead of truncating. */
914
1028
  expand?: boolean;
1029
+ /** A JSON string of globals to expose in every test environment. */
915
1030
  globals?: string;
1031
+ /** Globs selecting Runtime Test files when no `projects` are configured. */
916
1032
  include?: Array<string>;
1033
+ /**
1034
+ * Maximum worker count, or a percentage string like `"50%"`, for parallel
1035
+ * test execution.
1036
+ */
917
1037
  maxWorkers?: number | string;
1038
+ /** Omit stack traces from failure output. */
918
1039
  noStackTrace?: boolean;
1040
+ /** Default compiled-output directory for test discovery when not set per-project. */
919
1041
  outDir?: string;
1042
+ /** Exit `0` even when no tests are found. Default `false`. */
920
1043
  passWithNoTests?: boolean;
1044
+ /** Name of a preset that supplies base Jest config. */
921
1045
  preset?: string;
1046
+ /**
1047
+ * Per-project configs for a multi-project run. Each entry is a DataModel
1048
+ * path string, or an inline {@link defineProject} object.
1049
+ */
922
1050
  projects?: Array<ProjectEntry>;
1051
+ /** Reporter modules (DataModel paths) used to format results. */
923
1052
  reporters?: Array<string>;
1053
+ /** Root directories Jest scans for tests and modules. */
924
1054
  roots?: Array<string>;
1055
+ /** Run all tests serially in the current process instead of in workers. */
925
1056
  runInBand?: boolean;
1057
+ /** Run only the projects whose `displayName` is listed. */
926
1058
  selectProjects?: Array<string>;
1059
+ /** Print the resolved config and exit without running tests. */
927
1060
  showConfig?: boolean;
1061
+ /** Suppress test `print`/console output. Default `false`. */
928
1062
  silent?: boolean;
1063
+ /** Process exit code used when tests fail. */
929
1064
  testFailureExitCode?: string;
1065
+ /** Run only tests whose full name matches this regex. */
930
1066
  testNamePattern?: string;
1067
+ /** Run only test files whose path matches this regex. */
931
1068
  testPathPattern?: string;
1069
+ /** Fake-timers mode (e.g. `"real"`, `"fake"`). */
932
1070
  timers?: string;
1071
+ /** Update stored snapshots to match current output. */
933
1072
  updateSnapshot?: boolean;
1073
+ /** Report each individual test result, not just suite summaries. Default `false`. */
934
1074
  verbose?: boolean;
935
1075
  }
936
1076
  /**
@@ -938,10 +1078,29 @@ interface GlobalTestConfig extends SharedTestConfig {
938
1078
  * jest-passthrough options live.
939
1079
  */
940
1080
  interface Config {
1081
+ /**
1082
+ * Execution backend. `"auto"` probes for a running Studio then falls back to
1083
+ * Open Cloud; `"open-cloud"` uploads and runs via Roblox Open Cloud;
1084
+ * `"studio"` drives a locally running Studio. Default `"auto"`.
1085
+ */
941
1086
  backend?: Backend;
1087
+ /** Force ANSI colour in output. Default `true`. */
942
1088
  color?: boolean;
1089
+ /**
1090
+ * Reuse the incrementally-instrumented coverage place between runs when
1091
+ * nothing changed. Default `true`.
1092
+ */
943
1093
  coverageCache?: boolean;
1094
+ /**
1095
+ * One or more config files to inherit from (c12 layering), relative to this
1096
+ * file. Local keys win over extended ones.
1097
+ */
944
1098
  extends?: Array<string> | string;
1099
+ /**
1100
+ * Output formatters — `"default"`, `"agent"`, `"json"`,
1101
+ * `"github-actions"` — each a name or a `[name, options]` pair. Default
1102
+ * `["default"]`.
1103
+ */
945
1104
  formatters?: Array<FormatterEntry>;
946
1105
  /**
947
1106
  * Where to write Game Output. A path, or `true` to default to
@@ -949,7 +1108,16 @@ interface Config {
949
1108
  * single Aggregated Game Output file (consensus-resolved).
950
1109
  */
951
1110
  gameOutput?: string | true;
1111
+ /**
1112
+ * DataModel path to the Jest module the runner requires (e.g.
1113
+ * `"ReplicatedStorage/Packages/Jest"`). Defaults to auto-detection in
1114
+ * ReplicatedStorage.
1115
+ */
952
1116
  jestPath?: string;
1117
+ /**
1118
+ * Compiled-Luau directories to instrument for coverage. Defaults to the
1119
+ * tsconfig `outDir`.
1120
+ */
953
1121
  luauRoots?: Array<string>;
954
1122
  /**
955
1123
  * Where to write the Jest result JSON. A path, or `true` to default to
@@ -957,17 +1125,44 @@ interface Config {
957
1125
  * single aggregated result file (consensus-resolved).
958
1126
  */
959
1127
  outputFile?: string | true;
1128
+ /** Number of places to shard the run across, or `"auto"` to pick automatically. */
960
1129
  parallel?: "auto" | number;
1130
+ /** Path to the `.rbxl` place uploaded and run. Default `"./game.rbxl"`. */
961
1131
  placeFile?: string;
1132
+ /** Open Cloud place id to publish/run against. */
962
1133
  placeId?: string;
1134
+ /** WebSocket port for the Studio backend. Default `3001`. */
963
1135
  port?: number;
1136
+ /**
1137
+ * Path to the Rojo project file used to map DataModel paths to source.
1138
+ * Auto-detected when unset.
1139
+ */
964
1140
  rojoProject?: string;
1141
+ /**
1142
+ * Base directory for resolving relative paths. Defaults to the current
1143
+ * working directory.
1144
+ */
965
1145
  rootDir?: string;
1146
+ /** Include the translated Luau line in error/stack output. Default `true`. */
966
1147
  showLuau?: boolean;
1148
+ /** Map Luau stack traces back to TypeScript source. Default `true`. */
967
1149
  sourceMap?: boolean;
1150
+ /**
1151
+ * The Jest options block. Every jest-passthrough setting lives here, kept
1152
+ * separate from the CLI/runner keys above.
1153
+ */
968
1154
  test?: GlobalTestConfig;
1155
+ /**
1156
+ * Maximum remote execution time in milliseconds before the run is
1157
+ * abandoned. Default `300000`.
1158
+ */
969
1159
  timeout?: number;
1160
+ /** Open Cloud universe id that owns the place. */
970
1161
  universeId?: string;
1162
+ /**
1163
+ * Workspace-mode knobs for multi-package runs. Ignored outside
1164
+ * `--workspace`.
1165
+ */
971
1166
  workspace?: WorkspaceConfig;
972
1167
  }
973
1168
  /**
@@ -1048,13 +1243,9 @@ interface CliOptions {
1048
1243
  /** Directory to load the workspace config from when run outside a package. */
1049
1244
  workspaceRoot?: string;
1050
1245
  }
1051
- interface ConfigInput extends Except<Config, "formatters" | "luauRoots" | "test"> {
1052
- formatters?: Mergeable<Array<FormatterEntry>>;
1053
- luauRoots?: Mergeable<Array<string>>;
1054
- test?: GlobalTestConfigInput;
1055
- }
1246
+ type ConfigInput = { [K in keyof Config]?: K extends "formatters" ? Mergeable<Array<FormatterEntry>> : K extends "luauRoots" ? Mergeable<Array<string>> : K extends "test" ? GlobalTestConfigInput : Config[K] };
1056
1247
  type MergeableTestKey = "collectCoverageFrom" | "coveragePathIgnorePatterns" | "coverageReporters" | "coverageThreshold" | "reporters" | "roots" | "selectProjects" | "setupFiles" | "setupFilesAfterEnv" | "snapshotFormat" | "snapshotSerializers" | "testMatch" | "testPathIgnorePatterns";
1057
- type GlobalTestConfigInput = Except<GlobalTestConfig, MergeableTestKey> & { [K in MergeableTestKey]?: Mergeable<NonNullable<GlobalTestConfig[K]>> };
1248
+ type GlobalTestConfigInput = { [K in keyof GlobalTestConfig]?: K extends MergeableTestKey ? Mergeable<NonNullable<GlobalTestConfig[K]>> : GlobalTestConfig[K] };
1058
1249
  declare const SHARED_TEST_KEYS: ReadonlySet<string>;
1059
1250
  /** Keys valid in `test:` (root) but not per-project (`projects[N].test`). */
1060
1251
  declare const GLOBAL_TEST_KEYS: ReadonlySet<string>;
@@ -1067,7 +1258,28 @@ declare const ROOT_CLI_KEYS: ReadonlySet<string>;
1067
1258
  * (not jest itself).
1068
1259
  */
1069
1260
  declare const JEST_ARGV_EXCLUDED_KEYS: ReadonlySet<string>;
1261
+ /**
1262
+ * Identity helper for authoring a typed `jest.config.*` file. Returns its
1263
+ * input unchanged; it exists purely to give editors autocompletion and
1264
+ * type-checking for the root config shape (`Config` plus the c12 layer props
1265
+ * on `ConfigInput`).
1266
+ *
1267
+ * Use it as the default export of a config file discovered by c12 (`.ts`,
1268
+ * `.js`, `.mjs`, `.cjs`, `.json`, `.yaml`, `.toml`). All jest-passthrough
1269
+ * options live under the `test:` block; root keys are CLI/runner-level.
1270
+ * Configs may extend a shared base via `extends`, and any `Mergeable` array
1271
+ * field (e.g. `test.testMatch`) accepts a function that receives the inherited
1272
+ * defaults and returns the merged value. Precedence is CLI flags > config file
1273
+ * > extended config > defaults.
1274
+ */
1070
1275
  declare const defineConfig: (input: ConfigInput) => ConfigInput;
1276
+ /**
1277
+ * Identity helper for a single entry inside `test.projects`, mirroring
1278
+ * {@link defineConfig} for per-project overrides. Returns its input unchanged
1279
+ * and exists only for editor autocompletion and type-checking of the
1280
+ * `InlineProjectConfig` shape — a `test:` block carrying the project's
1281
+ * `include`/`displayName` plus any shared per-project jest options.
1282
+ */
1071
1283
  declare const defineProject: (input: InlineProjectConfig) => InlineProjectConfig;
1072
1284
  //#endregion
1073
1285
  export { SnapshotFormatOptions as _, DisplayName as a, defineProject as b, GlobalTestConfig as c, ProjectEntry as d, ProjectTestConfig as f, SharedTestConfig as g, SHARED_TEST_KEYS as h, DEFAULT_CONFIG as i, InlineProjectConfig as l, ResolvedConfig as m, Config as n, FormatterEntry as o, ROOT_CLI_KEYS as p, ConfigInput as r, GLOBAL_TEST_KEYS as s, CliOptions as t, JEST_ARGV_EXCLUDED_KEYS as u, WorkspaceConfig as v, TypecheckConfig as x, defineConfig as y };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@isentinel/jest-roblox",
3
- "version": "0.3.6",
3
+ "version": "0.3.7",
4
4
  "description": "Jest-compatible CLI for running roblox-ts tests via Roblox Open Cloud",
5
5
  "keywords": [
6
6
  "jest",
@@ -48,7 +48,7 @@
48
48
  "!dist/**/*.tsbuildinfo"
49
49
  ],
50
50
  "dependencies": {
51
- "@bedrock-rbx/ocale": "0.1.0-beta.18",
51
+ "@bedrock-rbx/ocale": "0.1.0-beta.19",
52
52
  "@jridgewell/trace-mapping": "0.3.31",
53
53
  "arktype": "2.2.0",
54
54
  "c12": "4.0.0-beta.5",
@@ -97,9 +97,9 @@
97
97
  "type-fest": "5.7.0",
98
98
  "typescript": "6.0.3",
99
99
  "vitest": "4.1.8",
100
- "@isentinel/luau-ast": "0.1.0",
101
100
  "@isentinel/roblox-runner": "0.1.0",
102
- "@isentinel/rojo-utils": "0.1.0"
101
+ "@isentinel/rojo-utils": "0.1.0",
102
+ "@isentinel/luau-ast": "0.1.0"
103
103
  },
104
104
  "engines": {
105
105
  "node": ">=24.12.0"