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

Use Jest muti-project runner instead of a global config #72569

Closed
1 task
tylersmalley opened this issue Jul 21, 2020 · 3 comments · Fixed by #77894
Closed
1 task

Use Jest muti-project runner instead of a global config #72569

tylersmalley opened this issue Jul 21, 2020 · 3 comments · Fixed by #77894
Assignees
Labels
Feature:Development ReleaseStatus Item of high enough importance that it should be called out in release status meetings Team:Operations Team label for Operations Team

Comments

@tylersmalley
Copy link
Contributor

tylersmalley commented Jul 21, 2020

Jest tests are currently split into a few non-standard configurations injected through Node CLI scripts:

scripts/jest.js:

x-pack/scripts/jest.js:

There are a few reasons this is not ideal. Mainly, it has led to confusion to how Jest works for those otherwise familiar with it. In addition, we loose any benefits to tooling available which requires running Jest directly or referencing a configuration file.

Another issue we have is these configurations cover a vast amount of tests across large portions of the repository. Currently, the X-Pack Jest tests take an hour to complete on CI. This results in contributors temporarily using .only within their tests, or specifying --testPathPattern. This really starts to break down when you would like to run all the tests for your plugin as you have to rely on naming convention which might change plugin-to-plugin.

I propose we move to a having a base Jest configuration file which each plugin could extend, and a core jest.config.js file which defines a pattern for projects to cover those configuration files.

This will still allow for the entire suite of tests to be ran for CI while allowing contributors to run the unit tests of their plugin in isolation.

TODO:

  • See if we can reduce memory requirements for Jest tests
@tylersmalley tylersmalley added discuss Team:Operations Team label for Operations Team labels Jul 21, 2020
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-operations (Team:Operations)

@spalger
Copy link
Contributor

spalger commented Jul 21, 2020

I don't think --testPathPattern is a very good way to limit the tests that run. It's much more straightforward to copy a specific file path or use tab-completion to type a directory prefix and pass it as an unnamed arg to any jest CLI ie node scripts/jest src/core/server. Do we know if this will still work with jest projects?

I think ultimately it would be ideal to schedule the jest suites using CI tasks rather than jest projects, mostly so we can execute them on multiple workers. That said we don't have CI tasks yet but it shouldn't be long. Additionally though, CI tasks are defined in groovy and we probably need to make sure that we're validating that all jest configs are included in some manifest that the pipeline code can rely on being up to date...

@tylersmalley
Copy link
Contributor Author

  • Add validation to error on test files not covered by a jest configuration file and/or ran on CI.

@tylersmalley tylersmalley self-assigned this Jul 22, 2020
@tylersmalley tylersmalley changed the title [discuss] Use Jest muti-project runner instead of a global config Use Jest muti-project runner instead of a global config Aug 14, 2020
@jbudz jbudz mentioned this issue Aug 17, 2020
10 tasks
@stacey-gammon stacey-gammon added the ReleaseStatus Item of high enough importance that it should be called out in release status meetings label Sep 17, 2020
tylersmalley pushed a commit to tylersmalley/kibana that referenced this issue Nov 12, 2020
Jest tests are currently organized into main configuration files (src/dev/jest/config.js and x-pack/dev-tools/jest/create_jest_config.js). Both of these are similar, but very slightly due to  previously being in separate repositories. This change consolidates the scripts referenced in those configs and moves them to the `@kbn/test` project.

OSS contained an alias for `test_utils`. Those aliases have been removed in favor of importing these utilities from `@kbn/test/jest`

Blocker to elastic#72569

Signed-off-by: Tyler Smalley <tyler.smalley@elastic.co>
tylersmalley pushed a commit that referenced this issue Nov 13, 2020
Jest tests are currently organized into main configuration files (src/dev/jest/config.js and x-pack/dev-tools/jest/create_jest_config.js). Both of these are similar, but very slightly due to  previously being in separate repositories. This change consolidates the scripts referenced in those configs and moves them to the `@kbn/test` project.

OSS contained an alias for `test_utils`. Those aliases have been removed in favor of importing these utilities from `@kbn/test/jest`

Blocker to #72569

Signed-off-by: Tyler Smalley <tyler.smalley@elastic.co>
tylersmalley pushed a commit to tylersmalley/kibana that referenced this issue Nov 13, 2020
Jest tests are currently organized into main configuration files (src/dev/jest/config.js and x-pack/dev-tools/jest/create_jest_config.js). Both of these are similar, but very slightly due to  previously being in separate repositories. This change consolidates the scripts referenced in those configs and moves them to the `@kbn/test` project.

OSS contained an alias for `test_utils`. Those aliases have been removed in favor of importing these utilities from `@kbn/test/jest`

Blocker to elastic#72569

Signed-off-by: Tyler Smalley <tyler.smalley@elastic.co>
tylersmalley pushed a commit that referenced this issue Nov 13, 2020
Jest tests are currently organized into main configuration files (src/dev/jest/config.js and x-pack/dev-tools/jest/create_jest_config.js). Both of these are similar, but very slightly due to  previously being in separate repositories. This change consolidates the scripts referenced in those configs and moves them to the `@kbn/test` project.

OSS contained an alias for `test_utils`. Those aliases have been removed in favor of importing these utilities from `@kbn/test/jest`

Blocker to #72569

Signed-off-by: Tyler Smalley <tyler.smalley@elastic.co>

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature:Development ReleaseStatus Item of high enough importance that it should be called out in release status meetings Team:Operations Team label for Operations Team
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants