Skip to content

Commit 63e83dc

Browse files
0x-r4bbitiurimatias
authored andcommitted
refactor(@embark/core): migrate console module tests to jets and embark-testing
1 parent bef582d commit 63e83dc

File tree

4 files changed

+62
-71
lines changed

4 files changed

+62
-71
lines changed

packages/core/console/package.json

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -36,20 +36,18 @@
3636
"ci": "npm run qa",
3737
"clean": "npm run reset",
3838
"lint": "npm-run-all lint:*",
39-
"lint:js": "eslint src/",
4039
"lint:ts": "tslint -c tslint.json \"src/**/*.ts\"",
4140
"qa": "npm-run-all lint _typecheck _build test",
4241
"reset": "npx rimraf .nyc_output coverage dist embark-*.tgz package",
4342
"solo": "embark-solo",
44-
"test": "nyc --reporter=html --reporter=json mocha \"dist/test/**/*.js\" --exit --no-timeouts --require source-map-support/register"
43+
"test": "jest"
4544
},
4645
"eslintConfig": {
4746
"extends": "../../../.eslintrc.json"
4847
},
4948
"dependencies": {
5049
"@babel/runtime-corejs3": "7.7.4",
5150
"@types/json-stringify-safe": "5.0.0",
52-
"async": "2.6.1",
5351
"chalk": "2.4.2",
5452
"core-js": "3.4.3",
5553
"embark-core": "^5.1.0-nightly.4",
@@ -59,14 +57,14 @@
5957
"json-stringify-safe": "5.0.1"
6058
},
6159
"devDependencies": {
60+
"@babel/core": "7.7.4",
61+
"babel-jest": "24.9.0",
6262
"embark-logger": "^5.1.0-nightly.1",
6363
"embark-solo": "^5.1.0-nightly.1",
64-
"eslint": "5.7.0",
65-
"mocha": "6.2.2",
64+
"embark-testing": "^5.1.0-nightly.1",
65+
"jest": "24.9.0",
6666
"npm-run-all": "4.1.5",
67-
"nyc": "13.1.0",
6867
"rimraf": "3.0.0",
69-
"source-map-support": "0.5.13",
7068
"tslint": "5.20.1",
7169
"typescript": "3.7.2"
7270
},
@@ -75,11 +73,19 @@
7573
"npm": ">=6.11.3",
7674
"yarn": ">=1.19.1"
7775
},
78-
"nyc": {
79-
"exclude": [
80-
"**/node_modules/**",
81-
"coverage/**",
82-
"dist/test/**"
83-
]
76+
"jest": {
77+
"collectCoverage": true,
78+
"testEnvironment": "node",
79+
"testMatch": [
80+
"**/test/**/*.js"
81+
],
82+
"transform": {
83+
"\\.(js|ts)$": [
84+
"babel-jest",
85+
{
86+
"rootMode": "upward"
87+
}
88+
]
89+
}
8490
}
8591
}

packages/core/console/src/test/console.js

Lines changed: 0 additions & 58 deletions
This file was deleted.
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/*globals describe, it*/
2+
import assert from 'assert';
3+
import { fakeEmbark } from 'embark-testing';
4+
import Console from '../src/lib';
5+
import { version } from '../package.json';
6+
7+
// Due to our `DAPP_PATH` dependency in `embark-utils` `dappPath()`, we need to
8+
// ensure that this environment variable is defined.
9+
process.env.DAPP_PATH = 'something';
10+
11+
describe('core/console', () => {
12+
13+
const { embark, plugins } = fakeEmbark();
14+
15+
16+
let console;
17+
18+
beforeEach(() => {
19+
console = new Console(embark, {
20+
ipc: embark.config.ipc,
21+
events: embark.events,
22+
plugins: embark.plugins,
23+
logger: embark.logger,
24+
version
25+
});
26+
});
27+
28+
afterEach(() => {
29+
embark.teardown();
30+
});
31+
32+
it('it should provide a help text', (done) => {
33+
console.executeCmd('help', (_err, output) => {
34+
let lines = output.split('\n');
35+
assert.equal(lines[0], 'Welcome to Embark ' + version);
36+
assert.equal(lines[2], 'possible commands are:');
37+
done();
38+
});
39+
});
40+
});

packages/core/console/tsconfig.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010
"src/lib/**/*"
1111
],
1212
"references": [
13+
{
14+
"path": "../../utils/testing"
15+
},
1316
{
1417
"path": "../core"
1518
},

0 commit comments

Comments
 (0)