Skip to content

Commit

Permalink
chore: migrate from jest to mocha
Browse files Browse the repository at this point in the history
Migrates from jest to mocha, tinyspy and c8.
  • Loading branch information
43081j committed Sep 21, 2024
1 parent 3f7f229 commit fe94577
Show file tree
Hide file tree
Showing 15 changed files with 2,666 additions and 5,869 deletions.
5 changes: 5 additions & 0 deletions .c8rc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"reporter": ["lcov"],
"include": ["packages/*/lib/**/*.ts"],
"exclude": []
}
6 changes: 3 additions & 3 deletions .github/workflows/nodejs-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,12 @@ jobs:
- run: npm ci
- run: npm run build --if-present

- name: Run Jest
- name: Run unit tests
run: npm run unit-tests
if: matrix.node != env.NODE_COV

- name: Run Jest with coverage
run: npm run unit-tests -- --coverage
- name: Run unit tests with coverage
run: npm run unit-tests-coverage
if: matrix.node == env.NODE_COV

- name: Run Coveralls
Expand Down
7 changes: 7 additions & 0 deletions .mocharc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"require": "ts-node/register",
"loader": "ts-node/esm",
"extensions": ["ts"],
"spec": ["**/*.test.ts"],
"watch-files": ["packages/*/lib"]
}
3 changes: 1 addition & 2 deletions bench/memory/sax-parser.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
/* eslint-disable no-console */
import { readFile } from 'node:fs/promises';
import format from 'human-format';
import memwatch from '@airbnb/node-memwatch';
import { SAXParser } from '../../packages/parse5-sax-parser/dist/index.js';
import { finished } from 'parse5-test-utils/dist/common.js';

/* eslint-disable no-console */

const heapDiffMeasurement = new memwatch.HeapDiff();

let maxMemUsage = 0;
Expand Down
3 changes: 1 addition & 2 deletions bench/perf/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable no-console */
import { readFileSync, createReadStream, readdirSync } from 'node:fs';
import Benchmark from 'benchmark';
import { loadTreeConstructionTestData } from 'parse5-test-utils/dist/generate-parsing-tests.js';
Expand All @@ -7,8 +8,6 @@ import * as parse5 from '../../packages/parse5/dist/index.js';
import { ParserStream as parse5Stream } from '../../packages/parse5-parser-stream/dist/index.js';
import * as parse5Upstream from 'parse5';

/* eslint-disable no-console */

const hugePagePath = new URL('../../test/data/huge-page/huge-page.html', import.meta.url);
const treeConstructionPath = new URL('../../test/data/html5lib-tests/tree-construction', import.meta.url);
const saxPath = new URL('../../test/data/sax/', import.meta.url);
Expand Down
8 changes: 8 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,14 @@ export default [
'arrow-body-style': ['error', 'as-needed'],
},
},
{
files: testFiles,
languageOptions: {
globals: {
...globals.mocha,
},
},
},
{
files: ['**/*.ts'],
rules: {
Expand Down
Loading

0 comments on commit fe94577

Please sign in to comment.