Skip to content

Commit 1a0468a

Browse files
Drew DiamantoukosDavertMik
Drew Diamantoukos
authored andcommitted
Typings (#699)
* Fixing * Updaing helper code * Home stretch for compiler fixes, just two left * Touched up tests and Mocha Base reporter class type * Adding some lint-related fixes for nightmarejs and appium * Using value in Nightmare test instead of nodeValue * Reverted Appium default config initialization location. Fixed waitFor methods in Nightmare to handle default parameter. * Added the package-lock generated by npm 5 * Reverted using sec for parameter name for wait Helper methods
1 parent d64af52 commit 1a0468a

38 files changed

+16304
-317
lines changed

Diff for: .eslintrc

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
"env": {
44
"node": true,
55
"mocha": true,
6-
"es6": true
6+
"es6": true,
7+
"browser": true
78
},
89
"ecmaFeatures": {
910
"jsx": true,

Diff for: gulpfile.js

+7
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ var glob = require('glob');
1111
var guppy = require('git-guppy')(gulp);
1212
var gitmodified = require('gulp-gitmodified');
1313
var istanbul = require('gulp-istanbul');
14+
var ts = require("gulp-typescript");
15+
var tsProject = ts.createProject("tsconfig.json");
1416

1517
function isFixed(file) {
1618
// Has ESLint fixed the file contents?
@@ -46,6 +48,11 @@ gulp.task('static', function () {
4648
.pipe(gulp.dest('lib'));
4749
});
4850

51+
gulp.task('type-check', function () {
52+
return tsProject.src()
53+
.pipe(tsProject());
54+
});
55+
4956
gulp.task('pre-commit', ['static']);
5057

5158
gulp.task('pre-test', function () {

Diff for: lib/assert/error.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,10 @@ function AssertionFailedError(params, template) {
1212
// this.message = "AssertionFailedError";
1313
let stack = new Error().stack;
1414
// this.showDiff = true;
15-
stack = stack.split("\n").filter((line) => {
15+
stack = stack ? stack.split("\n").filter((line) => {
1616
// @todo cut assert things nicer
1717
return line.indexOf('lib/assert') < 0;
18-
});
19-
this.stack = stack.join("\n");
18+
}).join("\n") : '';
2019
this.showDiff = true;
2120

2221
this.actual = this.params.actual;

Diff for: lib/codecept.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,12 @@ class Codecept {
2727
constructor(config, opts) {
2828
this.config = config;
2929
this.opts = opts;
30-
this.testFiles = [];
30+
this.testFiles = new Array();
3131
}
3232

3333
/**
3434
* Initialize CodeceptJS at specific directory.
35-
* If async initialization is required pass callbacke as second parameter.
35+
* If async initialization is required, pass callback as second parameter.
3636
*
3737
* @param {*} dir
3838
* @param {*} callback
@@ -82,26 +82,26 @@ class Codecept {
8282
*
8383
* @param {*} done
8484
*/
85-
teardown(done) {
85+
teardown(done = undefined) {
8686
runHook(this.config.teardown, done, 'teardown');
8787
}
8888

8989
/**
9090
* Loads tests by pattern or by config.tests
9191
*
92-
* @param {optional} pattern
92+
* @param {string} [pattern]
9393
*/
9494
loadTests(pattern) {
9595
pattern = pattern || this.config.tests;
96-
glob.sync(fsPath.resolve(codecept_dir, pattern)).forEach((file) => {
96+
glob.sync(fsPath.resolve(global.codecept_dir, pattern)).forEach((file) => {
9797
this.testFiles.push(fsPath.resolve(file));
9898
});
9999
}
100100

101101
/**
102102
* Run a specific test or all loaded tests.
103103
*
104-
* @param {optional} test
104+
* @param {string} [test]
105105
*/
106106
run(test) {
107107
let mocha = Container.mocha();

Diff for: lib/command/init.js

+6-3
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ let mkdirp = require('mkdirp');
1414
let defaultConfig = {
1515
tests: "./*_test.js",
1616
timeout: 10000,
17-
output: null,
17+
output: '',
1818
helpers: {},
1919
include: {},
2020
bootstrap: false,
@@ -118,8 +118,11 @@ module.exports = function (initPath) {
118118
config.output = result.output;
119119

120120
config.tests = result.tests;
121-
// create a directory tests it is included in tests path
122-
mkdirp.sync(path.join(testsPath, config.tests.match(/[^*.]+/)[0]));
121+
// create a directory tests if it is included in tests path
122+
let matchResults = config.tests.match(/[^*.]+/);
123+
if (matchResults) {
124+
mkdirp.sync(path.join(testsPath, matchResults[0]));
125+
}
123126

124127
// append file mask to the end of tests
125128
if (!config.tests.match(/\*(.*?)$/)) {

Diff for: lib/command/list.js

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
'use strict';
22

3-
let urils = require('../utils');
43
let getConfig = require('./utils').getConfig;
54
let getTestRoot = require('./utils').getTestRoot;
65
let Codecept = require('../codecept');
@@ -21,7 +20,7 @@ module.exports = function (path) {
2120

2221
output.print('List of test actions: -- ');
2322
let helpers = container.helpers();
24-
let suppportI = container.support('I');
23+
let supportI = container.support('I');
2524
let actions = [];
2625
for (let name in helpers) {
2726
let helper = helpers[name];
@@ -31,11 +30,11 @@ module.exports = function (path) {
3130
output.print(` ${output.colors.grey(name)} I.${output.colors.bold(action)}(${params})`);
3231
});
3332
}
34-
for (let name in suppportI) {
33+
for (let name in supportI) {
3534
if (actions[name]) {
3635
continue;
3736
}
38-
let actor = suppportI[name];
37+
let actor = supportI[name];
3938
let params = getParamsToString(actor);
4039
output.print(` I.${output.colors.bold(name)}(${params})`);
4140
}

Diff for: lib/command/run-multiple.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,8 @@ function replaceValue(obj, key, value) {
155155
if (obj[key]) obj[key] = value;
156156
if (typeof obj === "object" && obj !== null) {
157157
var children = Object.keys(obj);
158-
for (i = 0; i < children.length; i++) {
159-
replaceValue(obj[children[i]], key, value);
158+
for (let childIndex = 0; childIndex < children.length; childIndex++) {
159+
replaceValue(obj[children[childIndex]], key, value);
160160
}
161161
}
162162
return obj;

Diff for: lib/container.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class Container {
3434
* Get all support objects or get support object by name
3535
*
3636
* @api
37-
* @param {optional} name
37+
* @param {string} [name]
3838
*/
3939
static support(name) {
4040
if (!name) {
@@ -47,7 +47,7 @@ class Container {
4747
* Get all helpers or get a helper by name
4848
*
4949
* @api
50-
* @param {optional} name
50+
* @param {string} [name]
5151
*/
5252
static helpers(name) {
5353
if (!name) {
@@ -104,10 +104,10 @@ function createHelpers(config) {
104104
let helperModule;
105105
for (let helperName in config) {
106106
try {
107-
module = config[helperName].require
107+
let moduleName = config[helperName].require
108108
? path.resolve(global.codecept_dir, config[helperName].require) // custom helper
109109
: './helper/' + helperName; // built-in helper
110-
let HelperClass = require(module);
110+
let HelperClass = require(moduleName);
111111
if (HelperClass._checkRequirements) {
112112
let requirements = HelperClass._checkRequirements();
113113
if (requirements) {

Diff for: lib/data/table.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ class DataTable {
77

88
constructor(array) {
99
this.array = array;
10-
this.rows = [];
10+
this.rows = new Array();
1111
}
1212

1313
add(array) {

Diff for: lib/helper.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class Helper {
2323
}
2424

2525
/**
26-
* Abstract method to provide requried config options
26+
* Abstract method to provide required config options
2727
*/
2828
static _config() {
2929

0 commit comments

Comments
 (0)