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

Scripts: Improve the way test files are discovered #17033

Merged
merged 2 commits into from
Aug 16, 2019

Conversation

gziolo
Copy link
Member

@gziolo gziolo commented Aug 14, 2019

Description

Supersedes / closes #16263 opened by @Shelob9.

Test files matching has changed to fix the overlap between two types of tests implemented with test-e2e and test-unit.

This is a breaking change as we no longer match test files with .spec.js extension in the @wordpress/jest-preset-default. This extension is now used exclusively with e2e tests. This way we won't have to override test matching rules when using both types of tests, see WordPress core as an example:
https://github.com/WordPress/wordpress-develop/blob/94f4dcd15a8d85782323e1a87d15b172eebbf88e/tests/e2e/jest.config.js#L9-L11

wp-scripts test-e2e

Jest will look for test files with any of the following popular naming conventions:

  • Files with .js (or .ts) suffix at any level of depth in spec folders.
  • Files with .spec.js (or .spec.ts) suffix.

wp-scripts test-unit

Jest will look for test files with any of the following popular naming conventions:

  • Files with .js (or .ts) suffix located at any level of depth in __tests__ folders.
  • Files with .js (or .ts) suffix directly located in test folders.
  • Files with .test.js (or .test.ts) suffix.

How has this been tested?

  • npm run test-e2e
  • npm run test-unit

@gziolo gziolo added [Type] Enhancement A suggestion for improvement. [Type] Developer Documentation Documentation for developers [Tool] WP Scripts /packages/scripts labels Aug 14, 2019
@gziolo gziolo requested a review from iandunn August 14, 2019 10:34
@gziolo gziolo self-assigned this Aug 14, 2019
@gziolo
Copy link
Member Author

gziolo commented Aug 14, 2019

This branch:

Test Suites: 323 passed, 323 total
Tests:       3176 passed, 3176 total
Snapshots:   171 passed, 171 total
Time:        163.798s
Ran all test suites.

Master:

Test Suites: 328 passed, 328 total
Tests:       3320 passed, 3320 total
Snapshots:   175 passed, 175 total
Time:        145.631s, estimated 146s

It looks like 5 test files are skipped for some reasons.

@gziolo
Copy link
Member Author

gziolo commented Aug 14, 2019

It should be fixed with e11195c. I had to rename all test files located in the test/integration folder.

@gziolo gziolo merged commit 0f3058e into master Aug 16, 2019
@gziolo gziolo deleted the update/test-discovery-improvements branch August 16, 2019 08:55
gziolo added a commit that referenced this pull request Aug 29, 2019
* Scripts: Improve the way test files are discovered

* Fix file matching patterns and file extensions for integration tests
gziolo added a commit that referenced this pull request Aug 29, 2019
* Scripts: Improve the way test files are discovered

* Fix file matching patterns and file extensions for integration tests
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] Developer Documentation Documentation for developers [Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants