Skip to content

Commit

Permalink
feat: replace mocha with node own test runner (#280)
Browse files Browse the repository at this point in the history
* feat: replace mocha with node own test runner

* add --test flag for windows run

* try again to fix for windows
  • Loading branch information
Uzlopak authored Jan 30, 2024
1 parent 64de8f1 commit a930586
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 14 deletions.
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

0 comments on commit a930586

Please sign in to comment.