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

Add additional e2e debugging option #21845

Merged
merged 14 commits into from
Apr 28, 2020
Merged

Conversation

ajlende
Copy link
Contributor

@ajlende ajlende commented Apr 23, 2020

Description

Getting node debugging working for e2e tests in #21631 was a bit more involved than just add the --inspect-brk flag to wp-scripts --inspect-brk test-e2e, so I'm moving the additional code and documentation changes to a new pull request.

  • Add PUPPETEER_DEVTOOLS environment (default false) to enable the devtools launch option.
  • Add --puppeteer-devtools option to test-e2e to automatically open the devtools.
  • Add test-e2e:debug npm script with --inspect-brk (from wp-scripts test-unit-js node debugging #21631) and --puppeteer-devtools.
  • Add documentation for how to debug e2e tests

How has this been tested?

  • Run test-e2e:debug with breakpoints set in:
    • test context (add debugger; within a test)
    • evaluate context (add await page.evaluate( () => { debugger; } ); within a test)
    • window context (add debugger; within any front-end code that would be run)

Types of changes

New feature

Checklist:

  • My code is tested.
  • My code follows the WordPress code style.
  • My code follows the accessibility standards.
  • My code has proper inline documentation.
  • I've included developer documentation if appropriate.
  • I've updated all React Native files affected by any refactorings/renamings in this PR.

@gziolo gziolo added [Tool] WP Scripts /packages/scripts [Type] Automated Testing Testing infrastructure changes impacting the execution of end-to-end (E2E) and/or unit tests. labels Apr 24, 2020
@gziolo
Copy link
Member

gziolo commented Apr 24, 2020

I'm about to merge #21653

Add documentation for how to debug e2e tests

I think that it largely overlaps with unit tests so maybe we just move the existing section to the shared Advanced information section and reference it from both commands. What do you think?

@gziolo gziolo added the [Status] In Progress Tracking issues with work in progress label Apr 26, 2020
@ajlende ajlende force-pushed the add/e2e-debugging branch from df156ed to 7afaadc Compare April 27, 2020 18:14
@ajlende
Copy link
Contributor Author

ajlende commented Apr 27, 2020

@gziolo I like the idea! I figured the docs should also include some info about node options so I added that section and put it under there instead. Do you think that makes sense as a place to put it? The Advanced information section wasn't shared between them (and having multiple headers named the same makes that a little confusing and impossible to link to).

@ajlende ajlende marked this pull request as ready for review April 27, 2020 19:18
@gziolo
Copy link
Member

gziolo commented Apr 27, 2020

I figured the docs should also include some info about node options so I added that section and put it under there instead.

Awesome, super helpful 🤩 Should it be moved before the list of scripts maybe or is it too advanced use case?

Do you think that makes sense as a place to put it?

Now we have two advanced sections, but only the second is linked. So maybe we consolidate it as one?

I plan to test it tomorrow and land

@ajlende ajlende removed the [Status] In Progress Tracking issues with work in progress label Apr 27, 2020
@ajlende ajlende requested a review from chrisvanpatten as a code owner April 27, 2020 20:21
@ajlende
Copy link
Contributor Author

ajlende commented Apr 27, 2020

Should it be moved before the list of scripts maybe or is it too advanced use case?

As a reader of the documentation I'm probably more likely to be looking for which scripts are available rather than seeing how to pass Node.js options to a script, so it makes sense to not put too much before the "available scripts" section.

Now we have two advanced sections, but only the second is linked. So maybe we consolidate it as one?

Now that you mention it, the word 'advanced' is probably a little overused in this document. Debugging unit tests shouldn't be considered "advanced"—it should be a technique that everyone feels comfortable using.

I think "Passing Node.js options" may be a little more clear. All the other options aside from --inspect would probably be considered advanced options, but the second "Advanced Usage" section refers strictly to overriding default configuration which is why I didn't put it under that header.

I plan to test it tomorrow and land

❤️

@gziolo
Copy link
Member

gziolo commented Apr 28, 2020

I like all the revisions applied since I last viewed 💯

@@ -397,6 +398,7 @@ This is how you execute those scripts using the presented setup:
* `npm run test-e2e -- --puppeteer-interactive` - runs all e2e tests interactively.
* `npm run test-e2e FILE_NAME -- --puppeteer-interactive ` - runs one test file interactively.
* `npm run test-e2e:watch -- --puppeteer-interactive` - runs all tests interactively and watch for changes.
* `npm run test-e2e:debug` - runs all tests interactively and enables [debugging tests](#debugging-e2e-tests).
Copy link
Member

Choose a reason for hiding this comment

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

great idea to cross-link here 👍

Copy link
Member

@gziolo gziolo left a comment

Choose a reason for hiding this comment

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

It works like a charm. I love it. This is how it looks in action. Well, I need to convert screen recording into GIF ...

Update: it looks like GIF is too big so I used Twitter:
https://video.twimg.com/ext_tw_video/1254999864280264704/pu/pl/aULuGCn7NkSB654x.m3u8

@gziolo gziolo merged commit 229f0b0 into WordPress:master Apr 28, 2020
@github-actions github-actions bot added this to the Gutenberg 8.1 milestone Apr 28, 2020
@ajlende ajlende deleted the add/e2e-debugging branch April 28, 2020 14:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Tool] WP Scripts /packages/scripts [Type] Automated Testing Testing infrastructure changes impacting the execution of end-to-end (E2E) and/or unit tests.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants