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

test: migrate to ts and chai@5 #135

Merged
merged 2 commits into from
Feb 20, 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
File renamed without changes.
9 changes: 9 additions & 0 deletions .mocharc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
reporter: spec
loader:
# - ts-node/esm
require:
- ts-node/register
- chai/register-should.js

spec: ["test/*.ts"]
watch-files: ["lib"]
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"build": "tsc -b",
"clean": "tsc -b --clean",
"eslint": "eslint .",
"test": "mocha test/index.js --require ts-node/register",
"test": "mocha",
"test-cov": "c8 --reporter=lcovonly npm run test"
},
"files": [
Expand All @@ -30,10 +30,12 @@
"js-yaml": "^4.1.0"
},
"devDependencies": {
"@types/chai": "^4.3.11",
"@types/js-yaml": "^4.0.5",
"@types/mocha": "^10.0.6",
"@types/node": "^18.11.7",
"c8": "^9.1.0",
"chai": "^4.3.6",
"chai": "^5.0.0",
"eslint": "^8.23.1",
"eslint-config-hexo": "^5.0.0",
"mocha": "^10.0.0",
Expand Down
4 changes: 2 additions & 2 deletions test/.eslintrc → test/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"extends": "hexo/test",
"extends": "hexo/ts-test",
"rules": {
"@typescript-eslint/no-var-requires": 0,
"@typescript-eslint/no-empty-function": 0
}
}
}
1 change: 0 additions & 1 deletion test/.mocharc.yml

This file was deleted.

6 changes: 2 additions & 4 deletions test/index.js → test/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
'use strict';

const should = require('chai').should(); // eslint-disable-line
const yfm = require('../lib/front_matter.ts');

describe('Front-matter', () => {
const yfm = require('../lib/front_matter.ts');

describe('split', () => {
it('not string', () => {
Expand Down Expand Up @@ -373,7 +371,7 @@ describe('Front-matter', () => {
].join('\n');

const data = yfm.parse(str);
parseInt(data.date.getTime() / 1000, 10).should.eql(parseInt(unixTime / 1000, 10));
parseInt(String(data.date.getTime() / 1000), 10).should.eql(parseInt(String(unixTime / 1000), 10));
});
});

Expand Down
21 changes: 11 additions & 10 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@
"outDir": "dist",
"declaration": true,
"esModuleInterop": true,
"types": [
"node"
]
"types": ["node"]
},
"include": [
"lib/front_matter.ts"
],
"exclude": [
"node_modules"
]
}
"include": ["lib/front_matter.ts"],
"exclude": ["node_modules"],

"ts-node": {
"transpileOnly": true,
"compilerOptions": {
"types": ["node", "mocha", "chai"]
}
}
}