Skip to content

Commit b087989

Browse files
dselmanclaude
andauthored
chore(*): migrate to TypeScript, bump to v1.0.0 (#677)
* chore(*): migrate to TypeScript, bump to v1.0.0 Convert the entire monorepo from JavaScript (CommonJS + JSDoc-emitted .d.ts) to TypeScript source compiled to .js + .d.ts. Per package: - Move sources from lib/ (or src/) JavaScript to src/*.ts. tsc emits to lib/ during build (now gitignored). - Drop hand-written types/ in favour of declarations generated by tsc. - Remove babel toolchain (@babel/cli, @babel/preset-env, babel-loader, babel-plugin-istanbul, tsd-jsdoc, jsdoc, .babelrc, jsdoc.json). - Add per-package tsconfig.json extending the new tsconfig.base.json, plus tsconfig.test.json for ts-jest, jest.config.js using ts-jest preset, and .eslintrc.cjs with @typescript-eslint. - package.json: main/types/typings point at lib/; files: ["lib"] (or ["lib","umd"]) so published tarballs contain only the build output — no tests, snapshots, or configs leak. Test runners: - markdown-template, markdown-transform and markdown-cli moved off mocha+chai onto jest+ts-jest. Snapshots preserved. - All 1,860 unit tests pass across the 8 packages. External models: - scripts/external/Models.hbs and getExternalModels.js now generate TypeScript modules into packages/markdown-common/src/externalModels/ (previously .js into lib/externalModels/). Webpack UMD bundles (markdown-html, markdown-template, markdown-transform): - Swap babel-loader for ts-loader; entry now ./src/index.ts. - Add `webpack.ProvidePlugin({ process: 'process/browser' })` (webpack 5 no longer auto-polyfills) and `resolve.alias = { jsdom: false }` in the markdown-html config to keep the bundle slim (4.7 MB → 1.12 MB). - Browser entry point on each UMD package's package.json points at umd/markdown-X.js so bundlers automatically prefer it. Browser end-to-end tests: - New e2e/ workspace using Playwright (Chromium) loads each UMD bundle via addScriptTag and exercises public APIs in a real browser. 9 tests pass locally. - New build.yml job runs the Playwright suite on ubuntu-latest, with the browser binary cached across runs. Concerto v3 → v4: - Bump @accordproject/concerto-core to ^4.1.3 across the workspace, @accordproject/concerto-cto to ^4.1.3 in markdown-template, @accordproject/concerto-util to ^4.1.4 in markdown-cli. - Drop the now-defunct `{ strict: true }` ModelManagerOptions argument (the option was removed in v4; the default behaviour is equivalent). Misc: - Bump every package.json version to 1.0.0. - Update READMEs across all 9 modules (root + 8 packages) for accuracy: fix outdated schema URLs, correct format names, drop "in progress…" placeholders, add TypeScript usage examples, remove unsupported ModelLoader signature, list real supported format names in CLI docs. - Refresh .github/copilot-instructions.md to reflect the new toolchain (TS, jest+ts-jest, playwright, no babel/jsdoc). - Remove root jsdoc.json (no longer referenced by any script). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> Signed-off-by: dselman <danscode@selman.org> * fix(ci): build packages in dependency order, exclude e2e from licchk - Root `build` script: previous `npm run build --workspaces` ran tsc per workspace in an undefined order. On a clean CI checkout this failed because e.g. `markdown-cicero` was compiled before `markdown-common`'s `lib/` (and thus its `.d.ts`) existed, surfacing as `TS2307: Cannot find module '@accordproject/markdown-common'`. Replaced with an explicit topological sequence: common → markdown-it-* → cicero → html, template → transform → cli. - License check: the root `license-check-and-add-config` was scanning the new `e2e/` workspace and the `js|ergo|cto` license format key predated the TypeScript migration. Added `e2e` to `exact_paths` so the e2e fixtures don't trip the root check, and renamed the format key to `ts|tsx|js|cto` (drop legacy `ergo`). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> Signed-off-by: dselman <danscode@selman.org> * fix(ts): satisfy ESLint prefer-const and no-unused-vars The TS migration accidentally left several `let` declarations that are only ever assigned once — prefer-const flags these. Same for two test fixture constants that became dead after a refactor. CI lint surfaced them on the first non-local build; local development missed them because `pretest` (lint) was skipped when iterating with `npx jest` directly. - packages/markdown-it-template/src/template_block.ts: convert the block_open / attrs / block_name / markup / old_parent / old_line_max pre-declarations to const-at-assignment-site. - packages/markdown-it-template/src/template_inline.ts: const max. - Mirror both changes in markdown-it-cicero/src/cicero_block.ts and cicero_inline.ts. - packages/markdown-cli/src/cli.test.ts: drop the unused parameters scratch variable and the unused acceptanceGrammarFile constant. The remaining test cases pass parameters inline. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> Signed-off-by: dselman <danscode@selman.org> * fix(ci): build packages from root before webpacking UMD bundles in e2e job The e2e job's `Build packages and UMD bundles` step relied on `e2e`'s `prebuild:bundles` to build the three UMD packages, but those packages depend on `markdown-common` / `markdown-cicero` which weren't being built first — surfacing as TS2307 the same way the unit tests originally did. Split the e2e workflow into two steps: - `Build packages (dep order)` — runs the root `build` script, which topo-sorts every workspace via the previous CI fix. - `Build UMD bundles` — only the three webpack steps remain in `e2e`'s `build:bundles`. Drop `prebuild:bundles` from `e2e/package.json` since the root build now covers it. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> Signed-off-by: dselman <danscode@selman.org> * fix(webpack): silence "Module not found: vm" warnings in template/transform UMD webpack 5 stopped auto-polyfilling Node built-ins. crypto-browserify pulls in asn1.js which statically references `vm` on a code path that never runs in the browser, producing noisy "Can't resolve 'vm'" warnings during webpack of `markdown-template` and `markdown-transform`. Explicitly set `vm: false` in `resolve.fallback` so webpack treats the import as an empty module — same trick the surrounding `fs`/`tls`/etc. entries already use. Behaviour is unchanged at runtime; we just stop the build output from emitting BREAKING-CHANGE-style warnings that look alarming but are harmless. markdown-html already polyfills `vm` via `vm-browserify`; no change needed there. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> Signed-off-by: dselman <danscode@selman.org> * docs(transform): regenerate transformations diagram Signed-off-by: dselman <danscode@selman.org> --------- Signed-off-by: dselman <danscode@selman.org> Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent de2d2ba commit b087989

311 files changed

Lines changed: 8594 additions & 18048 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/copilot-instructions.md

Lines changed: 49 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,35 @@
11
# GitHub Copilot Instructions for Markdown-Transform
22

3-
This repository is **Accord Project markdown-transform** — a JavaScript npm-workspaces monorepo for parsing and transforming Markdown, CommonMark, CiceroMark, and TemplateMark.
3+
This repository is **Accord Project markdown-transform** — a TypeScript npm-workspaces monorepo for parsing and transforming Markdown, CommonMark, CiceroMark, and TemplateMark.
44

55
## Project context
66

7-
- Runtime: Node.js `>=18`
7+
- Runtime: Node.js `>=22`
88
- Package manager: `npm` (workspace root + package-level scripts)
9-
- Languages: JavaScript (CommonJS)
10-
- Linting: ESLint (`eslint:recommended` + strict local rules)
11-
- Testing: Jest (most packages), Mocha (notably `packages/markdown-transform`)
12-
- CI: GitHub Actions matrix on Ubuntu, macOS, and Windows
9+
- Language: **TypeScript** (target `ES2020`, `module: commonjs`). Source lives in `packages/*/src/`; compiled `.js` + `.d.ts` are emitted to `packages/*/lib/`.
10+
- Build: `tsc` per package (config extends `tsconfig.base.json`).
11+
- Linting: ESLint with `@typescript-eslint` (4-space indent, single quotes, semicolons).
12+
- Unit testing: **Jest 29 + ts-jest** across every package. The legacy mocha+chai suites were removed during the TS migration.
13+
- Browser E2E: **Playwright** under `e2e/` exercises the UMD bundles in headless Chromium.
14+
- Bundling: `webpack 5` produces UMD bundles for `markdown-html`, `markdown-template`, `markdown-transform` (the three user-facing entry points). The other packages are CommonJS library deps consumed via bundlers.
15+
- CI: GitHub Actions matrix on Ubuntu, macOS, and Windows for unit tests; Ubuntu-only for Playwright e2e.
1316

1417
## Repository layout
1518

16-
- Root workspace packages live under `packages/`
17-
- Primary packages include:
19+
- `packages/` — eight publishable packages:
1820
- `markdown-common`
1921
- `markdown-cicero`
20-
- `markdown-template`
21-
- `markdown-html`
22+
- `markdown-template` *(also UMD)*
23+
- `markdown-html` *(also UMD)*
2224
- `markdown-it-cicero`
2325
- `markdown-it-template`
2426
- `markdown-cli`
25-
- `markdown-transform`
26-
- Utility scripts are under `scripts/`
27+
- `markdown-transform` *(umbrella, also UMD)*
28+
- `e2e/` — browser end-to-end tests (Playwright). Not published.
29+
- `scripts/` — repo-level utilities (model generation, version bumping, coverage aggregation).
30+
- `tsconfig.base.json` — shared compiler options inherited by every package.
31+
32+
Concerto models for CommonMark/CiceroMark/TemplateMark are downloaded by `scripts/external/getExternalModels.js` (run via `npm run models:get` / triggered as `postinstall`) and emitted as TS into `packages/markdown-common/src/externalModels/`. Treat those files as generated.
2733

2834
## Non-negotiable contribution requirements
2935

@@ -35,31 +41,32 @@ This repository is **Accord Project markdown-transform** — a JavaScript npm-wo
3541
- Examples seen in this repo:
3642
- `fix: update broken CI badge to use GitHub Actions workflow URL`
3743
- `chore(deps): update package dependencies`
38-
- `chore(actions): publish v0.16.25 to npm`
44+
- `chore(actions): publish v1.0.0 to npm`
3945

4046
3. **Do not skip tests for behavior changes**
41-
- Add or update unit tests when changing logic.
47+
- Add or update unit tests when changing logic; add a Playwright e2e test if the change affects the browser bundle surface.
4248

4349
## Coding standards (repo-specific)
4450

45-
- Use **4-space indentation**.
46-
- Use **single quotes**.
47-
- Use **semicolons**.
48-
- Avoid `var`; use `const`/`let`.
49-
- Keep braces for control flow (`curly` rule).
50-
- Keep strict equality (`eqeqeq`).
51-
- Add JSDoc for classes, methods, and function declarations (`require-jsdoc`).
51+
- TypeScript only for new code. Avoid reintroducing `.js` files in `src/`.
52+
- 4-space indentation, single quotes, semicolons.
53+
- Prefer `const`/`let` (no `var`), keep braces (`curly`), strict equality (`eqeqeq`).
54+
- The TS config is pragmatic — `strict: false`, `noImplicitAny: false` — so visitor/AST code uses `any` liberally. That is intentional: don't tighten types in unrelated files while fixing something else.
55+
- Don't add JSDoc that simply restates the function signature; reserve comments for non-obvious *why*.
5256
- Prefer minimal, surgical diffs; avoid unrelated formatting churn.
5357

5458
## Build and test workflow
5559

5660
When changing code, run checks in this order:
5761

58-
1. `npm run build --workspaces --if-present`
59-
2. `npm test`
60-
3. If needed for coverage diagnostics: `npm run coverage`
62+
1. `npm run build` — runs `tsc` per workspace (also rebuilds before tests via each package's `pretest`).
63+
2. `npm test` — runs the full Jest suite across every package.
64+
3. `npm run -w markdown-transform-e2e test` — Playwright browser tests; only needed if you changed source that ends up in a UMD bundle.
65+
4. `npm run coverage` — coverage aggregation (only if investigating coverage).
66+
67+
For package-level iteration, `cd packages/<name>` and run `npm run build`, `npm test`, etc. directly. For the umbrella package, also run `npm run webpack` after `npm run build` to refresh the UMD bundle.
6168

62-
For package-level iteration, run the package scripts directly inside the package folder (for example lint/test in `packages/markdown-common` or `packages/markdown-transform`).
69+
When migrating Concerto: `@accordproject/concerto-core` is on **v4**. `new ModelManager({ strict: true })` is no longer valid — drop the option, don't cast to `any`. The model manager defaults are equivalent in v4.
6370

6471
## Dependency management rules (critical)
6572

@@ -73,7 +80,7 @@ These are based on merged PR review feedback in this repository:
7380
- If downgrading is required, explain why in PR description and comments.
7481

7582
3. **Avoid adding new dependencies without clear rationale**
76-
- Reviewers repeatedly asked Why the new deps? across multiple package manifests.
83+
- Reviewers repeatedly asked "Why the new deps?" across multiple package manifests.
7784
- Prefer updating existing dependencies over adding new ones.
7885

7986
4. **For core Accord dependencies, prefer exact versions when the repo already pins exact versions**
@@ -83,6 +90,15 @@ These are based on merged PR review feedback in this repository:
8390
5. **Keep workspace dependency versions consistent across packages**
8491
- If bumping a shared dependency, align all affected package manifests and lockfiles in one change.
8592

93+
6. **Browser polyfills only when strictly needed**
94+
- The webpack configs use `webpack.ProvidePlugin({ process: 'process/browser' })` and `resolve.alias = { jsdom: false }` to keep UMD bundles slim. Don't add Node polyfills unless a real test fails without them.
95+
96+
## Publishing & npm packages
97+
98+
- `package.json` `files` field for every publishable package is `["lib"]` (or `["lib", "umd"]` for the three UMD packages). `src/`, tests, snapshots, jest config, eslint config, and tsconfig stay out of the tarball.
99+
- `main: "lib/index.js"`, `types: "lib/index.d.ts"`. The three UMD packages also set `browser: "umd/markdown-X.js"` so bundlers serving browser targets pick the UMD bundle automatically.
100+
- Source maps (`*.js.map`) **are** shipped — keep `sourceMap: true` in `tsconfig.base.json` so consumer stack traces stay useful.
101+
86102
## AI review behavior (adapted from best-practice guidance)
87103

88104
Copilot suggestions should follow a **human-in-the-loop**, high-signal workflow:
@@ -100,7 +116,7 @@ Copilot suggestions should follow a **human-in-the-loop**, high-signal workflow:
100116
- Do not trade security for convenience.
101117

102118
4. **Continuous learning loop**
103-
- If a review pattern repeats (e.g., why new dependency?”, “why downgrade?), treat it as a standing rule for future changes.
119+
- If a review pattern repeats (e.g., "why new dependency?", "why downgrade?"), treat it as a standing rule for future changes.
104120
- Prefer repository-established patterns over generic defaults.
105121

106122
5. **Human validation remains required**
@@ -111,18 +127,21 @@ Copilot suggestions should follow a **human-in-the-loop**, high-signal workflow:
111127
Before proposing a PR-ready change:
112128

113129
- [ ] Change scope is minimal and focused
114-
- [ ] New/updated behavior has tests
130+
- [ ] New/updated behavior has tests (unit and, where relevant, Playwright e2e)
115131
- [ ] Lint/build/tests pass
132+
- [ ] `npm pack --dry-run` for any package whose contents changed shows only `lib/` (+ optional `umd/`) — no tests, snapshots, or configs leaking
116133
- [ ] Dependency changes are justified and minimal
117134
- [ ] No accidental downgrades or unnecessary added packages
118135
- [ ] Commit(s) use DCO sign-off
119136
- [ ] PR description clearly explains **why** the change is needed
120137

121138
## Common pitfalls in this repo
122139

140+
- Mixing `.js` and `.ts` in `src/` — the source tree is TypeScript only.
141+
- Forgetting to rebuild UMD bundles (`npm run webpack -w …`) after source changes; the Playwright e2e tests will then test stale code.
142+
- Adding broad type tightening (`noImplicitAny`, `strict`) in unrelated files while fixing a small bug — out of scope, expand `any` only where the change is needed.
123143
- Adding many dependency changes in one sweep without explaining each one.
124144
- Switching from exact to ranged versions for core dependencies without team agreement.
125-
- Introducing dependency downgrades as side effects of automated tooling.
126-
- Making large unrelated edits while addressing a small issue.
145+
- Re-introducing `npm install`-time `prepare`/`build` scripts. Build is a separate explicit step now (`npm run build`), keeping `npm install` fast and resilient to broken intermediate states.
127146

128147
When in doubt, prefer small, explicit, well-tested changes that match existing package patterns.

.github/workflows/build.yml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,62 @@ jobs:
6161
parallel: true
6262
fail-on-error: false
6363

64+
e2e:
65+
name: Browser E2E (Chromium)
66+
runs-on: ubuntu-latest
67+
needs:
68+
- build
69+
70+
steps:
71+
- name: git checkout
72+
uses: actions/checkout@v4
73+
74+
- name: Use Node.js 22.x
75+
uses: actions/setup-node@v4
76+
with:
77+
node-version: 22.x
78+
cache: 'npm'
79+
80+
- name: Install dependencies
81+
run: npm ci
82+
83+
- name: Build packages (dep order)
84+
run: npm run build
85+
86+
- name: Build UMD bundles
87+
run: npm run -w markdown-transform-e2e build:bundles
88+
89+
- name: Get Playwright version
90+
id: playwright-version
91+
run: |
92+
echo "version=$(node -p "require('./e2e/node_modules/@playwright/test/package.json').version")" >> $GITHUB_OUTPUT
93+
94+
- name: Cache Playwright browsers
95+
id: playwright-cache
96+
uses: actions/cache@v4
97+
with:
98+
path: ~/.cache/ms-playwright
99+
key: playwright-${{ runner.os }}-${{ steps.playwright-version.outputs.version }}
100+
101+
- name: Install Playwright Chromium
102+
if: steps.playwright-cache.outputs.cache-hit != 'true'
103+
run: npx --no-install --prefix e2e playwright install --with-deps chromium
104+
105+
- name: Install Playwright system deps only (cache hit)
106+
if: steps.playwright-cache.outputs.cache-hit == 'true'
107+
run: npx --no-install --prefix e2e playwright install-deps chromium
108+
109+
- name: Run browser e2e tests
110+
run: npm test -w markdown-transform-e2e -- --reporter=list
111+
112+
- name: Upload Playwright report on failure
113+
if: failure()
114+
uses: actions/upload-artifact@v4
115+
with:
116+
name: playwright-report
117+
path: e2e/playwright-report
118+
retention-days: 7
119+
64120
notify:
65121
needs:
66122
- build

README.md

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919

2020
A transformation and parsing framework for converting markdown content to HTML and other structured document object models (DOMs).
2121

22+
The codebase is written in TypeScript; each package ships compiled JavaScript alongside `.d.ts` type declarations.
23+
2224
![Transformations](./packages/markdown-transform/transformations.png)
2325

2426
## Structure of the Code Repository
@@ -37,23 +39,23 @@ Top level repository (markdown-transform), with sub packages. Each sub-package i
3739

3840
The CommonMark DOM is a model for the elements of CommonMark (the specification for markdown text), expressed as a [Concerto schema](https://github.com/accordproject/concerto), and serialized as a JSON graph.
3941

40-
The schema is defined here: https://models.accordproject.org/markdown/commonmark@0.2.0.html
42+
The schema is defined here: https://models.accordproject.org/markdown/commonmark@0.5.0.html
4143

4244
### CiceroMark DOM
4345

4446
CiceroMark defines markdown documents with embedded clauses, where each clause is an instance of a template, specified using TemplateMark.
4547

46-
The CiceroMark DOM extends the CommonMark DOM, defining nodes for `Clause`, `Variable` and `Formula` etc.
48+
The CiceroMark DOM extends the CommonMark DOM, defining nodes for `Clause`, `Variable`, `FormattedVariable`, `EnumVariable`, `Conditional`, `Optional`, `Formula` and `ListBlock`.
4749

48-
The schema is defined here: https://models.accordproject.org/markdown/ciceromark@0.3.0.html
50+
The schema is defined here: https://models.accordproject.org/markdown/ciceromark@0.6.0.html
4951

5052
### TemplateMark DOM
5153

5254
TemplateMark defines markdown documents with syntax for embedded variables, optional blocks, formulas etc. It is used to define Accord Project templates.
5355

54-
The TemplateMark DOM extends the CommonMark DOM, defining nodes for `ClauseDefinition`, `VariableDefinition` and `ForumulaDefinition` etc.
56+
The TemplateMark DOM extends the CommonMark DOM, defining nodes for `ClauseDefinition`, `ContractDefinition`, `VariableDefinition`, `FormattedVariableDefinition`, `EnumVariableDefinition`, `ConditionalDefinition`, `OptionalDefinition`, `WithDefinition`, `JoinDefinition`, `ListBlockDefinition` and `FormulaDefinition`.
5557

56-
The schema is defined here: https://models.accordproject.org/markdown/templatemark.html
58+
The schema is defined here: https://models.accordproject.org/markdown/templatemark@0.5.0.html
5759

5860
## Installation
5961

@@ -76,13 +78,14 @@ markus --help
7678
npm install
7779
```
7880

79-
Then run:
81+
Then build all packages and run their tests:
8082

8183
```
84+
npm run build
8285
npm run test
8386
```
8487

85-
This command uses npm workspaces to run the tests for each package in the monorepo.
88+
These commands use npm workspaces. `build` runs `tsc` for each package, producing JavaScript and `.d.ts` declarations into `packages/*/lib/`. `test` runs Jest. Requires Node 22 or later.
8689

8790
---
8891

e2e/.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
node_modules/
2+
test-results/
3+
playwright-report/
4+
playwright/.cache/

e2e/README.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Browser End-to-End Tests
2+
3+
[Playwright](https://playwright.dev) tests that load the UMD bundles for `markdown-html`, `markdown-template` and `markdown-transform` into a real headless Chromium and call the public API. These tests exist to catch packaging/bundling regressions that unit tests miss — for example, accidentally pulling Node-only modules like `jsdom` into the browser bundle.
4+
5+
## Run
6+
7+
From the repository root:
8+
9+
```bash
10+
npm install --workspaces
11+
npm run -w markdown-transform-e2e test
12+
```
13+
14+
`npm test` from the e2e directory runs `pretest` first, which:
15+
1. Builds each TS package (`tsc`)
16+
2. Builds each UMD bundle (`webpack`)
17+
3. Installs the Chromium browser used by Playwright (cached after first run)
18+
19+
## What's covered
20+
21+
| Spec | Asserts |
22+
|------|---------|
23+
| `markdown-html.spec.ts` | `HtmlTransformer` exported on the global; `toHtml`/`toCiceroMark` work using the native `DOMParser` (jsdom is **not** in the browser bundle) |
24+
| `markdown-template.spec.ts` | `TemplateMarkTransformer` exported; `toTokens` and `normalizeNLs` work |
25+
| `markdown-transform.spec.ts` | `transform`, `formatDescriptor`, `generateTransformationDiagram`, `TransformEngine` exported; markdown → commonmark and markdown → html transformations succeed |
26+
27+
## Adding a test
28+
29+
Each UMD bundle exports its API onto `window['<package-name>']` (e.g. `window['markdown-html']`). Spec pattern:
30+
31+
```ts
32+
await page.setContent('<!doctype html><html><body></body></html>');
33+
await page.addScriptTag({ path: path.resolve(__dirname, '../../packages/<pkg>/umd/<pkg>.js') });
34+
35+
const result = await page.evaluate(() => {
36+
const { Something } = (window as any)['<pkg>'];
37+
return new Something().doStuff();
38+
});
39+
40+
expect(result).toBe(/**/);
41+
```

e2e/package.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"name": "markdown-transform-e2e",
3+
"version": "1.0.0",
4+
"private": true,
5+
"description": "End-to-end tests that load the UMD browser bundles into a real headless Chromium and exercise the public API.",
6+
"scripts": {
7+
"build:bundles": "npm run -w @accordproject/markdown-html webpack && npm run -w @accordproject/markdown-template webpack && npm run -w @accordproject/markdown-transform webpack",
8+
"pretest": "npm run build:bundles && npx --yes playwright install chromium",
9+
"test": "playwright test"
10+
},
11+
"devDependencies": {
12+
"@playwright/test": "^1.49.0"
13+
}
14+
}
Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,19 @@
1212
* limitations under the License.
1313
*/
1414

15-
'use strict';
15+
import { defineConfig, devices } from '@playwright/test';
1616

17-
/**
18-
* Export the framework and plugins
19-
* @module markdown-transform
20-
*/
21-
22-
module.exports.CiceroMarkTransformer = require('./lib/CiceroMarkTransformer');
23-
module.exports.FromCiceroEditVisitor = require('./lib/FromCiceroEditVisitor');
24-
module.exports.ToCommonMarkVisitor = require('./lib/ToCommonMarkVisitor');
25-
26-
module.exports.Decorators = require('./lib/Decorators');
17+
export default defineConfig({
18+
testDir: './tests',
19+
fullyParallel: true,
20+
forbidOnly: !!process.env.CI,
21+
retries: process.env.CI ? 1 : 0,
22+
workers: process.env.CI ? 1 : undefined,
23+
reporter: 'list',
24+
use: {
25+
trace: 'on-first-retry',
26+
},
27+
projects: [
28+
{ name: 'chromium', use: { ...devices['Desktop Chrome'] } },
29+
],
30+
});

0 commit comments

Comments
 (0)