1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | const path_1 = require("path");
|
4 | const q_1 = require("q");
|
5 | const selenium_webdriver_1 = require("selenium-webdriver");
|
6 | let STACK_SUBSTRINGS_TO_FILTER = [
|
7 | 'node_modules/jasmine/', 'node_modules/selenium-webdriver', 'at Module.', 'at Object.Module.',
|
8 | 'at Function.Module', '(timers.js:', 'jasminewd2/index.js', 'protractor/lib/'
|
9 | ];
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 | function filterStackTrace(text) {
|
17 | if (!text) {
|
18 | return text;
|
19 | }
|
20 | let lines = text.split(/\n/).filter((line) => {
|
21 | for (let filter of STACK_SUBSTRINGS_TO_FILTER) {
|
22 | if (line.indexOf(filter) !== -1) {
|
23 | return false;
|
24 | }
|
25 | }
|
26 | return true;
|
27 | });
|
28 | return lines.join('\n');
|
29 | }
|
30 | exports.filterStackTrace = filterStackTrace;
|
31 |
|
32 |
|
33 |
|
34 |
|
35 |
|
36 |
|
37 | function runFilenameOrFn_(configDir, filenameOrFn, args) {
|
38 | return q_1.Promise((resolvePromise) => {
|
39 | if (filenameOrFn && !(typeof filenameOrFn === 'string' || typeof filenameOrFn === 'function')) {
|
40 | throw new Error('filenameOrFn must be a string or function');
|
41 | }
|
42 | if (typeof filenameOrFn === 'string') {
|
43 | filenameOrFn = require(path_1.resolve(configDir, filenameOrFn));
|
44 | }
|
45 | if (typeof filenameOrFn === 'function') {
|
46 | let results = q_1.when(filenameOrFn.apply(null, args), null, (err) => {
|
47 | if (typeof err === 'string') {
|
48 | err = new Error(err);
|
49 | }
|
50 | else {
|
51 | err = err;
|
52 | if (!err.stack) {
|
53 | err.stack = new Error().stack;
|
54 | }
|
55 | }
|
56 | err.stack = exports.filterStackTrace(err.stack);
|
57 | throw err;
|
58 | });
|
59 | resolvePromise(results);
|
60 | }
|
61 | else {
|
62 | resolvePromise(undefined);
|
63 | }
|
64 | });
|
65 | }
|
66 | exports.runFilenameOrFn_ = runFilenameOrFn_;
|
67 |
|
68 |
|
69 |
|
70 |
|
71 |
|
72 |
|
73 | function joinTestLogs(log1, log2) {
|
74 | return {
|
75 | failedCount: log1.failedCount + log2.failedCount,
|
76 | specResults: (log1.specResults || []).concat(log2.specResults || [])
|
77 | };
|
78 | }
|
79 | exports.joinTestLogs = joinTestLogs;
|
80 |
|
81 |
|
82 |
|
83 |
|
84 |
|
85 |
|
86 |
|
87 |
|
88 |
|
89 | function falseIfMissing(error) {
|
90 | if ((error instanceof selenium_webdriver_1.error.NoSuchElementError) ||
|
91 | (error instanceof selenium_webdriver_1.error.StaleElementReferenceError)) {
|
92 | return false;
|
93 | }
|
94 | else {
|
95 | throw error;
|
96 | }
|
97 | }
|
98 | exports.falseIfMissing = falseIfMissing;
|
99 |
|
100 |
|
101 |
|
102 |
|
103 |
|
104 |
|
105 | function passBoolean(value) {
|
106 | return value;
|
107 | }
|
108 | exports.passBoolean = passBoolean;
|
109 |
|
\ | No newline at end of file |