DEV: use REPORT_REQUESTS=1 to find all requests
We can use this to profile our pretender and ensure nothing is superfluous and nothing is missing
This commit is contained in:
parent
37bf38f801
commit
8a50ab45aa
|
@ -24,6 +24,8 @@ task "qunit:test", [:timeout, :qunit_path] do |_, args|
|
||||||
abort "Yarn is not installed. Download from https://yarnpkg.com/lang/en/docs/install/"
|
abort "Yarn is not installed. Download from https://yarnpkg.com/lang/en/docs/install/"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
report_requests = ENV['REPORT_REQUESTS'] == "1"
|
||||||
|
|
||||||
system("yarn install --dev")
|
system("yarn install --dev")
|
||||||
|
|
||||||
# ensure we have this port available
|
# ensure we have this port available
|
||||||
|
@ -63,10 +65,12 @@ task "qunit:test", [:timeout, :qunit_path] do |_, args|
|
||||||
options[arg] = ENV[arg.upcase] if ENV[arg.upcase].present?
|
options[arg] = ENV[arg.upcase] if ENV[arg.upcase].present?
|
||||||
end
|
end
|
||||||
|
|
||||||
if options.present?
|
if report_requests
|
||||||
cmd += "?#{options.to_query.gsub('+', '%20').gsub("&", '\\\&')}"
|
options['report_requests'] = '1'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
cmd += "?#{options.to_query.gsub('+', '%20').gsub("&", '\\\&')}"
|
||||||
|
|
||||||
if args[:timeout].present?
|
if args[:timeout].present?
|
||||||
cmd += " #{args[:timeout]}"
|
cmd += " #{args[:timeout]}"
|
||||||
end
|
end
|
||||||
|
|
|
@ -117,7 +117,17 @@ QUnit.testStart(function(ctx) {
|
||||||
return body;
|
return body;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (QUnit.config.logAllRequests) {
|
||||||
|
server.handledRequest = function(verb, path, request) {
|
||||||
|
console.log("REQ: " + verb + " " + path);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
server.unhandledRequest = function(verb, path) {
|
server.unhandledRequest = function(verb, path) {
|
||||||
|
if (QUnit.config.logAllRequests) {
|
||||||
|
console.log("REQ: " + verb + " " + path + " missing");
|
||||||
|
}
|
||||||
|
|
||||||
const error =
|
const error =
|
||||||
"Unhandled request in test environment: " + path + " (" + verb + ")";
|
"Unhandled request in test environment: " + path + " (" + verb + ")";
|
||||||
window.console.error(error);
|
window.console.error(error);
|
||||||
|
|
|
@ -112,6 +112,13 @@ async function runAllTests() {
|
||||||
await Runtime.evaluate({
|
await Runtime.evaluate({
|
||||||
expression: `(${qunit_script})()`
|
expression: `(${qunit_script})()`
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (args[0].indexOf("report_requests=1") > -1) {
|
||||||
|
await Runtime.evaluate({
|
||||||
|
expression: "QUnit.config.logAllRequests = true"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
const timeout = parseInt(args[1] || 300000, 10);
|
const timeout = parseInt(args[1] || 300000, 10);
|
||||||
var start = Date.now();
|
var start = Date.now();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue