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 section about integration testing to testing docs #49454

Merged
merged 2 commits into from
Apr 4, 2023

Conversation

glendaviesnz
Copy link
Contributor

What?

Adds documentation to cover new integration testing option added here.

Why?

So people willl know about it.

How?

Wrote it all by myself, no ChatGPT was harmed in the production of this text.

Testing Instructions

Read, and proof.

@glendaviesnz glendaviesnz added the [Type] Enhancement A suggestion for improvement. label Mar 29, 2023
Copy link
Member

@fabiankaegy fabiankaegy left a comment

Choose a reason for hiding this comment

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

Thanks for this addition. This is very valuable content :)

@@ -290,7 +290,30 @@ test('fires onChange when a new value is typed', async () => {
})
```

### Integration testing
Copy link
Contributor

Choose a reason for hiding this comment

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

The content is mostly about testing blocks, so I wonder if the title should be more specific

Suggested change
### Integration testing
### Integration testing for block UI

Or alternatively, keep this as the main header for the section, and move the block specific content under a subheader ('Testing a block's user interface').

There are other integration tests in the codebase (the full-content ones that check for block markup regressions), so it might be good to link to the docs for those from here (I believe there's a README in the folder).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Have changed the heading. The only other readme I could find around integration testing related to the native file testing.

Copy link
Contributor

Choose a reason for hiding this comment

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


Integration testing is defined as a type of testing where different parts are tested as a group. In this case, the parts that we want to test are the different components that are required to be rendered for a specific block or editor logic. In the end, they are very similar to unit tests as they are run with the same command using the Jest library. The main difference is that for the integration tests the blocks are run within a [`special instance of the block editor`](https://github.com/WordPress/gutenberg/blob/trunk/test/integration/helpers/integration-test-editor.js#L60).

The advantage of this approach is that the bulk of a blocks editor functionality, block toolbar and inspector panel interactions, etc. can be tested without having to fire up the full e2e test framework. This means the tests can run much faster and more reliably. It is recommended that as much of the editor functionality as possible should be covered with integration tests, with e2e tests only used for interactions that require a full browser environment, eg. file uploads, drag and drop, etc.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
The advantage of this approach is that the bulk of a blocks editor functionality, block toolbar and inspector panel interactions, etc. can be tested without having to fire up the full e2e test framework. This means the tests can run much faster and more reliably. It is recommended that as much of the editor functionality as possible should be covered with integration tests, with e2e tests only used for interactions that require a full browser environment, eg. file uploads, drag and drop, etc.
The advantage of this approach is that the bulk of a block editor's functionality (block toolbar and inspector panel interactions, etc.) can be tested without having to fire up the full e2e test framework. This means the tests can run much faster and more reliably. It is recommended that as much of the editor functionality as possible should be covered with integration tests, with e2e tests only used for interactions that require a full browser environment, eg. file uploads, drag and drop, etc.

Small typo here.


It is recommended that as much of the editor functionality as possible should be covered with integration tests

The "It is recommended" part might be a bit strong out of the blocks, considering the approach hasn't been very widely tested yet. 🤔

Maybe the language can be softened, but still propose writing integration tests first.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed the wording to "It is suggested that as much of a block's UI functionality as possible is covered with integration tests, with e2e tests used for interactions that require a full browser environment, eg. file uploads, drag and drop, etc." - is that softened enough do you think?

Copy link
Contributor

Choose a reason for hiding this comment

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

Sounds good, thanks for updating it!

Copy link
Member

@aristath aristath left a comment

Choose a reason for hiding this comment

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

Awesome, thank you!

@talldan talldan merged commit e684618 into trunk Apr 4, 2023
@talldan talldan deleted the add/integration-test-docs branch April 4, 2023 03:38
@github-actions github-actions bot added this to the Gutenberg 15.6 milestone Apr 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Type] Developer Documentation Documentation for developers [Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants