Skip to content

Commit 6e4f43e

Browse files
committed
Replace mocha by jest
1 parent 09f580c commit 6e4f43e

File tree

5 files changed

+21
-10
lines changed

5 files changed

+21
-10
lines changed

jest.config.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
'use strict';
2+
3+
module.exports = {
4+
clearMocks: true,
5+
coverageDirectory: 'reports/coverage',
6+
testEnvironment: 'node',
7+
testMatch: [
8+
'**/tests/lib/**/*.[jt]s?(x)',
9+
'**/tests/util/**/*.[jt]s?(x)',
10+
'**/tests/index.[jt]s?(x)'
11+
]
12+
};

package.json

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
"lint": "eslint ./",
1010
"pretest": "npm run lint",
1111
"test": "npm run unit-test",
12-
"unit-test": "istanbul cover --dir reports/coverage node_modules/mocha/bin/_mocha tests/lib/**/*.js tests/util/**/*.js tests/index.js"
12+
"test:watch": "jest --watch",
13+
"unit-test": "jest --coverage"
1314
},
1415
"files": [
1516
"LICENSE",
@@ -37,9 +38,7 @@
3738
"babel-eslint": "^10.0.1",
3839
"coveralls": "^3.0.2",
3940
"eslint": "^3.0.0 || ^4.0.0 || ^5.0.0",
40-
"istanbul": "^0.4.5",
41-
"mocha": "^6.1.4",
42-
"sinon": "^7.2.2",
41+
"jest": "^24.7.1",
4342
"typescript": "^3.2.2"
4443
},
4544
"peerDependencies": {

tests/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* eslint-env mocha */
1+
/* eslint-env jest */
22
'use strict';
33

44
const plugin = require('..');

tests/util/.eslintrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
22
"env": {
3-
"mocha": true
3+
"jest": true
44
}
55
}

tests/util/version.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,26 @@
22

33
const path = require('path');
44
const assert = require('assert');
5-
const sinon = require('sinon');
65
const versionUtil = require('../../lib/util/version');
76

87
describe('Version', () => {
98
const base = path.resolve(__dirname, '..', 'fixtures', 'version');
109
let cwd;
1110
let expectedErrorArgs = [];
11+
let spy;
1212

1313
beforeEach(() => {
1414
cwd = process.cwd();
1515
process.chdir(base);
16-
sinon.stub(console, 'error');
16+
spy = jest.spyOn(console, 'error').mockImplementation(() => {});
1717
expectedErrorArgs = [];
1818
});
1919

2020
afterEach(() => {
2121
process.chdir(cwd);
2222

23-
const actualArgs = console.error.args; // eslint-disable-line no-console
24-
console.error.restore(); // eslint-disable-line no-console
23+
const actualArgs = console.error.mock.calls; // eslint-disable-line no-console
24+
spy.mockRestore();
2525
assert.deepEqual(actualArgs, expectedErrorArgs);
2626
});
2727

0 commit comments

Comments
 (0)