Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: replace mocha with node own test runner #280

Merged
merged 4 commits into from
Jan 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,7 @@ jobs:

# Custom script, because progress looks not good in CI
- name: Run tests
env:
CFLAGS: -O0
run: npx mocha --timeout 30000 -r ts-node/register/type-check test/*-test.ts
run: npm run test

lint:
name: Run ESLint
Expand Down
5 changes: 3 additions & 2 deletions docs/releasing.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,12 @@ These are the required steps to release a new version of llhttp:

First of all, make sure you have [GitHub CLI](https://cli.github.com) installed and configured. While this is not strictly necessary, it will make your life way easier.

As a preliminary check, run the build command and execute the test suite locally:
As a preliminary check, lint the code, run the build command and execute the test suite locally:

```
npm run lint
npm run build
npm test
npm run test
```

If all goes good, you are ready to go!
Expand Down
2 changes: 0 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 1 addition & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
"wasm": "ts-node bin/build_wasm.ts",
"clean": "rm -rf lib && rm -rf test/tmp",
"prepare": "npm run clean && npm run build-ts",
"test": "node -r ts-node/register/type-check --test ./test/*-test.ts",
"lint": "eslint -c eslint.json bin/*.ts src/*.ts src/**/*.ts test/*.ts test/**/*.ts",
"lint-fix": "eslint --fix -c eslint.json bin/*.ts src/*.ts src/**/*.ts test/*.ts test/**/*.ts",
"mocha": "mocha --timeout=10000 -r ts-node/register/type-check --reporter progress test/*-test.ts",
"test": "npm run mocha && npm run lint",
"postversion": "RELEASE=`node -e \"process.stdout.write(require('./package').version)\"` make -B postversion",
"github-release": "RELEASE_V=`node -e \"process.stdout.write('v' + require('./package').version)\"` make github-release"
},
Expand All @@ -42,15 +42,13 @@
"homepage": "https://github.com/nodejs/llhttp#readme",
"devDependencies": {
"@stylistic/eslint-plugin": "^1.5.4",
"@types/mocha": "^10.0.6",
"@types/node": "^20.11.10",
"@typescript-eslint/eslint-plugin": "^6.20.0",
"@typescript-eslint/parser": "^6.20.0",
"eslint": "^8.56.0",
"llparse-dot": "^1.0.1",
"llparse-test-fixture": "^5.0.1",
"mdgator": "^1.1.2",
"mocha": "^10.2.0",
"ts-node": "^10.9.2",
"typescript": "^5.3.3"
},
Expand Down
7 changes: 3 additions & 4 deletions test/md-test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import * as assert from 'assert';
import * as assert from 'node:assert';
import { describe, test } from 'node:test';
import * as fs from 'fs';
import { LLParse } from 'llparse';
import { Group, MDGator, Metadata, Test } from 'mdgator';
Expand Down Expand Up @@ -92,7 +93,7 @@ function run(name: string): void {
function runSingleTest(ty: TestType, meta: Metadata,
input: string,
expected: ReadonlyArray<string | RegExp>): void {
it(`should pass for type="${ty}"`, async () => {
test(`should pass for type="${ty}"`, { timeout: 60000 }, async () => {
const binary = await buildMode(ty, meta);
await binary.check(input, expected, {
noScan: meta.noScan === true,
Expand Down Expand Up @@ -208,8 +209,6 @@ function run(name: string): void {

function runGroup(group: Group) {
describe(group.name + ` at ${name}.md:${group.line + 1}`, function () {
this.timeout(60000);

for (const child of group.children) {
runGroup(child);
}
Expand Down
Loading