Skip to content

Commit

Permalink
Replace mocha by jest
Browse files Browse the repository at this point in the history
  • Loading branch information
yannickcr committed Apr 28, 2019
1 parent 09f580c commit 6e4f43e
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 10 deletions.
12 changes: 12 additions & 0 deletions jest.config.js
@@ -0,0 +1,12 @@
'use strict';

module.exports = {
clearMocks: true,
coverageDirectory: 'reports/coverage',
testEnvironment: 'node',
testMatch: [
'**/tests/lib/**/*.[jt]s?(x)',
'**/tests/util/**/*.[jt]s?(x)',
'**/tests/index.[jt]s?(x)'
]
};
7 changes: 3 additions & 4 deletions package.json
Expand Up @@ -9,7 +9,8 @@
"lint": "eslint ./",
"pretest": "npm run lint",
"test": "npm run unit-test",
"unit-test": "istanbul cover --dir reports/coverage node_modules/mocha/bin/_mocha tests/lib/**/*.js tests/util/**/*.js tests/index.js"
"test:watch": "jest --watch",
"unit-test": "jest --coverage"
},
"files": [
"LICENSE",
Expand Down Expand Up @@ -37,9 +38,7 @@
"babel-eslint": "^10.0.1",
"coveralls": "^3.0.2",
"eslint": "^3.0.0 || ^4.0.0 || ^5.0.0",
"istanbul": "^0.4.5",
"mocha": "^6.1.4",
"sinon": "^7.2.2",
"jest": "^24.7.1",
"typescript": "^3.2.2"
},
"peerDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion tests/index.js
@@ -1,4 +1,4 @@
/* eslint-env mocha */
/* eslint-env jest */
'use strict';

const plugin = require('..');
Expand Down
2 changes: 1 addition & 1 deletion tests/util/.eslintrc
@@ -1,5 +1,5 @@
{
"env": {
"mocha": true
"jest": true
}
}
8 changes: 4 additions & 4 deletions tests/util/version.js
Expand Up @@ -2,26 +2,26 @@

const path = require('path');
const assert = require('assert');
const sinon = require('sinon');
const versionUtil = require('../../lib/util/version');

describe('Version', () => {
const base = path.resolve(__dirname, '..', 'fixtures', 'version');
let cwd;
let expectedErrorArgs = [];
let spy;

beforeEach(() => {
cwd = process.cwd();
process.chdir(base);
sinon.stub(console, 'error');
spy = jest.spyOn(console, 'error').mockImplementation(() => {});
expectedErrorArgs = [];
});

afterEach(() => {
process.chdir(cwd);

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

Expand Down

0 comments on commit 6e4f43e

Please sign in to comment.