phantomas 2.0.0 → 2.4.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/Dockerfile +39 -25
- package/README.md +20 -8
- package/bin/phantomas.js +9 -164
- package/bin/program.js +198 -0
- package/bin/utils.js +16 -0
- package/core/modules/navigationTiming/scope.js +7 -1
- package/core/modules/requestsMonitor/requestsMonitor.js +30 -13
- package/core/scope.js +2 -1
- package/extensions/cookies/cookies.js +1 -2
- package/extensions/filmStrip/filmStrip.js +1 -1
- package/extensions/pageSource/pageSource.js +2 -0
- package/extensions/pageStorage/pageStorage.js +82 -0
- package/extensions/screenshot/screenshot.js +27 -9
- package/extensions/scroll/scroll.js +3 -1
- package/extensions/userAgent/userAgent.js +55 -0
- package/extensions/viewport/viewport.js +1 -1
- package/extensions/waitForSelector/waitForSelector.js +0 -1
- package/hooks/build +3 -0
- package/lib/browser.js +81 -33
- package/lib/index.js +18 -9
- package/lib/loader.js +3 -4
- package/lib/metadata/metadata.json +180 -29
- package/modules/ajaxRequests/scope.js +1 -1
- package/modules/analyzeCss/analyzeCss.js +79 -76
- package/modules/analyzeCss/scope.js +1 -1
- package/modules/blockDomains/blockDomains.js +21 -21
- package/modules/cacheHits/cacheHits.js +6 -3
- package/modules/cpuTasks/cpuTasks.js +22 -0
- package/modules/documentHeight/scope.js +1 -1
- package/modules/domComplexity/scope.js +1 -1
- package/modules/domHiddenContent/scope.js +1 -1
- package/modules/domMutations/scope.js +1 -1
- package/modules/domQueries/domQueries.js +16 -19
- package/modules/domQueries/scope.js +1 -1
- package/modules/domains/domains.js +1 -1
- package/modules/events/scope.js +2 -1
- package/modules/globalVariables/scope.js +1 -1
- package/modules/jQuery/scope.js +1 -1
- package/modules/javaScriptBottlenecks/scope.js +1 -1
- package/modules/lazyLoadableImages/scope.js +2 -2
- package/modules/localStorage/scope.js +1 -1
- package/modules/protocols/protocols.js +101 -0
- package/modules/requestsStats/requestsStats.js +1 -1
- package/modules/staticAssets/staticAssets.js +2 -1
- package/modules/windowPerformance/windowPerformance.js +1 -0
- package/package.json +31 -20
- package/lib/fast-stats.js +0 -634
- package/lib/metadata/generate.js +0 -283
- package/lib/metadata/make_docs.js +0 -185
- package/reporters/csv.js +0 -54
- package/reporters/plain.js +0 -173
- package/reporters/statsd.js +0 -82
- package/reporters/tap.js +0 -71
- package/reporters/teamcity.js +0 -73
package/reporters/statsd.js
DELETED
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Results formatter for --format=statsd
|
|
3
|
-
*
|
|
4
|
-
* --reporter statsd
|
|
5
|
-
* --statsd-host localhost
|
|
6
|
-
* --statsd-port 8125
|
|
7
|
-
* --statsd-prefix "myapp.frontPage."
|
|
8
|
-
*
|
|
9
|
-
* Options:
|
|
10
|
-
* <host>:<port>:<prefix>
|
|
11
|
-
*
|
|
12
|
-
* @see https://github.com/sivy/node-statsd
|
|
13
|
-
*/
|
|
14
|
-
"use strict";
|
|
15
|
-
|
|
16
|
-
var StatsD = require("node-statsd").StatsD;
|
|
17
|
-
|
|
18
|
-
module.exports = function (results, reporterOptions, options) {
|
|
19
|
-
var debug = require("debug")("phantomas:reporter:statsd"),
|
|
20
|
-
params;
|
|
21
|
-
|
|
22
|
-
// -R statsd:<host>:<port>:<prefix>
|
|
23
|
-
if (reporterOptions.length > 0) {
|
|
24
|
-
options["statsd-host"] = reporterOptions[0];
|
|
25
|
-
options["statsd-port"] = reporterOptions[1];
|
|
26
|
-
options["statsd-prefix"] = reporterOptions[2];
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
params = {
|
|
30
|
-
host: options["statsd-host"] || "localhost",
|
|
31
|
-
port: options["statsd-port"] || 8125,
|
|
32
|
-
prefix:
|
|
33
|
-
typeof options["statsd-prefix"] === "undefined"
|
|
34
|
-
? "phantomas."
|
|
35
|
-
: options["statsd-prefix"],
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
debug("Patameters: %j", params);
|
|
39
|
-
|
|
40
|
-
// public API
|
|
41
|
-
return {
|
|
42
|
-
render: function (done) {
|
|
43
|
-
var client = new StatsD(params),
|
|
44
|
-
metrics = results.getMetricsNames(),
|
|
45
|
-
remaining = metrics.length,
|
|
46
|
-
bytesSent = 0;
|
|
47
|
-
|
|
48
|
-
client.socket.on("error", function (error) {
|
|
49
|
-
debug("Error in socket: %s", error);
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
metrics.forEach(function (metric) {
|
|
53
|
-
var value = results.getMetric(metric);
|
|
54
|
-
|
|
55
|
-
if (isNaN(parseFloat(value))) {
|
|
56
|
-
debug(
|
|
57
|
-
'Not sending %s as "%s" is not a numeric metric',
|
|
58
|
-
metric,
|
|
59
|
-
value
|
|
60
|
-
);
|
|
61
|
-
remaining--;
|
|
62
|
-
} else {
|
|
63
|
-
//debug('Sending %s = %s...', metric, value);
|
|
64
|
-
|
|
65
|
-
client.gauge(metric, value, function (err, bytes) {
|
|
66
|
-
if (err) {
|
|
67
|
-
debug("Error: %s", err);
|
|
68
|
-
} else {
|
|
69
|
-
bytesSent += bytes;
|
|
70
|
-
remaining--;
|
|
71
|
-
|
|
72
|
-
if (remaining === 0) {
|
|
73
|
-
debug("All metrics sent (%d bytes)", bytesSent);
|
|
74
|
-
done();
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
});
|
|
78
|
-
}
|
|
79
|
-
});
|
|
80
|
-
},
|
|
81
|
-
};
|
|
82
|
-
};
|
package/reporters/tap.js
DELETED
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Results formatter for --format=tap
|
|
3
|
-
*
|
|
4
|
-
* Options:
|
|
5
|
-
* no-skip - don't print out metrics that were skipped
|
|
6
|
-
*
|
|
7
|
-
* @see http://podwiki.hexten.net/TAP/TAP.html?page=TAP
|
|
8
|
-
* @see https://github.com/macbre/tap-producer
|
|
9
|
-
*/
|
|
10
|
-
"use strict";
|
|
11
|
-
|
|
12
|
-
var TapProducer = require("tap-producer-macbre");
|
|
13
|
-
|
|
14
|
-
module.exports = function (results, reporterOptions) {
|
|
15
|
-
// public API
|
|
16
|
-
return {
|
|
17
|
-
render: function () {
|
|
18
|
-
var metrics = results.getMetricsNames(),
|
|
19
|
-
noSkip = reporterOptions["no-skip"] === true,
|
|
20
|
-
res = [];
|
|
21
|
-
|
|
22
|
-
res.push(
|
|
23
|
-
results.getGenerator() + " results for <" + results.getUrl() + ">"
|
|
24
|
-
);
|
|
25
|
-
|
|
26
|
-
// metrics
|
|
27
|
-
metrics.forEach(function (metric) {
|
|
28
|
-
var entry = {
|
|
29
|
-
ok: true,
|
|
30
|
-
name: metric,
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
// check asserts
|
|
34
|
-
if (results.hasAssertion(metric)) {
|
|
35
|
-
if (!results.assert(metric)) {
|
|
36
|
-
entry.ok = false;
|
|
37
|
-
|
|
38
|
-
entry.expected = results.getAssertion(metric);
|
|
39
|
-
entry.actual = results.getMetric(metric);
|
|
40
|
-
} else {
|
|
41
|
-
entry.value = results.getMetric(metric);
|
|
42
|
-
}
|
|
43
|
-
} else {
|
|
44
|
-
// mark metrics with no assertions as skipped
|
|
45
|
-
entry.skip = true;
|
|
46
|
-
entry.value = results.getMetric(metric);
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
// add offenders
|
|
50
|
-
var offenders = results.getOffenders(metric);
|
|
51
|
-
if (offenders) {
|
|
52
|
-
// properly encode YAML to make it work in Jenkins
|
|
53
|
-
offenders = offenders.map(function (entry) {
|
|
54
|
-
return '"' + entry.replace(/"/g, "") + '"';
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
entry.offenders = offenders;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
// -R tap:no-skip
|
|
61
|
-
if (noSkip && entry.skip) {
|
|
62
|
-
return;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
res.push(entry);
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
return TapProducer.encode(res, true /* emit yanlish data in TAP */);
|
|
69
|
-
},
|
|
70
|
-
};
|
|
71
|
-
};
|
package/reporters/teamcity.js
DELETED
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Results formatter for -R teamcity
|
|
3
|
-
*
|
|
4
|
-
* Options:
|
|
5
|
-
* prefix-url - prefix the url to the metric key
|
|
6
|
-
* postfix-url - postfix the url to the metric key
|
|
7
|
-
* prefix - explicit prefix to the metric key
|
|
8
|
-
* postfix - explicit postfix to the metric key
|
|
9
|
-
*/
|
|
10
|
-
"use strict";
|
|
11
|
-
|
|
12
|
-
module.exports = function (results, reporterOptions) {
|
|
13
|
-
var isMultiple = Array.isArray(results);
|
|
14
|
-
|
|
15
|
-
function createTeamCityMessage(metric, value) {
|
|
16
|
-
var key = metric;
|
|
17
|
-
if (reporterOptions.prefix) key = reporterOptions.prefix + "." + key;
|
|
18
|
-
if (reporterOptions.postfix) key = key + "." + reporterOptions.postfix;
|
|
19
|
-
if (reporterOptions["prefix-url"] === true)
|
|
20
|
-
key = results.getUrl() + "." + key;
|
|
21
|
-
if (reporterOptions["postfix-url"] === true)
|
|
22
|
-
key = key + "." + results.getUrl();
|
|
23
|
-
|
|
24
|
-
key = key.replace(/'/g, "'");
|
|
25
|
-
|
|
26
|
-
return (
|
|
27
|
-
"##teamcity[buildStatisticValue key='" + key + "' value='" + value + "']"
|
|
28
|
-
);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
function renderSingleResult() {
|
|
32
|
-
var metrics = results.getMetricsNames(),
|
|
33
|
-
messages = [];
|
|
34
|
-
|
|
35
|
-
metrics.forEach(function (metric) {
|
|
36
|
-
var value = results.getMetric(metric);
|
|
37
|
-
messages.push(createTeamCityMessage(metric, value));
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
return messages.join("\n") + "\n";
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
function renderAvgResults() {
|
|
44
|
-
var transposed = {},
|
|
45
|
-
messages = [];
|
|
46
|
-
|
|
47
|
-
results.forEach(function (run) {
|
|
48
|
-
var metrics = run.getMetricsNames();
|
|
49
|
-
metrics.forEach(function (metric) {
|
|
50
|
-
if (!transposed[metric]) transposed[metric] = [];
|
|
51
|
-
transposed[metric].push(run.getMetric(metric));
|
|
52
|
-
});
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
for (var metric in transposed) {
|
|
56
|
-
var value = transposed[metric].reduce(function (a, b) {
|
|
57
|
-
return a + b;
|
|
58
|
-
}, 0);
|
|
59
|
-
value = value / transposed[metric].length;
|
|
60
|
-
messages.push(createTeamCityMessage(metric, value));
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
return messages.join("\n") + "\n";
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
return {
|
|
67
|
-
handlesMultiple: true,
|
|
68
|
-
render: function () {
|
|
69
|
-
if (isMultiple) return renderAvgResults();
|
|
70
|
-
else return renderSingleResult();
|
|
71
|
-
},
|
|
72
|
-
};
|
|
73
|
-
};
|