Scripts: Improve the way test files are discovered #17033
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
andtest-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:
.js
(or.ts
) suffix at any level of depth inspec
folders..spec.js
(or.spec.ts
) suffix.wp-scripts test-unit
Jest will look for test files with any of the following popular naming conventions:
.js
(or.ts
) suffix located at any level of depth in__tests__
folders..js
(or.ts
) suffix directly located intest
folders..test.js
(or.test.ts
) suffix.How has this been tested?
npm run test-e2e
npm run test-unit