Skip to content

Commit

Permalink
Merge branch 'main' into add-previewFeatures-option
Browse files Browse the repository at this point in the history
  • Loading branch information
mrazauskas committed Feb 21, 2024
2 parents a92b295 + 4537ed1 commit 5a6917f
Show file tree
Hide file tree
Showing 25 changed files with 963 additions and 965 deletions.
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"cspell.config.json": "jsonc",
"dprint.json": "jsonc",
"eslint.config.json": "jsonc",
"mocha.config.json": "jsonc",
"tstyche.config.json": "jsonc"
},
"typescript.preferences.importModuleSpecifierEnding": "js",
Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## [1.0.0] - 2024-02-20

_Stable release based on [1.0.0-rc.2]._

## [1.0.0-rc.2] - 2024-02-14

### Fixed
Expand Down Expand Up @@ -136,6 +140,7 @@

_First pre-release._

[1.0.0]: https://github.com/tstyche/tstyche/releases/tag/v1.0.0
[1.0.0-rc.2]: https://github.com/tstyche/tstyche/releases/tag/v1.0.0-rc.2
[1.0.0-rc.1]: https://github.com/tstyche/tstyche/releases/tag/v1.0.0-rc.1
[1.0.0-rc]: https://github.com/tstyche/tstyche/releases/tag/v1.0.0-rc
Expand Down
4 changes: 2 additions & 2 deletions dprint.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
"exportDeclaration.sortNamedExports": "maintain",
"importDeclaration.sortNamedImports": "maintain"
},
"excludes": ["coverage/**", "build/**", "models/*.*", "node_modules/**"],
"excludes": [".cache/**", "coverage/**", "build/**", "models/*.*", "node_modules/**"],

"plugins": [
"https://plugins.dprint.dev/typescript-0.88.9.wasm",
"https://plugins.dprint.dev/typescript-0.89.1.wasm",
"https://plugins.dprint.dev/json-0.19.1.wasm",
"https://plugins.dprint.dev/markdown-0.16.3.wasm"
]
Expand Down
10 changes: 1 addition & 9 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,9 @@
/** @type {import("jest").Config} */
const config = {
extensionsToTreatAsEsm: [".ts", ".tsx"],
injectGlobals: false,
moduleNameMapper: {
["^#(.*)$"]: "<rootDir>/source/$1",
["^(\\.{1,2}/.*)\\.js$"]: "$1",
},
modulePathIgnorePatterns: ["\\.generated"],
randomize: true,
testMatch: ["**/tests/*.test.js"],
testTimeout: 75000,
transform: {
["\\.tsx?$"]: "./tests/__scripts__/jest-ts-transformer.js",
},
workerThreads: true,
};

Expand Down
5 changes: 5 additions & 0 deletions mocha.config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"$schema": "https://json.schemastore.org/mocharc",
"parallel": true,
"spec": ["source/**/__tests__/*.test.js"]
}
21 changes: 12 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "tstyche",
"version": "1.0.0-rc.2",
"version": "1.0.0",
"description": "The Essential Type Testing Tool.",
"keywords": [
"typescript",
Expand Down Expand Up @@ -50,22 +50,25 @@
"lint": "eslint ./ --config eslint.config.json --ext .js,.cts,.ts,.tsx",
"prepack": "yarn clean && yarn build",
"prepublish": "yarn test",
"test": "NODE_OPTIONS='--experimental-vm-modules --no-warnings' jest --config jest.config.js",
"test": "yarn test:unit && yarn test:e2e",
"test:coverage": "yarn build --sourcemap && c8 --config c8.config.json yarn test:e2e",
"test:e2e": "yarn test --testMatch '**/tests/*.test.js'",
"test:e2e": "NODE_OPTIONS='--experimental-vm-modules --no-warnings' jest --config jest.config.js",
"test:examples": "tstyche examples",
"test:types": "tstyche tests",
"test:unit": "yarn test --testMatch '**/source/**/__tests__/*.test.ts?(x)'"
"test:unit": "mocha --config mocha.config.json"
},
"devDependencies": {
"@jest/globals": "29.7.0",
"@rollup/plugin-typescript": "11.1.6",
"@types/chai": "4.3.11",
"@types/mocha": "10.0.6",
"@types/node": "20.11.19",
"@typescript-eslint/eslint-plugin": "7.0.1",
"@typescript-eslint/parser": "7.0.1",
"@typescript-eslint/eslint-plugin": "7.0.2",
"@typescript-eslint/parser": "7.0.2",
"ajv": "8.12.0",
"c8": "9.1.0",
"cspell": "8.3.2",
"chai": "5.1.0",
"cspell": "8.4.1",
"dprint": "0.45.0",
"eslint": "8.56.0",
"eslint-import-resolver-typescript": "3.6.1",
Expand All @@ -74,11 +77,11 @@
"eslint-plugin-jest-formatting": "3.1.0",
"eslint-plugin-simple-import-sort": "12.0.0",
"jest": "29.7.0",
"jest-serializer-ansi-escapes": "2.0.1",
"magic-string": "0.30.7",
"mocha": "10.3.0",
"pretty-ansi": "2.0.0",
"rollup": "4.12.0",
"rollup-plugin-dts": "6.1.0",
"ts-node": "10.9.2",
"tslib": "2.6.2",
"typescript": "5.3.3"
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
import { describe, expect, test } from "@jest/globals";
import { Scribbler } from "#scribbler";
import { describeNameText } from "../describeNameText.js";
import { expect } from "chai";
import { describe, test } from "mocha";
import { describeNameText, Scribbler } from "tstyche/tstyche";

const scribbler = new Scribbler();

describe("describeNameText", () => {
test("describe name text", () => {
const text = scribbler.render(describeNameText("sample describe name"));

expect(text).toMatchInlineSnapshot(`
" sample describe name
"
`);
expect(text).to.equal([
" sample describe name",
"",
].join("\n"));
});

test("describe name text with indent", () => {
const text = scribbler.render(describeNameText("sample describe name", 2));

expect(text).toMatchInlineSnapshot(`
" sample describe name
"
`);
expect(text).to.equal([
" sample describe name",
"",
].join("\n"));
});
});
31 changes: 31 additions & 0 deletions source/output/__tests__/diagnosticText.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { expect } from "chai";
import { describe, test } from "mocha";
import prettyAnsi from "pretty-ansi";
import { Diagnostic, diagnosticText, Scribbler } from "tstyche/tstyche";

const scribbler = new Scribbler();

describe("diagnosticText", () => {
test("formats diagnostic text", () => {
const text = scribbler.render(diagnosticText(Diagnostic.error("sample text")));

expect(prettyAnsi(text)).to.equal([
"<red>Error: </>sample text",
"",
"",
].join("\n"));
});

test("formats diagnostic text with more than two lines", () => {
const text = scribbler.render(diagnosticText(Diagnostic.error(["sample text", "with more than", "two lines"])));

expect(prettyAnsi(text)).to.equal([
"<red>Error: </>sample text",
"",
"with more than",
"two lines",
"",
"",
].join("\n"));
});
});
34 changes: 0 additions & 34 deletions source/output/__tests__/diagnosticText.test.ts

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
import { URL } from "node:url";
import { describe, expect, test } from "@jest/globals";
import ansiEscapesSerializer from "jest-serializer-ansi-escapes";
import { ResultStatus } from "#result";
import { Scribbler } from "#scribbler";
import { fileStatusText } from "../fileStatusText.js";

expect.addSnapshotSerializer(ansiEscapesSerializer);
import { expect } from "chai";
import { describe, test } from "mocha";
import prettyAnsi from "pretty-ansi";
import { fileStatusText, ResultStatus, Scribbler } from "tstyche/tstyche";

const sampleTestFile = new URL("../../../path/to/sample.test.ts", import.meta.url);

Expand All @@ -15,27 +12,27 @@ describe("fileStatusText", () => {
test("formats failing file status text", () => {
const text = scribbler.render(fileStatusText(ResultStatus.Failed, sampleTestFile));

expect(text).toMatchInlineSnapshot(`
"<red>fail</> <gray>./path/to/</>sample.test.ts
"
`);
expect(prettyAnsi(text)).to.equal([
"<red>fail</> <gray>./path/to/</>sample.test.ts",
"",
].join("\n"));
});

test("formats passing file status text", () => {
const text = scribbler.render(fileStatusText(ResultStatus.Passed, sampleTestFile));

expect(text).toMatchInlineSnapshot(`
"<green>pass</> <gray>./path/to/</>sample.test.ts
"
`);
expect(prettyAnsi(text)).to.equal([
"<green>pass</> <gray>./path/to/</>sample.test.ts",
"",
].join("\n"));
});

test("formats running file status text", () => {
const text = scribbler.render(fileStatusText(ResultStatus.Runs, sampleTestFile));

expect(text).toMatchInlineSnapshot(`
"<yellow>runs</> <gray>./path/to/</>sample.test.ts
"
`);
expect(prettyAnsi(text)).to.equal([
"<yellow>runs</> <gray>./path/to/</>sample.test.ts",
"",
].join("\n"));
});
});
54 changes: 0 additions & 54 deletions source/output/__tests__/fileViewText.test.tsx

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,42 +1,42 @@
import { describe, expect, test } from "@jest/globals";
import { Scribbler } from "#scribbler";
import { formattedText } from "../formattedText.js";
import { expect } from "chai";
import { describe, test } from "mocha";
import { formattedText, Scribbler } from "tstyche/tstyche";

const scribbler = new Scribbler();

describe("formattedText", () => {
test("formats string", () => {
const string = scribbler.render(formattedText("1.2.3"));

expect(string).toMatchInlineSnapshot(`
"1.2.3
"
`);
expect(string).to.equal([
"1.2.3",
"",
].join("\n"));
});

test("formats list", () => {
const list = scribbler.render(formattedText(["path/to/first.test.ts", "path/to/second.test.ts"]));

expect(list).toMatchInlineSnapshot(`
"[
"path/to/first.test.ts",
"path/to/second.test.ts"
]
"
`);
expect(list).to.equal([
"[",
' "path/to/first.test.ts",',
' "path/to/second.test.ts"',
"]",
"",
].join("\n"));
});

test("formats object", () => {
// eslint-disable-next-line sort-keys -- testing purpose
const record = scribbler.render(formattedText({ k: "keys", a: "all", s: "sorted" }));

expect(record).toMatchInlineSnapshot(`
"{
"a": "all",
"k": "keys",
"s": "sorted"
}
"
`);
expect(record).to.equal([
"{",
' "a": "all",',
' "k": "keys",',
' "s": "sorted"',
"}",
"",
].join("\n"));
});
});
Loading

0 comments on commit 5a6917f

Please sign in to comment.