2020-10-25 23:40:51 +09:00
|
|
|
const TestReporter = function (browser) {
|
2022-03-10 20:55:08 +09:00
|
|
|
function send(action, json) {
|
|
|
|
return new Promise(resolve => {
|
|
|
|
json.browser = browser;
|
|
|
|
|
|
|
|
fetch(action, {
|
|
|
|
method: "POST",
|
|
|
|
headers: {
|
|
|
|
"Content-Type": "application/json",
|
|
|
|
},
|
|
|
|
body: JSON.stringify(json),
|
|
|
|
})
|
|
|
|
.then(response => {
|
|
|
|
// Retry until successful.
|
|
|
|
if (!response.ok || response.status !== 200) {
|
|
|
|
throw new Error(response.statusText);
|
2014-04-12 03:02:41 +09:00
|
|
|
}
|
2022-03-10 20:55:08 +09:00
|
|
|
resolve();
|
|
|
|
})
|
|
|
|
.catch(reason => {
|
|
|
|
console.warn(`TestReporter - send failed (${action}): ${reason}`);
|
|
|
|
resolve();
|
|
|
|
|
|
|
|
send(action, json);
|
|
|
|
});
|
|
|
|
});
|
2012-04-20 04:32:24 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
function sendInfo(message) {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
send("/info", { message });
|
2012-04-20 04:32:24 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
function sendResult(status, description, error) {
|
2020-10-25 23:40:51 +09:00
|
|
|
const message = {
|
2017-04-28 20:40:47 +09:00
|
|
|
status,
|
|
|
|
description,
|
2012-04-20 04:32:24 +09:00
|
|
|
};
|
2022-11-28 01:16:46 +09:00
|
|
|
if (error !== undefined) {
|
2020-04-17 19:06:27 +09:00
|
|
|
message.error = error;
|
2014-03-14 23:46:23 +09:00
|
|
|
}
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
send("/submit_task_results", message);
|
2012-04-20 04:32:24 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
function sendQuitRequest() {
|
2020-04-18 23:12:50 +09:00
|
|
|
send(`/tellMeToQuit?browser=${escape(browser)}`, {});
|
2012-04-20 04:32:24 +09:00
|
|
|
}
|
|
|
|
|
2020-04-14 19:28:14 +09:00
|
|
|
this.now = function () {
|
2021-02-12 07:00:42 +09:00
|
|
|
return Date.now();
|
2012-04-20 04:32:24 +09:00
|
|
|
};
|
|
|
|
|
2020-04-14 19:28:14 +09:00
|
|
|
this.jasmineStarted = function (suiteInfo) {
|
2012-04-20 04:32:24 +09:00
|
|
|
this.runnerStartTime = this.now();
|
2020-08-02 04:06:42 +09:00
|
|
|
|
|
|
|
const total = suiteInfo.totalSpecsDefined;
|
|
|
|
const seed = suiteInfo.order.seed;
|
|
|
|
sendInfo(`Started ${total} tests for ${browser} with seed ${seed}.`);
|
2012-04-20 04:32:24 +09:00
|
|
|
};
|
|
|
|
|
2020-08-02 03:57:51 +09:00
|
|
|
this.suiteStarted = function (result) {
|
|
|
|
// Normally suite starts don't have to be reported because the individual
|
|
|
|
// specs inside them are reported, but it can happen that the suite cannot
|
|
|
|
// start, for instance due to an uncaught exception in `beforeEach`. This
|
|
|
|
// is problematic because the specs inside the suite will never be found
|
|
|
|
// and run, so if we don't report the suite start failure here it would be
|
|
|
|
// ignored silently, leading to passing tests even though some did not run.
|
|
|
|
if (result.failedExpectations.length > 0) {
|
|
|
|
let failedMessages = "";
|
|
|
|
for (const item of result.failedExpectations) {
|
|
|
|
failedMessages += `${item.message} `;
|
|
|
|
}
|
|
|
|
sendResult("TEST-UNEXPECTED-FAIL", result.description, failedMessages);
|
|
|
|
}
|
|
|
|
};
|
2012-04-20 04:32:24 +09:00
|
|
|
|
2020-04-14 19:28:14 +09:00
|
|
|
this.specStarted = function (result) {};
|
2016-03-29 23:34:13 +09:00
|
|
|
|
2020-04-14 19:28:14 +09:00
|
|
|
this.specDone = function (result) {
|
2016-03-29 23:34:13 +09:00
|
|
|
if (result.failedExpectations.length === 0) {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
sendResult("TEST-PASSED", result.description);
|
2012-04-20 04:32:24 +09:00
|
|
|
} else {
|
2020-08-02 03:49:24 +09:00
|
|
|
let failedMessages = "";
|
|
|
|
for (const item of result.failedExpectations) {
|
|
|
|
failedMessages += `${item.message} `;
|
2014-03-14 23:46:23 +09:00
|
|
|
}
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
sendResult("TEST-UNEXPECTED-FAIL", result.description, failedMessages);
|
2012-04-20 04:32:24 +09:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2020-04-14 19:28:14 +09:00
|
|
|
this.suiteDone = function (result) {};
|
2012-04-20 04:32:24 +09:00
|
|
|
|
2020-04-14 19:28:14 +09:00
|
|
|
this.jasmineDone = function () {
|
2020-08-02 03:49:24 +09:00
|
|
|
// Give the test runner some time process any queued requests.
|
2012-04-20 06:19:08 +09:00
|
|
|
setTimeout(sendQuitRequest, 500);
|
2012-04-20 04:32:24 +09:00
|
|
|
};
|
|
|
|
};
|
2020-10-27 19:15:06 +09:00
|
|
|
|
|
|
|
export { TestReporter };
|