diff --git a/packages/core/console/package.json b/packages/core/console/package.json index 8446793b9..7786b06e3 100644 --- a/packages/core/console/package.json +++ b/packages/core/console/package.json @@ -36,12 +36,11 @@ "ci": "npm run qa", "clean": "npm run reset", "lint": "npm-run-all lint:*", - "lint:js": "eslint src/", "lint:ts": "tslint -c tslint.json \"src/**/*.ts\"", "qa": "npm-run-all lint _typecheck _build test", "reset": "npx rimraf .nyc_output coverage dist embark-*.tgz package", "solo": "embark-solo", - "test": "nyc --reporter=html --reporter=json mocha \"dist/test/**/*.js\" --exit --no-timeouts --require source-map-support/register" + "test": "jest" }, "eslintConfig": { "extends": "../../../.eslintrc.json" @@ -49,7 +48,6 @@ "dependencies": { "@babel/runtime-corejs3": "7.7.4", "@types/json-stringify-safe": "5.0.0", - "async": "2.6.1", "chalk": "2.4.2", "core-js": "3.4.3", "embark-core": "^5.1.0-nightly.4", @@ -59,14 +57,14 @@ "json-stringify-safe": "5.0.1" }, "devDependencies": { + "@babel/core": "7.7.4", + "babel-jest": "24.9.0", "embark-logger": "^5.1.0-nightly.1", "embark-solo": "^5.1.0-nightly.1", - "eslint": "5.7.0", - "mocha": "6.2.2", + "embark-testing": "^5.1.0-nightly.1", + "jest": "24.9.0", "npm-run-all": "4.1.5", - "nyc": "13.1.0", "rimraf": "3.0.0", - "source-map-support": "0.5.13", "tslint": "5.20.1", "typescript": "3.7.2" }, @@ -75,11 +73,19 @@ "npm": ">=6.11.3", "yarn": ">=1.19.1" }, - "nyc": { - "exclude": [ - "**/node_modules/**", - "coverage/**", - "dist/test/**" - ] + "jest": { + "collectCoverage": true, + "testEnvironment": "node", + "testMatch": [ + "**/test/**/*.js" + ], + "transform": { + "\\.(js|ts)$": [ + "babel-jest", + { + "rootMode": "upward" + } + ] + } } } diff --git a/packages/core/console/src/test/console.js b/packages/core/console/src/test/console.js deleted file mode 100644 index 369231c1f..000000000 --- a/packages/core/console/src/test/console.js +++ /dev/null @@ -1,58 +0,0 @@ -/*globals describe, it*/ -import Console from '../lib'; -import { Logger } from 'embark-logger'; -import { joinPath, setUpEnv } from 'embark-utils'; -import assert from 'assert'; -import { version } from '../../package.json'; - -setUpEnv(joinPath(__dirname, '../../../../embark')); - -describe('embark.Console', function() { - let logger = new Logger({logLevel: 'error'}); - let ipc = { - isServer: () => { return true; }, - broadcast: () => {}, - on: () => {}, - isClient: () => { return false; } - }; - let events = {once: () => {}, setCommandHandler: () => {}, emit: () => {}, on: () => {}, request: () => {}}; - let plugins = { - logger: logger, - createPlugin: () => { return {registerAPICall: () => {}}; }, - getPluginsProperty: () => { return []; } - }; - let embarkObject = { - registerAPICall: () => {}, - events: events, - logger: plugins.logger, - fs: { - existsSync: () => { return false; }, - dappPath: () => { return "ok"; } - }, - registerConsoleCommand: (_cmd, _opt) => {}, - embarkConfig: { - options: { - solc: { - "optimize": true, - "optimize-runs": 200 - } - } - } - }; - let console = new Console(embarkObject, {plugins, version, ipc, events, logger}); - - describe('#executeCmd', function() { - - describe('command: help', function() { - - it('it should provide a help text', function(done) { - console.executeCmd('help', function(_err, output) { - let lines = output.split('\n'); - assert.equal(lines[0], 'Welcome to Embark ' + version); - assert.equal(lines[2], 'possible commands are:'); - done(); - }); - }); - }); - }); -}); diff --git a/packages/core/console/test/console.spec.js b/packages/core/console/test/console.spec.js new file mode 100644 index 000000000..4d7389845 --- /dev/null +++ b/packages/core/console/test/console.spec.js @@ -0,0 +1,40 @@ +/*globals describe, it*/ +import assert from 'assert'; +import { fakeEmbark } from 'embark-testing'; +import Console from '../src/lib'; +import { version } from '../package.json'; + +// Due to our `DAPP_PATH` dependency in `embark-utils` `dappPath()`, we need to +// ensure that this environment variable is defined. +process.env.DAPP_PATH = 'something'; + +describe('core/console', () => { + + const { embark, plugins } = fakeEmbark(); + + + let console; + + beforeEach(() => { + console = new Console(embark, { + ipc: embark.config.ipc, + events: embark.events, + plugins: embark.plugins, + logger: embark.logger, + version + }); + }); + + afterEach(() => { + embark.teardown(); + }); + + it('it should provide a help text', (done) => { + console.executeCmd('help', (_err, output) => { + let lines = output.split('\n'); + assert.equal(lines[0], 'Welcome to Embark ' + version); + assert.equal(lines[2], 'possible commands are:'); + done(); + }); + }); +}); diff --git a/packages/core/console/tsconfig.json b/packages/core/console/tsconfig.json index 7510c18f6..f9c7ff106 100644 --- a/packages/core/console/tsconfig.json +++ b/packages/core/console/tsconfig.json @@ -10,6 +10,9 @@ "src/lib/**/*" ], "references": [ + { + "path": "../../utils/testing" + }, { "path": "../core" },