Skip to content

Commit 48099c1

Browse files
test: migrate from mocha to jest
Update package.json devDependencies: ```diff +jest -mocha -nyc ``` Update package.json scripts and remove `test:coverage:report` Run `jest-codemods` (https://jestjs.io/docs/en/migration-guide): ```sh jscodeshift -t jest-codemods/dist/transformers/mocha.js . --ignore-pattern node_modules --parser babel ``` Rename files under `test` directory Update eslint, husky, travis, and tsconfig
1 parent 179f359 commit 48099c1

11 files changed

+13
-15
lines changed

Diff for: .eslintrc.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"env": {
33
"browser": true,
44
"commonjs": true,
5-
"mocha": true,
5+
"jest": true,
66
"node": true
77
},
88
"extends": "eslint:recommended",

Diff for: .huskyrc.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"hooks": {
33
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS",
4-
"pre-commit": "npm run lint:dts && npm run test:coverage && lint-staged"
4+
"pre-commit": "npm run lint:dts && npm test && lint-staged"
55
}
66
}

Diff for: .travis.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ script:
88
- npx commitlint --from=HEAD~1
99
- npm run lint
1010
- npm run lint:dts
11-
- npm run test:coverage
11+
- npm test
1212
- npm run build
1313
- npm run benchmark
1414
after_success:
15-
- npx nyc report --reporter=text-lcov | npx coveralls
15+
- cat coverage/lcov.info | npx coveralls
1616
cache:
1717
directories:
1818
- node_modules

Diff for: package.json

+3-5
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,8 @@
1313
"lint:fix": "npm run lint -- --fix",
1414
"prepublishOnly": "npm run lint && npm run lint:dts && npm test && npm run clean && npm run build",
1515
"release": "standard-version --no-verify",
16-
"test": "mocha",
17-
"test:coverage": "nyc npm test",
18-
"test:coverage:report": "nyc report --reporter=html"
16+
"test": "jest --coverage",
17+
"test:watch": "npm test -- --watch"
1918
},
2019
"repository": {
2120
"type": "git",
@@ -49,9 +48,8 @@
4948
"eslint": "^7.1.0",
5049
"eslint-plugin-prettier": "^3.1.3",
5150
"husky": "^4.2.5",
51+
"jest": "^26.0.1",
5252
"lint-staged": "^10.2.7",
53-
"mocha": "^7.2.0",
54-
"nyc": "^15.1.0",
5553
"preact": "^10.4.4",
5654
"prettier": "^2.0.5",
5755
"react": "^16",

Diff for: test/attributes-to-props.js renamed to test/attributes-to-props.test.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -259,11 +259,11 @@ describe('attributes to props', () => {
259259
describe('when utilties.PRESERVE_CUSTOM_ATTRIBUTES=false', () => {
260260
const { PRESERVE_CUSTOM_ATTRIBUTES } = utilities;
261261

262-
before(() => {
262+
beforeAll(() => {
263263
utilities.PRESERVE_CUSTOM_ATTRIBUTES = false;
264264
});
265265

266-
after(() => {
266+
afterAll(() => {
267267
utilities.PRESERVE_CUSTOM_ATTRIBUTES = PRESERVE_CUSTOM_ATTRIBUTES;
268268
});
269269

Diff for: test/dom-to-react.js renamed to test/dom-to-react.test.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -210,11 +210,11 @@ describe('DOM to React', () => {
210210
describe('when React <16', () => {
211211
const { PRESERVE_CUSTOM_ATTRIBUTES } = utilities;
212212

213-
before(() => {
213+
beforeAll(() => {
214214
utilities.PRESERVE_CUSTOM_ATTRIBUTES = false;
215215
});
216216

217-
after(() => {
217+
afterAll(() => {
218218
utilities.PRESERVE_CUSTOM_ATTRIBUTES = PRESERVE_CUSTOM_ATTRIBUTES;
219219
});
220220

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

Diff for: tsconfig.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"files": [
2020
"index.d.ts",
2121
"lib/dom-to-react.d.ts",
22-
"test/types/index.test.tsx",
23-
"test/types/lib/dom-to-react.test.tsx"
22+
"test/types/index.tsx",
23+
"test/types/lib/dom-to-react.tsx"
2424
]
2525
}

0 commit comments

Comments
 (0)