Skip to content

Commit

Permalink
Added basic tests using mocha and chai
Browse files Browse the repository at this point in the history
  • Loading branch information
theenadayalank committed Jun 7, 2019
1 parent 4da862a commit 716a7b4
Show file tree
Hide file tree
Showing 4 changed files with 627 additions and 53 deletions.
27 changes: 24 additions & 3 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@ module.exports = {
ecmaVersion: 2017,
sourceType: "module"
},
extends: ["eslint:recommended", "plugin:node/recommended"],
extends: [
"eslint:recommended",
"plugin:node/recommended"
],
rules: {
// overwritten Eslint rule recommeded rule
"space-unary-ops": [
"error",
{
Expand Down Expand Up @@ -37,5 +39,24 @@ module.exports = {
"func-call-spacing": ["error", "never"],
"space-before-function-paren": ["error", "never"],
semi: "error"
}
},
overrides: [
// test files
{
files: ['tests/**/*.js'],
parserOptions: {
sourceType: 'script',
ecmaVersion: 2017
},
env: {
mocha: true
},
plugins: [
"mocha"
],
rules: {
"mocha/no-exclusive-tests": "error"
}
}
]
};
13 changes: 8 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
"lint-prepush": "index.js"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"lint": "node_modules/.bin/eslint **/*.js",
"format": "yarn lint --fix",
"test": "mocha tests/",
"prepush": "node index.js"
},
"lint-prepush": {
Expand All @@ -21,13 +21,16 @@
}
},
"devDependencies": {
"eslint": "^5.14.1",
"chai": "^4.2.0",
"eslint": "^5.16.0",
"eslint-plugin-mocha": "^5.3.0",
"eslint-plugin-node": "^8.0.1",
"husky": "^0.14.3"
"husky": "^0.14.3",
"mocha": "^6.1.4"
},
"dependencies": {
"chalk": "^2.4.1",
"cosmiconfig": "^5.0.5",
"cosmiconfig": "^5.2.1",
"debug": "^3.1.0",
"dedent": "^0.7.0",
"execa": "^0.10.0",
Expand All @@ -38,7 +41,7 @@
"npm-which": "^3.0.1"
},
"engines": {
"node": ">=6"
"node": ">=7.6.0"
},
"repository": {
"type": "git",
Expand Down
13 changes: 13 additions & 0 deletions tests/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
const chai = require('chai'); // eslint-disable-line node/no-unpublished-require
const { expect } = chai;
const { execChildProcess } = require('../utils/common');

describe('Test commmon util functions', () => {
describe('Assert execChildProcess() function', () => {
it('should return Hello World', () => {
return execChildProcess({ command : "echo 'Hello World!' " }).then( (result = '') => {
expect(result).to.equal('Hello World!');
});
});
});
});
Loading

0 comments on commit 716a7b4

Please sign in to comment.