Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: move from jest to vitest #2067

Draft
wants to merge 7 commits into
base: next
Choose a base branch
from
Draft
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
1 change: 1 addition & 0 deletions .github/workflows/publish-auto.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ jobs:
with:
registry-url: "https://registry.npmjs.org"
cache: "yarn"
node-version: 22
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
run: yarn build

- name: Test coverage
run: yarn jest test/ --collectCoverage=true
run: yarn test:coverage

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
1 change: 0 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
package.json
test/valid-data/**/*.json
babel.config.cjs
jest.config.cjs
2 changes: 1 addition & 1 deletion bin/ts-json-schema-generator.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env node

// eslint-disable-next-line @typescript-eslint/no-require-imports
// eslint-disable-next-line no-undef
require("../dist/ts-json-schema-generator.js");
5 changes: 2 additions & 3 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import globals from "globals";
import tseslint from "typescript-eslint";
import eslintPluginPrettierRecommended from "eslint-plugin-prettier/recommended";

/** @type {import('@types/eslint').Linter.FlatConfig[]} */
/** @type {import('@types/eslint').Linter.Config[]} */
export default tseslint.config(
{
ignores: ["dist", "cjs", "build", "eslint.config.mjs"],
Expand All @@ -15,7 +15,6 @@ export default tseslint.config(
"index.ts",
"src/**/*.ts",
"factory/**/*.ts",
"bin/**",
"test/**/*.test.ts",
"test/utils.ts",
],
Expand Down Expand Up @@ -70,7 +69,7 @@ export default tseslint.config(
files: ["test/**/*.test.ts"],
languageOptions: {
globals: {
...globals.jest,
...globals.vitest,
...globals.commonjs,
},
},
Expand Down
17 changes: 0 additions & 17 deletions jest.config.cjs

This file was deleted.

49 changes: 24 additions & 25 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,49 +49,48 @@
"prepublishOnly": "yarn build",
"release": "yarn build && auto shipit",
"run": "tsx ts-json-schema-generator.ts",
"test": "jest test/ --verbose",
"test:coverage": "yarn jest test/ --collectCoverage=true",
"test:fast": "cross-env FAST_TEST=1 jest test/ --verbose",
"test": "vitest run",
"test:coverage": "yarn vitest run --coverage",
"test:fast": "cross-env FAST_TEST=1 vitest run",
"test:update": "cross-env UPDATE_SCHEMA=true yarn test:fast",
"watch": "tsc -w"
},
"dependencies": {
"@types/json-schema": "^7.0.15",
"commander": "^12.1.0",
"glob": "^10.4.2",
"glob": "^11.0.0",
"json5": "^2.2.3",
"normalize-path": "^3.0.0",
"safe-stable-stringify": "^2.4.3",
"tslib": "^2.6.3",
"typescript": "^5.5.2"
"safe-stable-stringify": "^2.5.0",
"tslib": "^2.7.0",
"typescript": "^5.5.4"
},
"devDependencies": {
"@auto-it/conventional-commits": "^11.1.6",
"@auto-it/first-time-contributor": "^11.1.6",
"@babel/core": "^7.24.7",
"@babel/preset-env": "^7.24.7",
"@auto-it/conventional-commits": "^11.2.1",
"@auto-it/first-time-contributor": "^11.2.1",
"@babel/core": "^7.25.2",
"@babel/preset-env": "^7.25.4",
"@babel/preset-typescript": "^7.24.7",
"@eslint/js": "^9.6.0",
"@types/eslint": "^9.6.0",
"@eslint/js": "^9.10.0",
"@types/eslint": "^9.6.1",
"@types/glob": "^8.1.0",
"@types/jest": "^29.5.12",
"@types/node": "^22.0.0",
"@types/node": "^22.5.4",
"@types/normalize-path": "^3.0.2",
"ajv": "^8.16.0",
"@vitest/coverage-v8": "^2.0.5",
"ajv": "^8.17.1",
"ajv-formats": "^3.0.1",
"auto": "^11.1.6",
"auto": "^11.2.1",
"chai": "^5.1.1",
"cross-env": "^7.0.3",
"eslint": "^9.6.0",
"eslint": "^9.10.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-prettier": "^5.1.3",
"jest": "^29.7.0",
"jest-junit": "^16.0.0",
"prettier": "^3.3.2",
"tsx": "^4.16.0",
"typescript-eslint": "^7.14.1",
"eslint-plugin-prettier": "^5.2.1",
"prettier": "^3.3.3",
"tsx": "^4.19.0",
"typescript-eslint": "^8.4.0",
"vega": "^5.30.0",
"vega-lite": "^5.19.0"
"vega-lite": "^5.21.0",
"vitest": "^2.0.5"
},
"engines": {
"node": ">=18.0.0"
Expand Down
2 changes: 1 addition & 1 deletion src/AnnotationsReader/BasicAnnotationsReader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,12 @@
}

const annotations = jsDocTags.reduce((result: Annotations, jsDocTag) => {
const value = this.parseJsDocTag(jsDocTag);

Check warning on line 79 in src/AnnotationsReader/BasicAnnotationsReader.ts

View workflow job for this annotation

GitHub Actions / Test (ubuntu-latest)

Unsafe assignment of an `any` value

Check warning on line 79 in src/AnnotationsReader/BasicAnnotationsReader.ts

View workflow job for this annotation

GitHub Actions / Test (windows-latest)

Unsafe assignment of an `any` value
if (value !== undefined) {
if (BasicAnnotationsReader.requiresDollar.has(jsDocTag.name)) {
result["$" + jsDocTag.name] = value;

Check warning on line 82 in src/AnnotationsReader/BasicAnnotationsReader.ts

View workflow job for this annotation

GitHub Actions / Test (ubuntu-latest)

Unsafe assignment of an `any` value

Check warning on line 82 in src/AnnotationsReader/BasicAnnotationsReader.ts

View workflow job for this annotation

GitHub Actions / Test (windows-latest)

Unsafe assignment of an `any` value
} else {
result[jsDocTag.name] = value;

Check warning on line 84 in src/AnnotationsReader/BasicAnnotationsReader.ts

View workflow job for this annotation

GitHub Actions / Test (ubuntu-latest)

Unsafe assignment of an `any` value

Check warning on line 84 in src/AnnotationsReader/BasicAnnotationsReader.ts

View workflow job for this annotation

GitHub Actions / Test (windows-latest)

Unsafe assignment of an `any` value
}
}
return result;
Expand All @@ -99,8 +99,8 @@
if (isTextTag) {
return text;
}
let parsed = this.parseJson(text);

Check warning on line 102 in src/AnnotationsReader/BasicAnnotationsReader.ts

View workflow job for this annotation

GitHub Actions / Test (ubuntu-latest)

Unsafe assignment of an `any` value

Check warning on line 102 in src/AnnotationsReader/BasicAnnotationsReader.ts

View workflow job for this annotation

GitHub Actions / Test (windows-latest)

Unsafe assignment of an `any` value
parsed = parsed === undefined ? text : parsed;

Check warning on line 103 in src/AnnotationsReader/BasicAnnotationsReader.ts

View workflow job for this annotation

GitHub Actions / Test (ubuntu-latest)

Unsafe assignment of an `any` value

Check warning on line 103 in src/AnnotationsReader/BasicAnnotationsReader.ts

View workflow job for this annotation

GitHub Actions / Test (windows-latest)

Unsafe assignment of an `any` value
if (BasicAnnotationsReader.jsonTags.has(jsDocTag.name)) {
return parsed;
} else if (this.extraTags?.has(jsDocTag.name)) {
Expand All @@ -114,7 +114,7 @@
private parseJson(value: string): any {
try {
return json5.parse(value);
} catch (e) {
} catch {
return undefined;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/AnnotationsReader/ExtendedAnnotationsReader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ export class ExtendedAnnotationsReader extends BasicAnnotationsReader {
const text = (example.text ?? []).map((part) => part.text).join("");
try {
examples.push(json5.parse(text));
} catch (e) {
} catch {
// ignore examples which don't parse to valid JSON
// This could be improved to support a broader range of usages,
// such as if the example has a title (as explained in the tsdoc spec).
Expand Down
2 changes: 1 addition & 1 deletion src/NodeParser/PrefixUnaryExpressionNodeParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export class PrefixUnaryExpressionNodeParser implements SubNodeParser {
case ts.SyntaxKind.PlusToken:
return new LiteralType(+operand.getValue());
case ts.SyntaxKind.MinusToken:
return new LiteralType(-operand.getValue());
return new LiteralType(-(operand.getValue() as number));
case ts.SyntaxKind.TildeToken:
return new LiteralType(~operand.getValue());
case ts.SyntaxKind.ExclamationToken:
Expand Down
1 change: 1 addition & 0 deletions test/config.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { describe, it, expect } from "vitest";
import Ajv from "ajv";
import addFormats from "ajv-formats";
import { readFileSync, writeFileSync } from "fs";
Expand Down
1 change: 1 addition & 0 deletions test/invalid-data.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { describe, it, expect } from "vitest";
import { resolve } from "path";
import ts from "typescript";
import { createFormatter } from "../factory/formatter";
Expand Down
1 change: 1 addition & 0 deletions test/minify/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { describe, it, expect } from "vitest";
import { execSync } from "child_process";
import path from "path";

Expand Down
1 change: 1 addition & 0 deletions test/sourceless-nodes/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { describe, it, expect } from "vitest";
import path from "path";
import ts from "typescript";
import { createParser } from "../../factory";
Expand Down
1 change: 1 addition & 0 deletions test/sourceless-nodes/key/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { describe, it, expect } from "vitest";
import path from "path";
import ts from "typescript";
import { createParser } from "../../../factory";
Expand Down
1 change: 1 addition & 0 deletions test/unit/AnnotatedTypeFormatter.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { describe, it, expect } from "vitest";
import { makeNullable } from "../../src/TypeFormatter/AnnotatedTypeFormatter.js";

describe("makeNullable", () => {
Expand Down
1 change: 1 addition & 0 deletions test/unit/String.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { describe, it, expect } from "vitest";
import { strip } from "../../src/Utils/String";

describe("strip", () => {
Expand Down
1 change: 1 addition & 0 deletions test/unit/Type/HiddenType.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { describe, it, expect } from "vitest";
import { HiddenType } from "../../../src/Type/HiddenType.js";
import { NeverType } from "../../../src/Type/NeverType.js";

Expand Down
1 change: 1 addition & 0 deletions test/unit/deepMerge.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { describe, it, expect } from "vitest";
import { deepMerge } from "../../src/Utils/deepMerge.js";

describe("deepMerge", () => {
Expand Down
1 change: 1 addition & 0 deletions test/unit/intersectionOfArrays.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { describe, it, expect } from "vitest";
import { intersectionOfArrays } from "../../src/Utils/intersectionOfArrays.js";

describe("intersectionOfArrays", () => {
Expand Down
1 change: 1 addition & 0 deletions test/unit/isAssignableTo.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { describe, it, expect } from "vitest";
import { AliasType } from "../../src/Type/AliasType.js";
import { AnnotatedType } from "../../src/Type/AnnotatedType.js";
import { AnyType } from "../../src/Type/AnyType.js";
Expand Down
1 change: 1 addition & 0 deletions test/utils.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { expect } from "vitest";
import Ajv, { Options as AjvOptions } from "ajv";
import addFormats from "ajv-formats";
import { readFileSync, writeFileSync } from "fs";
Expand Down
1 change: 1 addition & 0 deletions test/valid-data-annotations.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { describe, it, expect } from "vitest";
import { assertValidSchema } from "./utils";
import * as annotationDefaultSamples from "./valid-data/annotation-default/samples";

Expand Down
1 change: 1 addition & 0 deletions test/valid-data-other.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { describe, it } from "vitest";
import { assertValidSchema } from "./utils";
import * as objectRequiredSamples from "./valid-data/object-required/samples";

Expand Down
1 change: 1 addition & 0 deletions test/valid-data-struct.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { describe, it } from "vitest";
import { assertValidSchema } from "./utils";

describe("valid-data-struct", () => {
Expand Down
1 change: 1 addition & 0 deletions test/valid-data-type.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { describe, it } from "vitest";
import { assertValidSchema } from "./utils";

describe("valid-data-type", () => {
Expand Down
1 change: 1 addition & 0 deletions test/vega-lite.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { describe, it, expect } from "vitest";
import { readFileSync, writeFileSync } from "fs";
import { resolve } from "path";
import { CompletedConfig, DEFAULT_CONFIG } from "../src/Config.js";
Expand Down
33 changes: 33 additions & 0 deletions test/vega-lite/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -28308,6 +28308,11 @@
],
"description": "For text marks, the vertical text baseline. One of `\"alphabetic\"` (default), `\"top\"`, `\"middle\"`, `\"bottom\"`, `\"line-top\"`, `\"line-bottom\"`, or an expression reference that provides one of the valid values. The `\"line-top\"` and `\"line-bottom\"` values operate similarly to `\"top\"` and `\"bottom\"`, but are calculated relative to the `lineHeight` rather than `fontSize` alone.\n\nFor range marks, the vertical alignment of the marks. One of `\"top\"`, `\"middle\"`, `\"bottom\"`.\n\n__Note:__ Expression reference is *not* supported for range marks."
},
"binSpacing": {
"description": "Offset between bars for binned field. The ideal value for this is either 0 (preferred by statisticians) or 1 (Vega-Lite default, D3 example style).\n\n__Default value:__ `1`",
"minimum": 0,
"type": "number"
},
"blend": {
"anyOf": [
{
Expand All @@ -28333,6 +28338,11 @@
],
"description": "Default color.\n\n__Default value:__ <span style=\"color: #4682b4;\">&#9632;</span> `\"#4682b4\"`\n\n__Note:__\n- This property cannot be used in a [style config](https://vega.github.io/vega-lite/docs/mark.html#style-config).\n- The `fill` and `stroke` properties have higher precedence than `color` and will override `color`."
},
"continuousBandSize": {
"description": "The default size of the bars on continuous scales.\n\n__Default value:__ `5`",
"minimum": 0,
"type": "number"
},
"cornerRadius": {
"anyOf": [
{
Expand Down Expand Up @@ -28421,6 +28431,18 @@
}
]
},
"discreteBandSize": {
"anyOf": [
{
"type": "number"
},
{
"$ref": "#/definitions/RelativeBandSize"
}
],
"description": "The default size of the bars with discrete dimensions. If unspecified, the default size is `step-2`, which provides 2 pixel offset between bars.",
"minimum": 0
},
"dx": {
"anyOf": [
{
Expand Down Expand Up @@ -28633,6 +28655,17 @@
}
]
},
"minBandSize": {
"anyOf": [
{
"type": "number"
},
{
"$ref": "#/definitions/ExprRef"
}
],
"description": "The minimum band size for bar and rectangle marks. __Default value:__ `0.25`"
},
"opacity": {
"anyOf": [
{
Expand Down
Loading
Loading