Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🏗 [test-case-reporting] Implement PoC for e2e test reporter #29768

Merged
merged 13 commits into from
Aug 13, 2020

Conversation

Rafer45
Copy link
Contributor

@Rafer45 Rafer45 commented Aug 10, 2020

No description provided.

@google-cla google-cla bot added the cla: yes label Aug 10, 2020
@danielrozenberg danielrozenberg requested review from rcebulko and removed request for danielrozenberg August 10, 2020 20:51
build-system/tasks/mocha-ci-json-reporter.js Outdated Show resolved Hide resolved
build-system/tasks/mocha-ci-json-reporter.js Outdated Show resolved Hide resolved
build-system/tasks/mocha-ci-json-reporter.js Outdated Show resolved Hide resolved
build-system/tasks/mocha-ci-json-reporter.js Outdated Show resolved Hide resolved
runner.on(EVENT_RUN_END, async function () {
// Apparently we'll need to add a --no-exit flag when calling this
// to allow for the asynchronous reporter.
// See https://github.com/mochajs/mocha/issues/812
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we assert this flag is provided and complain if it is not, providing some explanation?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know if we can -- I don't know if using that flag is a good idea or not, I think I'd like a few more eyes on this.

Copy link
Collaborator

@estherkim estherkim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Does mocha support multiple reporters?

  2. If yes, have you looked at existing reporters before creating a custom one? Looks like there's https://mochajs.org/#json

You might have to update the existing e2e reporter. If you do, can you move it into the e2e folder?

@Rafer45
Copy link
Contributor Author

Rafer45 commented Aug 11, 2020

Have you looked at existing reporters before creating a custom one?

Yup, none of the reporters fit our needs -- the json reporter doesn't give a list of the suites of the tests, and it gives the data in a shape that the API endpoint doesn't use.

@Rafer45
Copy link
Contributor Author

Rafer45 commented Aug 11, 2020

Does mocha support multiple reporters?

I don't know, checking...

@Rafer45
Copy link
Contributor Author

Rafer45 commented Aug 11, 2020

Does mocha support multiple reporters?

Not natively -- there's a module that lets you do it (https://www.npmjs.com/package/mocha-multi), and apparently joining reporters together in one reporter isn't that complicated -- mochajs/mocha#2184 (comment)

I'm good with either option, slightly prefer the latter.

@rcebulko
Copy link
Contributor

Have you looked at existing reporters before creating a custom one?

Yup, none of the reporters fit our needs -- the json reporter doesn't give a list of the suites of the tests, and it gives the data in a shape that the API endpoint doesn't use.

The shape of the data can be handled on the API side by inspecting the incoming object, but if the test suite info isn't available that's a sufficient reason in my mind to hand-roll our own. Is that the case? Or is the suite data in some other format?

@Rafer45
Copy link
Contributor Author

Rafer45 commented Aug 11, 2020

Have you looked at existing reporters before creating a custom one?

Yup, none of the reporters fit our needs -- the json reporter doesn't give a list of the suites of the tests, and it gives the data in a shape that the API endpoint doesn't use.

The shape of the data can be handled on the API side by inspecting the incoming object, but if the test suite info isn't available that's a sufficient reason in my mind to hand-roll our own. Is that the case? Or is the suite data in some other format?

That is the case. The suite data is irrecoverable in the available reporters -- they use fullTitle() which joins the suite names using a space separator, and we can't get the suite info back from that, because most suites use spaces in their names.

@amp-owners-bot
Copy link

amp-owners-bot bot commented Aug 11, 2020

Hey @estherkim! These files were changed:

build-system/tasks/e2e/index.js
build-system/tasks/e2e/mocha-ci-reporter.js
build-system/tasks/e2e/mocha-custom-json-reporter.js
build-system/tasks/e2e/mocha-dots-reporter.js

function ciReporter(runner, options) {
Base.call(this, runner, options);
this._karmaMimicReporter = new KarmaMimicReporter(runner, options);
this._jsonReporter = new JsonReporter(runner, options);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'll probably want to skip the json reporter depending on whether a certain flag is set; I'm not familiar with this part of the codebase, what would be the cleanest way to do this?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suspect the same argv pattern you used for the gulp upload-report task (or whatever it was called) would work here

@Rafer45 Rafer45 requested a review from estherkim August 11, 2020 17:19
@Rafer45 Rafer45 requested a review from rcebulko August 13, 2020 15:49
Copy link
Contributor

@rcebulko rcebulko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the status of this PR currently?

@@ -163,4 +173,5 @@ e2e.flags = {
'Options are `puppeteer` or `selenium`. Default: `selenium`',
'headless': ' Runs the browser in headless mode',
'debug': ' Prints debugging information while running tests',
'report': ' Write test result report to a local file',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Didn't we use report-results or something elsewhere, or was this the same flag?

Copy link
Contributor Author

@Rafer45 Rafer45 Aug 13, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The flag for the tasks is report; the uploading gulp task is is test-report-upload -- see #29495 (comment)

@Rafer45 Rafer45 requested a review from rcebulko August 13, 2020 17:47
@Rafer45
Copy link
Contributor Author

Rafer45 commented Aug 13, 2020

What's the status of this PR currently?

I believe it's ready. This is currently blocking a PR to add the flag to the e2e task & another PR to run the upload task.

@rcebulko rcebulko merged commit e51a682 into ampproject:master Aug 13, 2020
@Rafer45 Rafer45 deleted the mocha-report branch August 13, 2020 20:12
ed-bird pushed a commit to ed-bird/amphtml that referenced this pull request Dec 10, 2020
…ct#29768)

* Implement PoC for e2e test reporter

* Improve wording in comment & err message

* Lint

* Refactor for clarity, fix fullTitle typo

* Move reporters to e2e folder, allowing imports to break for now

* Fix broken imports

* Rename mocha ci reporter, breaking imports

* Make ci reporter that joins together the reporters

* Rename KarmaMimicReporter in files

* Rename karma-mimic-reporter file

* Rename private _karmaMimicReporter

* Simplify event insertion

* Only write json report if report flag set
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants