Skip to content

Commit 84feeb4

Browse files
committed
test: establish WPT coverage and clean-checkout type checks
Consolidates the original contiguous commits 0d6cb96..e11bfb2. Preserves the exact tree at the end of this group.
1 parent 2c91a94 commit 84feeb4

32 files changed

Lines changed: 1999 additions & 2802 deletions

‎.config/coverage.config.mts‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
export const coverageThresholds = {
2+
statements: 73,
3+
branches: 61,
4+
functions: 74,
5+
lines: 70,
6+
} as const

‎.config/oxlint.json‎

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
{
2-
"plugins": ["oxc", "import"],
2+
"options": {
3+
"typeAware": true,
4+
"denyWarnings": true
5+
},
6+
"plugins": ["oxc", "import", "typescript"],
37
"categories": {
48
"correctness": "error"
59
},
@@ -12,7 +16,10 @@
1216
"NW": "readonly"
1317
},
1418
"rules": {
15-
"no-console": "off"
19+
"no-console": "off",
20+
"typescript/no-floating-promises": "error",
21+
"typescript/no-misused-promises": "error",
22+
"typescript/await-thenable": "error"
1623
},
1724
"overrides": [
1825
{

‎.config/runtime.d.ts‎

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
interface NwsapiEngine {
2+
S_BODY: string
3+
M_BODY: string
4+
S_TEST: string
5+
M_TEST: string
6+
select(this: void, selector: string, context?: Node): Element[]
7+
first(selector: string, context?: Node): Element | null
8+
match(this: void, selector: string, context: Element): boolean
9+
configure(options: Record<string, unknown>, clear?: boolean): unknown
10+
registerSelector(
11+
name: string,
12+
expression: RegExp,
13+
callback: (
14+
match: RegExpMatchArray,
15+
source: string,
16+
mode: boolean,
17+
callback?: unknown,
18+
) => unknown,
19+
): void
20+
up?(element: Element, expression?: string | number): Element | null
21+
down?(element: Element, expression?: string | number): Element | null
22+
next?(element: Element, expression?: string | number): Element | null
23+
previous?(element: Element, expression?: string | number): Element | null
24+
}
25+
declare global {
26+
const NW: { Dom: NwsapiEngine }
27+
interface Window {
28+
NW: typeof NW
29+
}
30+
const define: { (factory: unknown): void; amd?: unknown }
31+
}
32+
export {}

‎.config/tsconfig.check.json‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"compilerOptions": {
3+
"target": "ES2024",
4+
"module": "ESNext",
5+
"moduleResolution": "bundler",
6+
"lib": ["ES2024", "DOM"],
7+
"types": ["node", "vitest"],
8+
"allowImportingTsExtensions": true,
9+
"erasableSyntaxOnly": true,
10+
"noEmit": true,
11+
"incremental": true,
12+
"tsBuildInfoFile": "../.cache/tsconfig.check.tsbuildinfo",
13+
"skipLibCheck": true,
14+
"forceConsistentCasingInFileNames": true,
15+
"strict": false
16+
},
17+
"include": ["../src/**/*.mts", "../scripts/**/*.mts", "../test/*.mts", "../test/upstream/*.mts", "./*.mts", "./*.d.ts"]
18+
}

‎.config/vitest.config.mts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ export default defineConfig({
2121
coverage: {
2222
provider: 'v8',
2323
include: ['src/*.js'],
24-
reporter: ['text', 'html', 'json-summary'],
24+
reportsDirectory: 'coverage/node',
25+
reporter: ['text', 'json', 'json-summary'],
2526
},
2627
},
2728
})

‎.github/local-ci.Dockerfile‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# actions-runner 2.337.0
2+
FROM ghcr.io/actions/actions-runner@sha256:e5496277be5d09bc968b3d64911b74e219ac4a3f2edce956a3ecf9271bea1ef4
3+
4+
# Node 26 needs libatomic on the minimal runner image.
5+
RUN sudo apt-get update \
6+
&& sudo apt-get install -y --no-install-recommends libatomic1

‎.github/workflows/node.js.yml‎

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,21 @@ jobs:
1414
- uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0 (2026-07-14)
1515
with:
1616
node-version: '26'
17-
cache: npm
17+
package-manager-cache: false
1818
- run: npm install --global [email protected]
19-
- run: npm ci
20-
- run: npm run lint
21-
- run: npm run format:check
22-
- run: npm run test:coverage
23-
- run: npm run check:coverage
24-
- run: npm run test:package
25-
- run: npm run upstream:clone
26-
- run: npm run upstream:verify
27-
- run: npx playwright install --with-deps chromium
28-
- run: npm run test:browser
29-
- run: npm run test:upstream
19+
working-directory: ${{ runner.temp }}
20+
- run: npm install --global [email protected]
21+
working-directory: ${{ runner.temp }}
22+
- run: pnpm install --frozen-lockfile
23+
- run: pnpm run lint
24+
- run: pnpm run format:check
25+
- run: pnpm run type
26+
- run: pnpm run test:package
27+
# Use real Git for upstream repositories, not the local runner's checkout shim.
28+
- run: PATH="$(git --exec-path):$PATH" pnpm run upstream:clone
29+
- run: PATH="$(git --exec-path):$PATH" pnpm run upstream:verify
30+
- run: pnpm exec playwright install --with-deps chromium
31+
- run: pnpm run test:coverage
32+
- run: pnpm run check:coverage
33+
- run: pnpm run test:browser
34+
- run: NWSAPI_MINIFIED=1 pnpm run test:upstream

‎.gitignore‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
**/node_modules/
2+
/.cache/
3+
/.env.local-ci
24
/coverage/
35
/dist/nwsapi.min.js
46
/playwright-report/

‎README.md‎

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,30 +71,41 @@ matching. The existing nwsapi factory API and selector support are unchanged.
7171

7272
Run the development tools with Node.js ≥ 22. This does not change the library's
7373
runtime support.
74-
Use npm ≥ 11.19.0 within v11 or ≥ 12.0.2, or pnpm ≥ 11.25.0 within v11
75-
or ≥ 12.3.4. New dependency resolutions use a one-day release-age delay. Dependency
74+
Use pnpm ≥ 11.25.0 within v11 or ≥ 12.3.4. New dependency resolutions use a
75+
one-day release-age delay. Dependency
7676
scripts need explicit approval. These requirements apply to contributors, not
7777
library consumers.
7878
CI runs lint, formatting checks, Node tests, the build and WPT in one Node.js 26 job.
7979

80-
The coverage badge starts as `n/a`; `pnpm run test:coverage` measures and updates it.
80+
`pnpm run test:coverage` measures the engine with WPT in Chromium and the adapter
81+
with Node tests, then updates the badge. It needs the WPT checkout and Chromium
82+
(see setup below). Known WPT failures remain visible in the test report.
8183

8284
```sh
8385
pnpm install
8486
pnpm test
8587
pnpm run lint
8688
pnpm run format:check
89+
pnpm run type
8790
pnpm run build
8891
```
8992

90-
Alternatively, use `npm ci` and `npm run <script>`. Keep both lockfiles
91-
updated when changing dependencies.
93+
Dependency versions are pinned in the `pnpm-workspace.yaml` catalog. Keep
94+
`pnpm-lock.yaml` updated when changing dependencies. npm remains supported for
95+
installing the published package, but cannot install this repository's catalogs.
9296

9397
Vitest runs the Node tests. Use `pnpm run test:watch` while editing or
9498
`pnpm run test:coverage` for coverage. Oxlint checks code, Oxfmt formats tooling
9599
and tests, and Rolldown transforms the `.mts` sources and minifies the browser build.
96100
Runtime source is not reformatted.
97101

102+
`pnpm run type` runs incremental TypeScript checks without emitting files.
103+
Oxlint also checks types. Coverage enforces the aggregate minimums in
104+
`.config/coverage.config.mts`; HTML reports are generated only in CI.
105+
106+
Run `pnpm run ci:local` before pushing to test the GitHub Actions workflows locally.
107+
It needs Docker and GitHub CLI authentication, and pauses on failures for fixes.
108+
98109
Node tests need no browser or WPT checkout. See [upstream testing](docs/upstream.md)
99110
for Chromium setup and known failures. `pnpm run clean` removes generated JavaScript.
100111

‎assets/repo/coverage.svg‎

Lines changed: 1 addition & 1 deletion
Loading

0 commit comments

Comments
 (0)