datagrok-tools 4.12.26 → 4.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/bin/commands/test.js
CHANGED
|
@@ -24,7 +24,7 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
|
|
|
24
24
|
|
|
25
25
|
function test(args) {
|
|
26
26
|
var options = Object.keys(args).slice(1);
|
|
27
|
-
var commandOptions = ['host', 'csv', 'gui', 'catchUnhandled', 'platform', 'core', 'report', 'skip-build', 'skip-publish', 'path', 'record', 'verbose', 'benchmark'];
|
|
27
|
+
var commandOptions = ['host', 'package', 'csv', 'gui', 'catchUnhandled', 'platform', 'core', 'report', 'skip-build', 'skip-publish', 'path', 'record', 'verbose', 'benchmark'];
|
|
28
28
|
var nArgs = args['_'].length;
|
|
29
29
|
var curDir = process.cwd();
|
|
30
30
|
var grokDir = _path["default"].join(_os["default"].homedir(), '.grok');
|
|
@@ -32,10 +32,6 @@ function test(args) {
|
|
|
32
32
|
if (nArgs > 1 || options.length > commandOptions.length || options.length > 0 && !options.every(function (op) {
|
|
33
33
|
return commandOptions.includes(op);
|
|
34
34
|
})) return false;
|
|
35
|
-
if (!utils.isPackageDir(curDir)) {
|
|
36
|
-
color.error('File `package.json` not found. Run the command from the package directory');
|
|
37
|
-
return false;
|
|
38
|
-
}
|
|
39
35
|
if (!_fs["default"].existsSync(confPath)) {
|
|
40
36
|
color.error("File `".concat(confPath, "` not found. Run `grok config` to set up the config file"));
|
|
41
37
|
return false;
|
|
@@ -55,16 +51,25 @@ function test(args) {
|
|
|
55
51
|
process.env.HOST = config["default"];
|
|
56
52
|
console.log('Environment variable `HOST` is set to', config["default"]);
|
|
57
53
|
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
}));
|
|
61
|
-
if (packageData.name) {
|
|
62
|
-
process.env.TARGET_PACKAGE = utils.kebabToCamelCase(utils.removeScope(packageData.name));
|
|
63
|
-
console.log('Environment variable `TARGET_PACKAGE` is set to', process.env.TARGET_PACKAGE);
|
|
54
|
+
if (args["package"]) {
|
|
55
|
+
process.env.TARGET_PACKAGE = utils.kebabToCamelCase(args["package"]);
|
|
64
56
|
} else {
|
|
65
|
-
|
|
66
|
-
|
|
57
|
+
if (!utils.isPackageDir(curDir)) {
|
|
58
|
+
color.error('File `package.json` not found. Run the command from the package directory or specify plugin using \'--package\' option');
|
|
59
|
+
return false;
|
|
60
|
+
} else {
|
|
61
|
+
var packageData = JSON.parse(_fs["default"].readFileSync(_path["default"].join(curDir, 'package.json'), {
|
|
62
|
+
encoding: 'utf-8'
|
|
63
|
+
}));
|
|
64
|
+
if (packageData.name) {
|
|
65
|
+
process.env.TARGET_PACKAGE = utils.kebabToCamelCase(packageData.name);
|
|
66
|
+
} else {
|
|
67
|
+
color.error('Invalid package name. Set the `name` field in `package.json`');
|
|
68
|
+
return false;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
67
71
|
}
|
|
72
|
+
console.log('Environment variable `TARGET_PACKAGE` is set to', process.env.TARGET_PACKAGE);
|
|
68
73
|
if (args.platform && process.env.TARGET_PACKAGE !== 'ApiTests') {
|
|
69
74
|
color.error('--platform flag can only be used in the ApiTests package');
|
|
70
75
|
return false;
|
|
@@ -73,11 +78,17 @@ function test(args) {
|
|
|
73
78
|
color.error('--core flag can only be used in the DevTools package');
|
|
74
79
|
return false;
|
|
75
80
|
}
|
|
76
|
-
if (args['skip-
|
|
77
|
-
|
|
78
|
-
} else
|
|
79
|
-
|
|
80
|
-
|
|
81
|
+
if (args['skip-publish'] || args["package"]) {
|
|
82
|
+
test();
|
|
83
|
+
} else {
|
|
84
|
+
if (args['skip-build']) {
|
|
85
|
+
publish(test);
|
|
86
|
+
} else {
|
|
87
|
+
build(function () {
|
|
88
|
+
return publish(test);
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
}
|
|
81
92
|
function build(callback) {
|
|
82
93
|
(0, _child_process.exec)('npm run build', function (err, stdout, stderr) {
|
|
83
94
|
color.info("Building package...");
|
|
@@ -140,31 +151,38 @@ function test(args) {
|
|
|
140
151
|
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
141
152
|
return testUtils.runWithTimeout(timeout, /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2() {
|
|
142
153
|
var _process$env$TARGET_P;
|
|
143
|
-
var
|
|
154
|
+
var consoleLogOutputDir, addLogsToFile, targetPackage, r;
|
|
144
155
|
return _regenerator["default"].wrap(function _callee2$(_context2) {
|
|
145
156
|
while (1) switch (_context2.prev = _context2.next) {
|
|
146
157
|
case 0:
|
|
147
|
-
|
|
158
|
+
addLogsToFile = function _addLogsToFile(msg) {
|
|
159
|
+
_fs["default"].appendFileSync(consoleLogOutputDir, "".concat(msg));
|
|
160
|
+
};
|
|
161
|
+
consoleLogOutputDir = './test-console-output.log';
|
|
162
|
+
_context2.next = 4;
|
|
163
|
+
return page.exposeFunction("addLogsToFile", addLogsToFile);
|
|
164
|
+
case 4:
|
|
148
165
|
if (!options.record) {
|
|
149
|
-
_context2.next =
|
|
166
|
+
_context2.next = 11;
|
|
150
167
|
break;
|
|
151
168
|
}
|
|
152
|
-
|
|
169
|
+
_fs["default"].writeFileSync(consoleLogOutputDir, "");
|
|
170
|
+
_context2.next = 8;
|
|
153
171
|
return recorder.start('./test-record.mp4');
|
|
154
|
-
case
|
|
172
|
+
case 8:
|
|
155
173
|
page.on('console', function (msg) {
|
|
156
|
-
|
|
174
|
+
addLogsToFile("CONSOLE LOG ENTRY: ".concat(msg.text(), "\n"));
|
|
157
175
|
});
|
|
158
176
|
page.on('pageerror', function (error) {
|
|
159
|
-
|
|
177
|
+
addLogsToFile("CONSOLE LOG ERROR: ".concat(error.message, "\n"));
|
|
160
178
|
});
|
|
161
179
|
page.on('response', function (response) {
|
|
162
|
-
|
|
180
|
+
addLogsToFile("CONSOLE LOG REQUEST: ".concat(response.status(), ", ").concat(response.url(), "\n"));
|
|
163
181
|
});
|
|
164
|
-
case
|
|
182
|
+
case 11:
|
|
165
183
|
targetPackage = (_process$env$TARGET_P = process.env.TARGET_PACKAGE) !== null && _process$env$TARGET_P !== void 0 ? _process$env$TARGET_P : '#{PACKAGE_NAMESPACE}';
|
|
166
184
|
console.log("Testing ".concat(targetPackage, " package...\n"));
|
|
167
|
-
_context2.next =
|
|
185
|
+
_context2.next = 15;
|
|
168
186
|
return page.evaluate(function (targetPackage, options, testContext) {
|
|
169
187
|
if (options.benchmark) window.DG.Test.isInBenchmark = true;
|
|
170
188
|
return new Promise(function (resolve, reject) {
|
|
@@ -191,7 +209,7 @@ function test(args) {
|
|
|
191
209
|
};
|
|
192
210
|
if (df == null) {
|
|
193
211
|
failed = true;
|
|
194
|
-
failReport = "Fail reason: No package tests found".concat(options.path ?
|
|
212
|
+
failReport = "Fail reason: No package tests found".concat(options.path ? ' for path "' + options.path + '"' : '');
|
|
195
213
|
resolve({
|
|
196
214
|
failReport: failReport,
|
|
197
215
|
skipReport: skipReport,
|
|
@@ -234,34 +252,33 @@ function test(args) {
|
|
|
234
252
|
countReport: countReport
|
|
235
253
|
});
|
|
236
254
|
})["catch"](function (e) {
|
|
237
|
-
var stack = window.DG.Logger.translateStackTrace(e.stack)
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
255
|
+
var stack = window.DG.Logger.translateStackTrace(e.stack).then(function () {
|
|
256
|
+
resolve({
|
|
257
|
+
failReport: "".concat(e.message, "\n").concat(stack),
|
|
258
|
+
skipReport: '',
|
|
259
|
+
passReport: '',
|
|
260
|
+
failed: true,
|
|
261
|
+
csv: '',
|
|
262
|
+
countReport: {
|
|
263
|
+
skip: 0,
|
|
264
|
+
pass: 0
|
|
265
|
+
}
|
|
266
|
+
});
|
|
248
267
|
});
|
|
249
268
|
});
|
|
250
269
|
});
|
|
251
270
|
}, targetPackage, options, new testUtils.TestContext(options.catchUnhandled, options.report));
|
|
252
|
-
case
|
|
271
|
+
case 15:
|
|
253
272
|
r = _context2.sent;
|
|
254
273
|
if (!options.record) {
|
|
255
|
-
_context2.next =
|
|
274
|
+
_context2.next = 19;
|
|
256
275
|
break;
|
|
257
276
|
}
|
|
258
|
-
_context2.next =
|
|
277
|
+
_context2.next = 19;
|
|
259
278
|
return recorder.stop();
|
|
260
|
-
case
|
|
261
|
-
_fs["default"].writeFileSync('./test-console-output.log', consoleLog);
|
|
262
|
-
case 16:
|
|
279
|
+
case 19:
|
|
263
280
|
return _context2.abrupt("return", r);
|
|
264
|
-
case
|
|
281
|
+
case 20:
|
|
265
282
|
case "end":
|
|
266
283
|
return _context2.stop();
|
|
267
284
|
}
|
|
@@ -3,6 +3,9 @@ const FuncGeneratorPlugin = require('datagrok-tools/plugins/func-gen-plugin');
|
|
|
3
3
|
const packageName = path.parse(require('./package.json').name).name.toLowerCase().replace(/-/g, '');
|
|
4
4
|
|
|
5
5
|
module.exports = {
|
|
6
|
+
cache: {
|
|
7
|
+
type: 'filesystem',
|
|
8
|
+
},
|
|
6
9
|
mode: 'development',
|
|
7
10
|
entry: {
|
|
8
11
|
test: {filename: 'package-test.js', library: {type: 'var', name: `${packageName}_test`}, import: './src/package-test.ts'},
|
|
@@ -13,7 +16,7 @@ module.exports = {
|
|
|
13
16
|
},
|
|
14
17
|
module: {
|
|
15
18
|
rules: [
|
|
16
|
-
{test: /\.tsx?$/, loader: 'ts-loader'},
|
|
19
|
+
{test: /\.tsx?$/, loader: 'ts-loader', options: {allowTsInNodeModules: true}},
|
|
17
20
|
],
|
|
18
21
|
},
|
|
19
22
|
plugins: [
|
|
@@ -65,7 +65,7 @@
|
|
|
65
65
|
"emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
|
|
66
66
|
|
|
67
67
|
/* Advanced Options */
|
|
68
|
-
"skipLibCheck":
|
|
68
|
+
"skipLibCheck": true, /* Skip type checking of declaration files. */
|
|
69
69
|
"forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */
|
|
70
70
|
}
|
|
71
71
|
}
|
|
@@ -2,7 +2,10 @@ const path = require('path');
|
|
|
2
2
|
const packageName = path.parse(require('./package.json').name).name.toLowerCase().replace(/-/g, '');
|
|
3
3
|
|
|
4
4
|
module.exports = {
|
|
5
|
-
|
|
5
|
+
cache: {
|
|
6
|
+
type: 'filesystem',
|
|
7
|
+
},
|
|
8
|
+
mode: 'production',
|
|
6
9
|
entry: {
|
|
7
10
|
package: './src/package.js',
|
|
8
11
|
},
|
package/package.json
CHANGED