diff --git a/jest.config.js b/jest.config.js new file mode 100644 index 0000000000..453806d390 --- /dev/null +++ b/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)' + ] +}; diff --git a/package.json b/package.json index e31d5e6de2..1f205a96d7 100644 --- a/package.json +++ b/package.json @@ -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", @@ -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": { diff --git a/tests/index.js b/tests/index.js index 69c8051fae..914ca65882 100644 --- a/tests/index.js +++ b/tests/index.js @@ -1,4 +1,4 @@ -/* eslint-env mocha */ +/* eslint-env jest */ 'use strict'; const plugin = require('..'); diff --git a/tests/util/.eslintrc b/tests/util/.eslintrc index 078e30c590..e6c347adc3 100644 --- a/tests/util/.eslintrc +++ b/tests/util/.eslintrc @@ -1,5 +1,5 @@ { "env": { - "mocha": true + "jest": true } } diff --git a/tests/util/version.js b/tests/util/version.js index cf0eaf034c..cb56e9463b 100644 --- a/tests/util/version.js +++ b/tests/util/version.js @@ -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); });