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

RichText: add faster, separate e2e tests #17303

Closed
wants to merge 5 commits into from
Closed

Conversation

ellatrix
Copy link
Member

@ellatrix ellatrix commented Sep 2, 2019

Description

Split out from #17065. This is an attempt to move isolate e2e tests to the package they belong to, and to encourage adding more (faster) e2e tests.

RichText in particular is a component that could really benefit from a lot of e2e tests, as it cannot be fully tested otherwise. The fastest way would be to render it separately.

To do: add more tests and add to Travis. This is just a first try. Some current e2e tests can be moved later.

How has this been tested?

run npm run test-package-e2e packages/rich-text (needs improvement)

Screenshots

Types of changes

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.

@ellatrix ellatrix added [Type] Automated Testing Testing infrastructure changes impacting the execution of end-to-end (E2E) and/or unit tests. [Package] Rich text /packages/rich-text labels Sep 2, 2019
@ellatrix ellatrix requested a review from gziolo September 2, 2019 19:07
@ellatrix
Copy link
Member Author

ellatrix commented Sep 2, 2019

@gziolo I would super appreciate your feedback on all the package stuff, configs, and Travis. :D

'--config',
'bin/jest.config.js',
'--rootDir',
'packages/rich-text',
Copy link
Member Author

Choose a reason for hiding this comment

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

To do: run all tests in all packages.

"plugins": [
[ "@babel/plugin-transform-react-jsx", {
"pragma": "createElement",
"pragmaFrag": "Fragment"
Copy link
Member Author

Choose a reason for hiding this comment

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

Is this correct? I didn't see it in other Babel config files, but I got an error when it didn't include this.

@@ -34,6 +34,9 @@
"memize": "^1.0.5",
"rememo": "^3.0.0"
},
"devDependencies": {
"@babel/core": "7.5.5"
Copy link
Member Author

Choose a reason for hiding this comment

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

I'm not sure why this got added tbh. Also not sure about the lock file.

@ellatrix ellatrix requested a review from talldan as a code owner September 3, 2019 12:22
@@ -0,0 +1,9 @@
{
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure but it feels like this Babel config should be in the folder which generates code for the tests to avoid some accidental overrides when building packages or Gutenberg app.

Copy link
Member Author

Choose a reason for hiding this comment

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

I couldn't get it to work otherwise. Do you have any ideas why? I'm also struggling with getting it to work on Travis. :)

Copy link
Member

Choose a reason for hiding this comment

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

We had to do something similar for the playground:
https://github.com/WordPress/gutenberg/blob/master/playground/.babelrc

Parcel does some magic to the Babel config behind the scenes which forces us to add this Babel config 🤷‍♂ I guess we must have it unless they fix it in Parcel 2.x. We should unless ensure it doesn't get activated for the codebase when executed outside of Parcel.

}
);

bundler.on( 'buildEnd', () => {
Copy link
Member

Choose a reason for hiding this comment

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

You can also start a server using jest-puppeteer which might easier with parcel:
https://github.com/smooth-code/jest-puppeteer#start-a-server

Copy link
Member Author

Choose a reason for hiding this comment

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

It's not immediately obvious to me how this would work. We'd still need parcel, right?

Copy link
Member

Choose a reason for hiding this comment

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

yes, but it's less work to do it through config

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.

This is a great start. I still need to think about how to approach it but we definitely need to move some tests which don't depend on WordPress to some faster test suites which can run more often. I see at least 3 areas where we could use the same technique:

  • WordPress components
  • RichText
  • Block Editor (the current playground)

@ellatrix
Copy link
Member Author

ellatrix commented Sep 4, 2019

@gziolo Yes, we could tweak also tweak the playground for block editor testing (e.g. we don't need all the header and Google Fonts). This Pr in particular also adds more rich text e2e tests. I think in the future we should add even more tests. There are a lot of small rich text interactions that are currently not tested (since they didn't break before). So far our strategy has been to create e2e tests when something breaks, instead of writing a full spec.

@gziolo gziolo mentioned this pull request Sep 19, 2019
5 tasks
@ellatrix ellatrix added the [Status] In Progress Tracking issues with work in progress label Oct 8, 2019
@gziolo
Copy link
Member

gziolo commented Oct 31, 2019

Now that the playground will hopefully get integrated into Storybook with #18191. We probably could add a section for RichText as well. With that in place, isolated e2e tests shouldn't be that difficult to set up.

@etoledom etoledom removed their request for review November 7, 2019 06:39
@ellatrix
Copy link
Member Author

Closing this for now as it's outdated and I'm not planning to work on it for now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Package] Rich text /packages/rich-text [Status] In Progress Tracking issues with work in progress [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