From f0e6407b32d9293b6cbc4a2743e2392adb072dee Mon Sep 17 00:00:00 2001 From: spiltcoffee Date: Sat, 24 Apr 2021 23:20:32 +1000 Subject: [PATCH] refactor: large refactor of testing framework and related aspects fix #221 --- .circleci/config.yml | 56 ++++++++++++++++--- .gitignore | 3 +- jest.config.json | 31 ---------- package.json | 2 +- packages/@postdfm/ast/jest.config.cjs | 1 + packages/@postdfm/ast/package.json | 1 + .../ast/{__test__ => test}/item.test.ts | 0 .../ast/{__test__ => test}/list.test.ts | 0 .../ast/{__test__ => test}/object.test.ts | 0 .../ast/{__test__ => test}/property.test.ts | 0 .../ast/{__test__ => test}/root.test.ts | 0 .../ast/{__test__ => test}/value.test.ts | 0 packages/@postdfm/ast/typedoc.config.cjs | 5 +- .../ast2dfm/__test__/fixtures/index.test.ts | 24 -------- packages/@postdfm/ast2dfm/jest.config.cjs | 1 + packages/@postdfm/ast2dfm/package.json | 1 + .../{__test__ => test}/broken/ast.json | 0 .../{__test__ => test}/broken/index.test.ts | 0 .../ast2dfm/test/fixtures/index.test.ts | 28 ++++++++++ packages/@postdfm/ast2dfm/typedoc.config.cjs | 5 +- packages/@postdfm/dfm2ast/jest.config.cjs | 1 + packages/@postdfm/dfm2ast/package.json | 1 + .../{__test__ => test}/broken/form.dfm | 0 .../{__test__ => test}/broken/index.test.ts | 0 .../{__test__ => test}/fixtures/index.test.ts | 2 +- packages/@postdfm/dfm2ast/typedoc.config.cjs | 5 +- packages/@postdfm/plugin/jest.config.cjs | 1 + packages/@postdfm/plugin/package.json | 1 + .../{__test__ => test}/plugin/index.test.ts | 0 packages/@postdfm/plugin/typedoc.config.cjs | 5 +- packages/@postdfm/transform/jest.config.cjs | 1 + packages/@postdfm/transform/package.json | 1 + .../{__test__ => test}/broken/index.test.ts | 0 .../{__test__ => test}/fixtures/index.test.ts | 2 +- .../@postdfm/transform/typedoc.config.cjs | 5 +- packages/postdfm/jest.config.cjs | 1 + packages/postdfm/package.json | 1 + .../{__test__ => test}/broken/index.test.ts | 0 .../broken/invalidProperty.dfm | 0 .../broken/unexpectedEnd.dfm | 0 .../{__test__ => test}/fixtures/index.test.ts | 4 +- .../{__test__ => test}/options/index.test.ts | 0 .../{__test__ => test}/options/parser.js | 0 .../{__test__ => test}/options/plugin.js | 0 .../{__test__ => test}/options/stringifier.js | 0 packages/postdfm/typedoc.config.cjs | 5 +- .../fixtures}/parse/boundary-keyword/ast.json | 0 .../fixtures}/parse/boundary-keyword/form.dfm | 0 .../fixtures}/parse/empty-file/ast.json | 0 .../fixtures}/parse/empty-file/form.dfm | 0 .../fixtures}/parse/empty-object/ast.json | 0 .../fixtures}/parse/empty-object/form.dfm | 0 .../fixtures}/parse/everything/ast.json | 0 .../fixtures}/parse/everything/form.dfm | 0 .../fixtures}/parse/lists/ast.json | 0 .../fixtures}/parse/lists/form.dfm | 0 .../fixtures}/parse/no-type/ast.json | 0 .../fixtures}/parse/no-type/form.dfm | 0 .../fixtures}/parse/objects/ast.json | 0 .../fixtures}/parse/objects/form.dfm | 0 .../fixtures}/parse/properties/ast.json | 0 .../fixtures}/parse/properties/form.dfm | 0 .../fixtures}/parse/strings/ast.json | 0 .../fixtures}/parse/strings/form.dfm | 0 .../fixtures}/parse/weird-spacing/ast.json | 0 .../fixtures}/parse/weird-spacing/form.dfm | 0 .../fixtures}/transform/everything/cis.dfm | 0 .../fixtures}/transform/everything/cis.json | 0 .../fixtures}/transform/everything/plugin.js | 0 .../fixtures}/transform/everything/trans.dfm | 0 .../fixtures}/transform/everything/trans.json | 0 .../fixtures}/transform/hello-world/cis.dfm | 0 .../fixtures}/transform/hello-world/cis.json | 0 .../fixtures}/transform/hello-world/plugin.js | 0 .../fixtures}/transform/hello-world/trans.dfm | 0 .../transform/hello-world/trans.json | 0 test/jest-preset.cjs | 31 ++++++++++ typedoc.config.cjs | 18 +++--- 78 files changed, 137 insertions(+), 106 deletions(-) delete mode 100644 jest.config.json create mode 100644 packages/@postdfm/ast/jest.config.cjs rename packages/@postdfm/ast/{__test__ => test}/item.test.ts (100%) rename packages/@postdfm/ast/{__test__ => test}/list.test.ts (100%) rename packages/@postdfm/ast/{__test__ => test}/object.test.ts (100%) rename packages/@postdfm/ast/{__test__ => test}/property.test.ts (100%) rename packages/@postdfm/ast/{__test__ => test}/root.test.ts (100%) rename packages/@postdfm/ast/{__test__ => test}/value.test.ts (100%) delete mode 100644 packages/@postdfm/ast2dfm/__test__/fixtures/index.test.ts create mode 100644 packages/@postdfm/ast2dfm/jest.config.cjs rename packages/@postdfm/ast2dfm/{__test__ => test}/broken/ast.json (100%) rename packages/@postdfm/ast2dfm/{__test__ => test}/broken/index.test.ts (100%) create mode 100644 packages/@postdfm/ast2dfm/test/fixtures/index.test.ts create mode 100644 packages/@postdfm/dfm2ast/jest.config.cjs rename packages/@postdfm/dfm2ast/{__test__ => test}/broken/form.dfm (100%) rename packages/@postdfm/dfm2ast/{__test__ => test}/broken/index.test.ts (100%) rename packages/@postdfm/dfm2ast/{__test__ => test}/fixtures/index.test.ts (94%) create mode 100644 packages/@postdfm/plugin/jest.config.cjs rename packages/@postdfm/plugin/{__test__ => test}/plugin/index.test.ts (100%) create mode 100644 packages/@postdfm/transform/jest.config.cjs rename packages/@postdfm/transform/{__test__ => test}/broken/index.test.ts (100%) rename packages/@postdfm/transform/{__test__ => test}/fixtures/index.test.ts (95%) create mode 100644 packages/postdfm/jest.config.cjs rename packages/postdfm/{__test__ => test}/broken/index.test.ts (100%) rename packages/postdfm/{__test__ => test}/broken/invalidProperty.dfm (100%) rename packages/postdfm/{__test__ => test}/broken/unexpectedEnd.dfm (100%) rename packages/postdfm/{__test__ => test}/fixtures/index.test.ts (95%) rename packages/postdfm/{__test__ => test}/options/index.test.ts (100%) rename packages/postdfm/{__test__ => test}/options/parser.js (100%) rename packages/postdfm/{__test__ => test}/options/plugin.js (100%) rename packages/postdfm/{__test__ => test}/options/stringifier.js (100%) rename {__test__/__fixtures__ => test/fixtures}/parse/boundary-keyword/ast.json (100%) rename {__test__/__fixtures__ => test/fixtures}/parse/boundary-keyword/form.dfm (100%) rename {__test__/__fixtures__ => test/fixtures}/parse/empty-file/ast.json (100%) rename {__test__/__fixtures__ => test/fixtures}/parse/empty-file/form.dfm (100%) rename {__test__/__fixtures__ => test/fixtures}/parse/empty-object/ast.json (100%) rename {__test__/__fixtures__ => test/fixtures}/parse/empty-object/form.dfm (100%) rename {__test__/__fixtures__ => test/fixtures}/parse/everything/ast.json (100%) rename {__test__/__fixtures__ => test/fixtures}/parse/everything/form.dfm (100%) rename {__test__/__fixtures__ => test/fixtures}/parse/lists/ast.json (100%) rename {__test__/__fixtures__ => test/fixtures}/parse/lists/form.dfm (100%) rename {__test__/__fixtures__ => test/fixtures}/parse/no-type/ast.json (100%) rename {__test__/__fixtures__ => test/fixtures}/parse/no-type/form.dfm (100%) rename {__test__/__fixtures__ => test/fixtures}/parse/objects/ast.json (100%) rename {__test__/__fixtures__ => test/fixtures}/parse/objects/form.dfm (100%) rename {__test__/__fixtures__ => test/fixtures}/parse/properties/ast.json (100%) rename {__test__/__fixtures__ => test/fixtures}/parse/properties/form.dfm (100%) rename {__test__/__fixtures__ => test/fixtures}/parse/strings/ast.json (100%) rename {__test__/__fixtures__ => test/fixtures}/parse/strings/form.dfm (100%) rename {__test__/__fixtures__ => test/fixtures}/parse/weird-spacing/ast.json (100%) rename {__test__/__fixtures__ => test/fixtures}/parse/weird-spacing/form.dfm (100%) rename {__test__/__fixtures__ => test/fixtures}/transform/everything/cis.dfm (100%) rename {__test__/__fixtures__ => test/fixtures}/transform/everything/cis.json (100%) rename {__test__/__fixtures__ => test/fixtures}/transform/everything/plugin.js (100%) rename {__test__/__fixtures__ => test/fixtures}/transform/everything/trans.dfm (100%) rename {__test__/__fixtures__ => test/fixtures}/transform/everything/trans.json (100%) rename {__test__/__fixtures__ => test/fixtures}/transform/hello-world/cis.dfm (100%) rename {__test__/__fixtures__ => test/fixtures}/transform/hello-world/cis.json (100%) rename {__test__/__fixtures__ => test/fixtures}/transform/hello-world/plugin.js (100%) rename {__test__/__fixtures__ => test/fixtures}/transform/hello-world/trans.dfm (100%) rename {__test__/__fixtures__ => test/fixtures}/transform/hello-world/trans.json (100%) create mode 100644 test/jest-preset.cjs diff --git a/.circleci/config.yml b/.circleci/config.yml index 60f0dd05..1841c44c 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -27,7 +27,7 @@ jobs: - save_cache: paths: - node_modules - - packages/postdfm/node_modules + # for nearleyc - packages/@postdfm/dfm2ast/node_modules key: node-{{ .Environment.CACHE_VERSION }}-dependencies-{{ checksum "yarn.lock" }} @@ -89,10 +89,46 @@ jobs: - run: yarn test - store_test_results: - path: test-results + path: ~/repo/packages/postdfm/results - codecov/upload: - file: coverage/lcov.info + flags: "postdfm" + file: ~/repo/packages/postdfm/results/lcov/coverage.info + + - store_test_results: + path: ~/repo/packages/@postdfm/ast/results + + - codecov/upload: + flags: "@postdfm/ast" + file: ~/repo/packages/@postdfm/ast/results/lcov/coverage.info + + - store_test_results: + path: ~/repo/packages/@postdfm/ast2dfm/results + + - codecov/upload: + flags: "@postdfm/ast2dfm" + file: ~/repo/packages/@postdfm/ast2dfm/results/lcov/coverage.info + + - store_test_results: + path: ~/repo/packages/@postdfm/dfm2ast/results + + - codecov/upload: + flags: "@postdfm/dfm2ast" + file: ~/repo/packages/@postdfm/dfm2ast/results/lcov/coverage.info + + - store_test_results: + path: ~/repo/packages/@postdfm/plugin/results + + - codecov/upload: + flags: "@postdfm/plugin" + file: ~/repo/packages/@postdfm/plugin/results/lcov/coverage.info + + - store_test_results: + path: ~/repo/packages/@postdfm/transform/results + + - codecov/upload: + flags: "@postdfm/transform" + file: ~/repo/packages/@postdfm/transform/results/lcov/coverage.info docs: executor: node-executor @@ -107,10 +143,11 @@ jobs: - run: yarn docs - - persist_to_workspace: - root: docs - paths: - - ./* + # currently not used for anything + # - persist_to_workspace: + # root: docs + # paths: + # - ./* release: executor: node-executor @@ -123,8 +160,9 @@ jobs: - attach_workspace: at: ~/repo/packages - - attach_workspace: - at: ~/repo/docs + # currently not used for anything + # - attach_workspace: + # at: ~/repo/docs - run: yarn release diff --git a/.gitignore b/.gitignore index 16e9ce90..d2f67478 100644 --- a/.gitignore +++ b/.gitignore @@ -82,8 +82,7 @@ typings/ # js dist -# jest-junit -test-results +results/ # nearley.js packages/@postdfm/dfm2ast/src/grammar.ts diff --git a/jest.config.json b/jest.config.json deleted file mode 100644 index dcf4304d..00000000 --- a/jest.config.json +++ /dev/null @@ -1,31 +0,0 @@ -{ - "reporters": [ - "default", - [ - "jest-junit", - { - "usePathForSuiteName": "true", - "classNameTemplate": "[{classname}]", - "titleTemplate": "{title}", - "outputDirectory": "test-results/jest", - "outputName": "./report.xml" - } - ] - ], - "preset": "ts-jest/presets/default-esm", - "extensionsToTreatAsEsm": [".ts"], - "globals": { - "ts-jest": { - "useESM": true - } - }, - "transform": { - "^.+\\.tsx?$": "ts-jest" - }, - "resolver": "/test/resolver.cjs", - "collectCoverage": true, - "collectCoverageFrom": ["**/dist/**/*.js", "!**/node_modules/**"], - "coverageReporters": ["lcov", "text"], - "coverageDirectory": "coverage", - "rootDir": "./" -} diff --git a/package.json b/package.json index 0184f26e..6eaf550b 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,7 @@ "format:fix": "yarn format --write --list-different", "format:check": "yarn format --check", "compile": "yarn workspaces run compile", - "test": "cross-env NODE_OPTIONS=--experimental-vm-modules jest --coverage --verbose --maxWorkers=16", + "test": "yarn workspaces run test", "docs": "yarn workspaces run docs", "release": "semantic-release", "snyk-protect": "snyk protect", diff --git a/packages/@postdfm/ast/jest.config.cjs b/packages/@postdfm/ast/jest.config.cjs new file mode 100644 index 00000000..7db7edb9 --- /dev/null +++ b/packages/@postdfm/ast/jest.config.cjs @@ -0,0 +1 @@ +module.exports = require("../../../test/jest-preset.cjs")("@postdfm/ast"); diff --git a/packages/@postdfm/ast/package.json b/packages/@postdfm/ast/package.json index 22436293..3d83de91 100644 --- a/packages/@postdfm/ast/package.json +++ b/packages/@postdfm/ast/package.json @@ -16,6 +16,7 @@ }, "scripts": { "compile": "tsc --listEmittedFiles", + "test": "cross-env NODE_OPTIONS=--experimental-vm-modules jest --coverage --verbose", "docs": "typedoc --options typedoc.config.cjs" }, "author": "SpiltCoffee", diff --git a/packages/@postdfm/ast/__test__/item.test.ts b/packages/@postdfm/ast/test/item.test.ts similarity index 100% rename from packages/@postdfm/ast/__test__/item.test.ts rename to packages/@postdfm/ast/test/item.test.ts diff --git a/packages/@postdfm/ast/__test__/list.test.ts b/packages/@postdfm/ast/test/list.test.ts similarity index 100% rename from packages/@postdfm/ast/__test__/list.test.ts rename to packages/@postdfm/ast/test/list.test.ts diff --git a/packages/@postdfm/ast/__test__/object.test.ts b/packages/@postdfm/ast/test/object.test.ts similarity index 100% rename from packages/@postdfm/ast/__test__/object.test.ts rename to packages/@postdfm/ast/test/object.test.ts diff --git a/packages/@postdfm/ast/__test__/property.test.ts b/packages/@postdfm/ast/test/property.test.ts similarity index 100% rename from packages/@postdfm/ast/__test__/property.test.ts rename to packages/@postdfm/ast/test/property.test.ts diff --git a/packages/@postdfm/ast/__test__/root.test.ts b/packages/@postdfm/ast/test/root.test.ts similarity index 100% rename from packages/@postdfm/ast/__test__/root.test.ts rename to packages/@postdfm/ast/test/root.test.ts diff --git a/packages/@postdfm/ast/__test__/value.test.ts b/packages/@postdfm/ast/test/value.test.ts similarity index 100% rename from packages/@postdfm/ast/__test__/value.test.ts rename to packages/@postdfm/ast/test/value.test.ts diff --git a/packages/@postdfm/ast/typedoc.config.cjs b/packages/@postdfm/ast/typedoc.config.cjs index 5a4e0ed3..530d4194 100644 --- a/packages/@postdfm/ast/typedoc.config.cjs +++ b/packages/@postdfm/ast/typedoc.config.cjs @@ -1,4 +1 @@ -module.exports = require("../../../typedoc.config.cjs")({ - entryPoints: ["src/index.ts"], - out: "@postdfm/ast" -}); +module.exports = require("../../../typedoc.config.cjs")("@postdfm/ast"); diff --git a/packages/@postdfm/ast2dfm/__test__/fixtures/index.test.ts b/packages/@postdfm/ast2dfm/__test__/fixtures/index.test.ts deleted file mode 100644 index 45cbcda2..00000000 --- a/packages/@postdfm/ast2dfm/__test__/fixtures/index.test.ts +++ /dev/null @@ -1,24 +0,0 @@ -import path from "path"; -import { readdirSync, readFileSync } from "fs"; - -import { Root } from "@postdfm/ast"; -import { stringify } from "@postdfm/ast2dfm"; - -const rootFixturesDir = path.join("__test__", "__fixtures__"); -const parseFixturesDir = path.join(rootFixturesDir, "parse"); - -describe("dfm2ast", () => { - describe("parse fixtures", () => { - const fixtures = readdirSync(parseFixturesDir); - fixtures.forEach((fixture) => { - const astFile = path.join(parseFixturesDir, fixture, "ast.json"); - const formFile = path.join(parseFixturesDir, fixture, "form.dfm"); - - test(`${fixture}`, () => { - expect( - stringify(JSON.parse(readFileSync(astFile, "utf8")) as Root) - ).toEqual(readFileSync(formFile, "ascii")); - }); - }); - }); -}); diff --git a/packages/@postdfm/ast2dfm/jest.config.cjs b/packages/@postdfm/ast2dfm/jest.config.cjs new file mode 100644 index 00000000..e3276e89 --- /dev/null +++ b/packages/@postdfm/ast2dfm/jest.config.cjs @@ -0,0 +1 @@ +module.exports = require("../../../test/jest-preset.cjs")("@postdfm/ast2dfm"); diff --git a/packages/@postdfm/ast2dfm/package.json b/packages/@postdfm/ast2dfm/package.json index 62aaf311..42c88311 100644 --- a/packages/@postdfm/ast2dfm/package.json +++ b/packages/@postdfm/ast2dfm/package.json @@ -16,6 +16,7 @@ }, "scripts": { "compile": "tsc --listEmittedFiles", + "test": "cross-env NODE_OPTIONS=--experimental-vm-modules jest --coverage --verbose", "docs": "typedoc --options typedoc.config.cjs" }, "author": "SpiltCoffee", diff --git a/packages/@postdfm/ast2dfm/__test__/broken/ast.json b/packages/@postdfm/ast2dfm/test/broken/ast.json similarity index 100% rename from packages/@postdfm/ast2dfm/__test__/broken/ast.json rename to packages/@postdfm/ast2dfm/test/broken/ast.json diff --git a/packages/@postdfm/ast2dfm/__test__/broken/index.test.ts b/packages/@postdfm/ast2dfm/test/broken/index.test.ts similarity index 100% rename from packages/@postdfm/ast2dfm/__test__/broken/index.test.ts rename to packages/@postdfm/ast2dfm/test/broken/index.test.ts diff --git a/packages/@postdfm/ast2dfm/test/fixtures/index.test.ts b/packages/@postdfm/ast2dfm/test/fixtures/index.test.ts new file mode 100644 index 00000000..cf331385 --- /dev/null +++ b/packages/@postdfm/ast2dfm/test/fixtures/index.test.ts @@ -0,0 +1,28 @@ +import { readdirSync, readFileSync } from "fs"; + +import { Root } from "@postdfm/ast"; +import { stringify } from "@postdfm/ast2dfm"; + +const parseFixturesPath = new URL( + "../../../../../test/fixtures/parse/", + import.meta.url +); + +describe("dfm2ast", () => { + describe("parse fixtures", () => { + const fixtures = readdirSync(parseFixturesPath); + fixtures.forEach((fixture) => { + const fixturePath = new URL(`./${fixture}/`, parseFixturesPath); + + test(`${fixture}`, () => { + expect( + stringify( + JSON.parse( + readFileSync(new URL("./ast.json", fixturePath), "utf8") + ) as Root + ) + ).toEqual(readFileSync(new URL("./form.dfm", fixturePath), "ascii")); + }); + }); + }); +}); diff --git a/packages/@postdfm/ast2dfm/typedoc.config.cjs b/packages/@postdfm/ast2dfm/typedoc.config.cjs index 80af0b68..b018e8f7 100644 --- a/packages/@postdfm/ast2dfm/typedoc.config.cjs +++ b/packages/@postdfm/ast2dfm/typedoc.config.cjs @@ -1,4 +1 @@ -module.exports = require("../../../typedoc.config.cjs")({ - entryPoints: ["src/index.ts"], - out: "@postdfm/ast2dfm" -}); +module.exports = require("../../../typedoc.config.cjs")("@postdfm/ast2dfm"); diff --git a/packages/@postdfm/dfm2ast/jest.config.cjs b/packages/@postdfm/dfm2ast/jest.config.cjs new file mode 100644 index 00000000..46f73cc4 --- /dev/null +++ b/packages/@postdfm/dfm2ast/jest.config.cjs @@ -0,0 +1 @@ +module.exports = require("../../../test/jest-preset.cjs")("@postdfm/dfm2ast"); diff --git a/packages/@postdfm/dfm2ast/package.json b/packages/@postdfm/dfm2ast/package.json index f199cab0..6a00365f 100644 --- a/packages/@postdfm/dfm2ast/package.json +++ b/packages/@postdfm/dfm2ast/package.json @@ -17,6 +17,7 @@ "scripts": { "precompile": "nearleyc ne/grammar.ne -o src/grammar.ts", "compile": "tsc --listEmittedFiles", + "test": "cross-env NODE_OPTIONS=--experimental-vm-modules jest --coverage --verbose", "docs": "typedoc --options typedoc.config.cjs" }, "author": "SpiltCoffee", diff --git a/packages/@postdfm/dfm2ast/__test__/broken/form.dfm b/packages/@postdfm/dfm2ast/test/broken/form.dfm similarity index 100% rename from packages/@postdfm/dfm2ast/__test__/broken/form.dfm rename to packages/@postdfm/dfm2ast/test/broken/form.dfm diff --git a/packages/@postdfm/dfm2ast/__test__/broken/index.test.ts b/packages/@postdfm/dfm2ast/test/broken/index.test.ts similarity index 100% rename from packages/@postdfm/dfm2ast/__test__/broken/index.test.ts rename to packages/@postdfm/dfm2ast/test/broken/index.test.ts diff --git a/packages/@postdfm/dfm2ast/__test__/fixtures/index.test.ts b/packages/@postdfm/dfm2ast/test/fixtures/index.test.ts similarity index 94% rename from packages/@postdfm/dfm2ast/__test__/fixtures/index.test.ts rename to packages/@postdfm/dfm2ast/test/fixtures/index.test.ts index 86270073..9e52190e 100644 --- a/packages/@postdfm/dfm2ast/__test__/fixtures/index.test.ts +++ b/packages/@postdfm/dfm2ast/test/fixtures/index.test.ts @@ -4,7 +4,7 @@ import { ASTNode } from "@postdfm/ast"; import { parse } from "@postdfm/dfm2ast"; const parseFixturesPath = new URL( - "../../../../../__test__/__fixtures__/parse/", + "../../../../../test/fixtures/parse/", import.meta.url ); diff --git a/packages/@postdfm/dfm2ast/typedoc.config.cjs b/packages/@postdfm/dfm2ast/typedoc.config.cjs index 5f8938e1..362d1a7e 100644 --- a/packages/@postdfm/dfm2ast/typedoc.config.cjs +++ b/packages/@postdfm/dfm2ast/typedoc.config.cjs @@ -1,4 +1 @@ -module.exports = require("../../../typedoc.config.cjs")({ - entryPoints: ["src/index.ts"], - out: "@postdfm/dfm2ast" -}); +module.exports = require("../../../typedoc.config.cjs")("@postdfm/dfm2ast"); diff --git a/packages/@postdfm/plugin/jest.config.cjs b/packages/@postdfm/plugin/jest.config.cjs new file mode 100644 index 00000000..dfbe6893 --- /dev/null +++ b/packages/@postdfm/plugin/jest.config.cjs @@ -0,0 +1 @@ +module.exports = require("../../../test/jest-preset.cjs")("@postdfm/plugin"); diff --git a/packages/@postdfm/plugin/package.json b/packages/@postdfm/plugin/package.json index 65af6cb0..dc49701c 100644 --- a/packages/@postdfm/plugin/package.json +++ b/packages/@postdfm/plugin/package.json @@ -16,6 +16,7 @@ }, "scripts": { "compile": "tsc --listEmittedFiles", + "test": "cross-env NODE_OPTIONS=--experimental-vm-modules jest --coverage --verbose", "docs": "typedoc --options typedoc.config.cjs" }, "author": "SpiltCoffee", diff --git a/packages/@postdfm/plugin/__test__/plugin/index.test.ts b/packages/@postdfm/plugin/test/plugin/index.test.ts similarity index 100% rename from packages/@postdfm/plugin/__test__/plugin/index.test.ts rename to packages/@postdfm/plugin/test/plugin/index.test.ts diff --git a/packages/@postdfm/plugin/typedoc.config.cjs b/packages/@postdfm/plugin/typedoc.config.cjs index 96d991f9..4141fbc7 100644 --- a/packages/@postdfm/plugin/typedoc.config.cjs +++ b/packages/@postdfm/plugin/typedoc.config.cjs @@ -1,4 +1 @@ -module.exports = require("../../../typedoc.config.cjs")({ - entryPoints: ["src/index.ts"], - out: "@postdfm/plugin", -}); +module.exports = require("../../../typedoc.config.cjs")("@postdfm/plugin"); diff --git a/packages/@postdfm/transform/jest.config.cjs b/packages/@postdfm/transform/jest.config.cjs new file mode 100644 index 00000000..7147c59b --- /dev/null +++ b/packages/@postdfm/transform/jest.config.cjs @@ -0,0 +1 @@ +module.exports = require("../../../test/jest-preset.cjs")("@postdfm/transform"); diff --git a/packages/@postdfm/transform/package.json b/packages/@postdfm/transform/package.json index 8a44bd35..8d32097b 100644 --- a/packages/@postdfm/transform/package.json +++ b/packages/@postdfm/transform/package.json @@ -16,6 +16,7 @@ }, "scripts": { "compile": "tsc --listEmittedFiles", + "test": "cross-env NODE_OPTIONS=--experimental-vm-modules jest --coverage --verbose", "docs": "typedoc --options typedoc.config.cjs" }, "author": "SpiltCoffee", diff --git a/packages/@postdfm/transform/__test__/broken/index.test.ts b/packages/@postdfm/transform/test/broken/index.test.ts similarity index 100% rename from packages/@postdfm/transform/__test__/broken/index.test.ts rename to packages/@postdfm/transform/test/broken/index.test.ts diff --git a/packages/@postdfm/transform/__test__/fixtures/index.test.ts b/packages/@postdfm/transform/test/fixtures/index.test.ts similarity index 95% rename from packages/@postdfm/transform/__test__/fixtures/index.test.ts rename to packages/@postdfm/transform/test/fixtures/index.test.ts index 7dd4ff4b..2554ed72 100644 --- a/packages/@postdfm/transform/__test__/fixtures/index.test.ts +++ b/packages/@postdfm/transform/test/fixtures/index.test.ts @@ -6,7 +6,7 @@ import { Plugin } from "@postdfm/plugin"; import { Transformer } from "@postdfm/transform"; const transformFixturesPath = new URL( - "../../../../../__test__/__fixtures__/transform/", + "../../../../../test/fixtures/transform/", import.meta.url ); diff --git a/packages/@postdfm/transform/typedoc.config.cjs b/packages/@postdfm/transform/typedoc.config.cjs index 3af5eaa8..a295c2af 100644 --- a/packages/@postdfm/transform/typedoc.config.cjs +++ b/packages/@postdfm/transform/typedoc.config.cjs @@ -1,4 +1 @@ -module.exports = require("../../../typedoc.config.cjs")({ - entryPoints: ["src/index.ts"], - out: "@postdfm/transform", -}); +module.exports = require("../../../typedoc.config.cjs")("@postdfm/transform"); diff --git a/packages/postdfm/jest.config.cjs b/packages/postdfm/jest.config.cjs new file mode 100644 index 00000000..7dd1efeb --- /dev/null +++ b/packages/postdfm/jest.config.cjs @@ -0,0 +1 @@ +module.exports = require("../../test/jest-preset.cjs")("postdfm"); diff --git a/packages/postdfm/package.json b/packages/postdfm/package.json index f023fca3..de98cb74 100644 --- a/packages/postdfm/package.json +++ b/packages/postdfm/package.json @@ -15,6 +15,7 @@ }, "scripts": { "compile": "tsc --listEmittedFiles", + "test": "cross-env NODE_OPTIONS=--experimental-vm-modules jest --coverage --verbose", "docs": "typedoc --options typedoc.config.cjs" }, "keywords": [ diff --git a/packages/postdfm/__test__/broken/index.test.ts b/packages/postdfm/test/broken/index.test.ts similarity index 100% rename from packages/postdfm/__test__/broken/index.test.ts rename to packages/postdfm/test/broken/index.test.ts diff --git a/packages/postdfm/__test__/broken/invalidProperty.dfm b/packages/postdfm/test/broken/invalidProperty.dfm similarity index 100% rename from packages/postdfm/__test__/broken/invalidProperty.dfm rename to packages/postdfm/test/broken/invalidProperty.dfm diff --git a/packages/postdfm/__test__/broken/unexpectedEnd.dfm b/packages/postdfm/test/broken/unexpectedEnd.dfm similarity index 100% rename from packages/postdfm/__test__/broken/unexpectedEnd.dfm rename to packages/postdfm/test/broken/unexpectedEnd.dfm diff --git a/packages/postdfm/__test__/fixtures/index.test.ts b/packages/postdfm/test/fixtures/index.test.ts similarity index 95% rename from packages/postdfm/__test__/fixtures/index.test.ts rename to packages/postdfm/test/fixtures/index.test.ts index e3cfcdc9..bc9de76c 100644 --- a/packages/postdfm/__test__/fixtures/index.test.ts +++ b/packages/postdfm/test/fixtures/index.test.ts @@ -5,12 +5,12 @@ import { Plugin } from "@postdfm/plugin"; import { postdfm, postdfmSync } from "postdfm"; const parseFixturesPath = new URL( - "../../../../__test__/__fixtures__/parse/", + "../../../../test/fixtures/parse/", import.meta.url ); const transformFixturesPath = new URL( - "../../../../__test__/__fixtures__/transform/", + "../../../../test/fixtures/transform/", import.meta.url ); diff --git a/packages/postdfm/__test__/options/index.test.ts b/packages/postdfm/test/options/index.test.ts similarity index 100% rename from packages/postdfm/__test__/options/index.test.ts rename to packages/postdfm/test/options/index.test.ts diff --git a/packages/postdfm/__test__/options/parser.js b/packages/postdfm/test/options/parser.js similarity index 100% rename from packages/postdfm/__test__/options/parser.js rename to packages/postdfm/test/options/parser.js diff --git a/packages/postdfm/__test__/options/plugin.js b/packages/postdfm/test/options/plugin.js similarity index 100% rename from packages/postdfm/__test__/options/plugin.js rename to packages/postdfm/test/options/plugin.js diff --git a/packages/postdfm/__test__/options/stringifier.js b/packages/postdfm/test/options/stringifier.js similarity index 100% rename from packages/postdfm/__test__/options/stringifier.js rename to packages/postdfm/test/options/stringifier.js diff --git a/packages/postdfm/typedoc.config.cjs b/packages/postdfm/typedoc.config.cjs index da19847d..0c3f3537 100644 --- a/packages/postdfm/typedoc.config.cjs +++ b/packages/postdfm/typedoc.config.cjs @@ -1,4 +1 @@ -module.exports = require("../../typedoc.config.cjs")({ - entryPoints: ["src/index.ts"], - out: "postdfm" -}); +module.exports = require("../../typedoc.config.cjs")("postdfm"); diff --git a/__test__/__fixtures__/parse/boundary-keyword/ast.json b/test/fixtures/parse/boundary-keyword/ast.json similarity index 100% rename from __test__/__fixtures__/parse/boundary-keyword/ast.json rename to test/fixtures/parse/boundary-keyword/ast.json diff --git a/__test__/__fixtures__/parse/boundary-keyword/form.dfm b/test/fixtures/parse/boundary-keyword/form.dfm similarity index 100% rename from __test__/__fixtures__/parse/boundary-keyword/form.dfm rename to test/fixtures/parse/boundary-keyword/form.dfm diff --git a/__test__/__fixtures__/parse/empty-file/ast.json b/test/fixtures/parse/empty-file/ast.json similarity index 100% rename from __test__/__fixtures__/parse/empty-file/ast.json rename to test/fixtures/parse/empty-file/ast.json diff --git a/__test__/__fixtures__/parse/empty-file/form.dfm b/test/fixtures/parse/empty-file/form.dfm similarity index 100% rename from __test__/__fixtures__/parse/empty-file/form.dfm rename to test/fixtures/parse/empty-file/form.dfm diff --git a/__test__/__fixtures__/parse/empty-object/ast.json b/test/fixtures/parse/empty-object/ast.json similarity index 100% rename from __test__/__fixtures__/parse/empty-object/ast.json rename to test/fixtures/parse/empty-object/ast.json diff --git a/__test__/__fixtures__/parse/empty-object/form.dfm b/test/fixtures/parse/empty-object/form.dfm similarity index 100% rename from __test__/__fixtures__/parse/empty-object/form.dfm rename to test/fixtures/parse/empty-object/form.dfm diff --git a/__test__/__fixtures__/parse/everything/ast.json b/test/fixtures/parse/everything/ast.json similarity index 100% rename from __test__/__fixtures__/parse/everything/ast.json rename to test/fixtures/parse/everything/ast.json diff --git a/__test__/__fixtures__/parse/everything/form.dfm b/test/fixtures/parse/everything/form.dfm similarity index 100% rename from __test__/__fixtures__/parse/everything/form.dfm rename to test/fixtures/parse/everything/form.dfm diff --git a/__test__/__fixtures__/parse/lists/ast.json b/test/fixtures/parse/lists/ast.json similarity index 100% rename from __test__/__fixtures__/parse/lists/ast.json rename to test/fixtures/parse/lists/ast.json diff --git a/__test__/__fixtures__/parse/lists/form.dfm b/test/fixtures/parse/lists/form.dfm similarity index 100% rename from __test__/__fixtures__/parse/lists/form.dfm rename to test/fixtures/parse/lists/form.dfm diff --git a/__test__/__fixtures__/parse/no-type/ast.json b/test/fixtures/parse/no-type/ast.json similarity index 100% rename from __test__/__fixtures__/parse/no-type/ast.json rename to test/fixtures/parse/no-type/ast.json diff --git a/__test__/__fixtures__/parse/no-type/form.dfm b/test/fixtures/parse/no-type/form.dfm similarity index 100% rename from __test__/__fixtures__/parse/no-type/form.dfm rename to test/fixtures/parse/no-type/form.dfm diff --git a/__test__/__fixtures__/parse/objects/ast.json b/test/fixtures/parse/objects/ast.json similarity index 100% rename from __test__/__fixtures__/parse/objects/ast.json rename to test/fixtures/parse/objects/ast.json diff --git a/__test__/__fixtures__/parse/objects/form.dfm b/test/fixtures/parse/objects/form.dfm similarity index 100% rename from __test__/__fixtures__/parse/objects/form.dfm rename to test/fixtures/parse/objects/form.dfm diff --git a/__test__/__fixtures__/parse/properties/ast.json b/test/fixtures/parse/properties/ast.json similarity index 100% rename from __test__/__fixtures__/parse/properties/ast.json rename to test/fixtures/parse/properties/ast.json diff --git a/__test__/__fixtures__/parse/properties/form.dfm b/test/fixtures/parse/properties/form.dfm similarity index 100% rename from __test__/__fixtures__/parse/properties/form.dfm rename to test/fixtures/parse/properties/form.dfm diff --git a/__test__/__fixtures__/parse/strings/ast.json b/test/fixtures/parse/strings/ast.json similarity index 100% rename from __test__/__fixtures__/parse/strings/ast.json rename to test/fixtures/parse/strings/ast.json diff --git a/__test__/__fixtures__/parse/strings/form.dfm b/test/fixtures/parse/strings/form.dfm similarity index 100% rename from __test__/__fixtures__/parse/strings/form.dfm rename to test/fixtures/parse/strings/form.dfm diff --git a/__test__/__fixtures__/parse/weird-spacing/ast.json b/test/fixtures/parse/weird-spacing/ast.json similarity index 100% rename from __test__/__fixtures__/parse/weird-spacing/ast.json rename to test/fixtures/parse/weird-spacing/ast.json diff --git a/__test__/__fixtures__/parse/weird-spacing/form.dfm b/test/fixtures/parse/weird-spacing/form.dfm similarity index 100% rename from __test__/__fixtures__/parse/weird-spacing/form.dfm rename to test/fixtures/parse/weird-spacing/form.dfm diff --git a/__test__/__fixtures__/transform/everything/cis.dfm b/test/fixtures/transform/everything/cis.dfm similarity index 100% rename from __test__/__fixtures__/transform/everything/cis.dfm rename to test/fixtures/transform/everything/cis.dfm diff --git a/__test__/__fixtures__/transform/everything/cis.json b/test/fixtures/transform/everything/cis.json similarity index 100% rename from __test__/__fixtures__/transform/everything/cis.json rename to test/fixtures/transform/everything/cis.json diff --git a/__test__/__fixtures__/transform/everything/plugin.js b/test/fixtures/transform/everything/plugin.js similarity index 100% rename from __test__/__fixtures__/transform/everything/plugin.js rename to test/fixtures/transform/everything/plugin.js diff --git a/__test__/__fixtures__/transform/everything/trans.dfm b/test/fixtures/transform/everything/trans.dfm similarity index 100% rename from __test__/__fixtures__/transform/everything/trans.dfm rename to test/fixtures/transform/everything/trans.dfm diff --git a/__test__/__fixtures__/transform/everything/trans.json b/test/fixtures/transform/everything/trans.json similarity index 100% rename from __test__/__fixtures__/transform/everything/trans.json rename to test/fixtures/transform/everything/trans.json diff --git a/__test__/__fixtures__/transform/hello-world/cis.dfm b/test/fixtures/transform/hello-world/cis.dfm similarity index 100% rename from __test__/__fixtures__/transform/hello-world/cis.dfm rename to test/fixtures/transform/hello-world/cis.dfm diff --git a/__test__/__fixtures__/transform/hello-world/cis.json b/test/fixtures/transform/hello-world/cis.json similarity index 100% rename from __test__/__fixtures__/transform/hello-world/cis.json rename to test/fixtures/transform/hello-world/cis.json diff --git a/__test__/__fixtures__/transform/hello-world/plugin.js b/test/fixtures/transform/hello-world/plugin.js similarity index 100% rename from __test__/__fixtures__/transform/hello-world/plugin.js rename to test/fixtures/transform/hello-world/plugin.js diff --git a/__test__/__fixtures__/transform/hello-world/trans.dfm b/test/fixtures/transform/hello-world/trans.dfm similarity index 100% rename from __test__/__fixtures__/transform/hello-world/trans.dfm rename to test/fixtures/transform/hello-world/trans.dfm diff --git a/__test__/__fixtures__/transform/hello-world/trans.json b/test/fixtures/transform/hello-world/trans.json similarity index 100% rename from __test__/__fixtures__/transform/hello-world/trans.json rename to test/fixtures/transform/hello-world/trans.json diff --git a/test/jest-preset.cjs b/test/jest-preset.cjs new file mode 100644 index 00000000..51a132b1 --- /dev/null +++ b/test/jest-preset.cjs @@ -0,0 +1,31 @@ +const path = require("path"); + +module.exports = (projectName) => ({ + extensionsToTreatAsEsm: [".ts"], + globals: { + "ts-jest": { + useESM: true + } + }, + transform: { + "^.+\\.tsx?$": "ts-jest" + }, + resolver: path.resolve(__dirname, "resolver.cjs"), + collectCoverage: true, + collectCoverageFrom: ["**/dist/**/*.js", "!**/node_modules/**"], + coverageReporters: [["lcovonly", { file: "coverage.info" }], "text"], + coverageDirectory: "results/lcov", + reporters: [ + "default", + [ + "jest-junit", + { + usePathForSuiteName: "true", + classNameTemplate: "[{classname}]", + titleTemplate: "{title}", + outputName: "./report.xml", + outputDirectory: "results/jest" + } + ] + ] +}); diff --git a/typedoc.config.cjs b/typedoc.config.cjs index 568fcd98..1f3965fc 100644 --- a/typedoc.config.cjs +++ b/typedoc.config.cjs @@ -1,13 +1,9 @@ const path = require("path"); -module.exports = (options) => - Object.assign( - { - excludePrivate: true, - theme: "minimal", - }, - options, - { - out: path.resolve(__dirname, "docs", options.out), - } - ); +module.exports = (projectName) => + Object.assign({ + excludePrivate: true, + theme: "minimal", + entryPoints: ["src/index.ts"], + out: path.resolve(__dirname, "docs", projectName) + });