Skip to content

Commit

Permalink
refactor: large refactor of testing framework and related aspects
Browse files Browse the repository at this point in the history
fix #221
  • Loading branch information
spiltcoffee committed Apr 24, 2021
1 parent 4d73f84 commit dcf6ea2
Show file tree
Hide file tree
Showing 79 changed files with 437 additions and 118 deletions.
56 changes: 47 additions & 9 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }}

Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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

Expand Down
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,7 @@ typings/
# js
dist

# jest-junit
test-results
results/

# nearley.js
packages/@postdfm/dfm2ast/src/grammar.ts
Expand Down
31 changes: 0 additions & 31 deletions jest.config.json

This file was deleted.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -46,6 +46,7 @@
"husky": "^5.0.6",
"jest": "^27.0.0-next.8",
"jest-junit": "^10.0.0",
"lcov-result-merger": "^3.1.0",
"lint-staged": "^10.0.3",
"nearley": "^2.16.0",
"prettier": "^2.2.1",
Expand Down
1 change: 1 addition & 0 deletions packages/@postdfm/ast/jest.config.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require("../../../test/jest-preset.cjs")("@postdfm/ast");
1 change: 1 addition & 0 deletions packages/@postdfm/ast/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
5 changes: 1 addition & 4 deletions packages/@postdfm/ast/typedoc.config.cjs
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
module.exports = require("../../../typedoc.config.cjs")({
entryPoints: ["src/index.ts"],
out: "@postdfm/ast"
});
module.exports = require("../../../typedoc.config.cjs")("@postdfm/ast");
24 changes: 0 additions & 24 deletions packages/@postdfm/ast2dfm/__test__/fixtures/index.test.ts

This file was deleted.

1 change: 1 addition & 0 deletions packages/@postdfm/ast2dfm/jest.config.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require("../../../test/jest-preset.cjs")("@postdfm/ast2dfm");
1 change: 1 addition & 0 deletions packages/@postdfm/ast2dfm/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
28 changes: 28 additions & 0 deletions packages/@postdfm/ast2dfm/test/fixtures/index.test.ts
Original file line number Diff line number Diff line change
@@ -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"));
});
});
});
});
5 changes: 1 addition & 4 deletions packages/@postdfm/ast2dfm/typedoc.config.cjs
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
module.exports = require("../../../typedoc.config.cjs")({
entryPoints: ["src/index.ts"],
out: "@postdfm/ast2dfm"
});
module.exports = require("../../../typedoc.config.cjs")("@postdfm/ast2dfm");
1 change: 1 addition & 0 deletions packages/@postdfm/dfm2ast/jest.config.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require("../../../test/jest-preset.cjs")("@postdfm/dfm2ast");
1 change: 1 addition & 0 deletions packages/@postdfm/dfm2ast/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
);

Expand Down
5 changes: 1 addition & 4 deletions packages/@postdfm/dfm2ast/typedoc.config.cjs
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
module.exports = require("../../../typedoc.config.cjs")({
entryPoints: ["src/index.ts"],
out: "@postdfm/dfm2ast"
});
module.exports = require("../../../typedoc.config.cjs")("@postdfm/dfm2ast");
1 change: 1 addition & 0 deletions packages/@postdfm/plugin/jest.config.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require("../../../test/jest-preset.cjs")("@postdfm/plugin");
1 change: 1 addition & 0 deletions packages/@postdfm/plugin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
5 changes: 1 addition & 4 deletions packages/@postdfm/plugin/typedoc.config.cjs
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
module.exports = require("../../../typedoc.config.cjs")({
entryPoints: ["src/index.ts"],
out: "@postdfm/plugin",
});
module.exports = require("../../../typedoc.config.cjs")("@postdfm/plugin");
1 change: 1 addition & 0 deletions packages/@postdfm/transform/jest.config.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require("../../../test/jest-preset.cjs")("@postdfm/transform");
1 change: 1 addition & 0 deletions packages/@postdfm/transform/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
);

Expand Down
5 changes: 1 addition & 4 deletions packages/@postdfm/transform/typedoc.config.cjs
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
module.exports = require("../../../typedoc.config.cjs")({
entryPoints: ["src/index.ts"],
out: "@postdfm/transform",
});
module.exports = require("../../../typedoc.config.cjs")("@postdfm/transform");
1 change: 1 addition & 0 deletions packages/postdfm/jest.config.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require("../../test/jest-preset.cjs")("postdfm");
1 change: 1 addition & 0 deletions packages/postdfm/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -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
);

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
5 changes: 1 addition & 4 deletions packages/postdfm/typedoc.config.cjs
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
module.exports = require("../../typedoc.config.cjs")({
entryPoints: ["src/index.ts"],
out: "postdfm"
});
module.exports = require("../../typedoc.config.cjs")("postdfm");
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
31 changes: 31 additions & 0 deletions test/jest-preset.cjs
Original file line number Diff line number Diff line change
@@ -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"
}
]
]
});
18 changes: 7 additions & 11 deletions typedoc.config.cjs
Original file line number Diff line number Diff line change
@@ -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)
});
Loading

0 comments on commit dcf6ea2

Please sign in to comment.