[8.x] [Fleet] Fix Jest dev config (#207211) (#207376)

# Backport

This will backport the following commits from `main` to `8.x`:
- [[Fleet] Fix Jest dev config
(#207211)](https://github.com/elastic/kibana/pull/207211)

<!--- Backport version: 9.4.3 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Jill
Guyonnet","email":"jill.guyonnet@elastic.co"},"sourceCommit":{"committedDate":"2025-01-21T14:53:11Z","message":"[Fleet]
Fix Jest dev config (#207211)\n\n## Summary\r\n\r\nFollowup to
https://github.com/elastic/kibana/pull/205798.\r\n\r\nThere was a typo
in the root Jest config for running unit tests locally.\r\nAlso fixing
reference in README.\r\n\r\n### To test\r\n\r\n`yarn jest
--config\r\nx-pack/platform/plugins/shared/fleet/jest.config.dev.js`
should run\r\nFleet unit tests
correctly.","sha":"36332b1bd014c5f09af0cfedcf1f8905f781c9b0","branchLabelMapping":{"^v9.0.0$":"main","^v8.18.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","Team:Fleet","v9.0.0","backport:prev-minor"],"title":"[Fleet]
Fix Jest dev
config","number":207211,"url":"https://github.com/elastic/kibana/pull/207211","mergeCommit":{"message":"[Fleet]
Fix Jest dev config (#207211)\n\n## Summary\r\n\r\nFollowup to
https://github.com/elastic/kibana/pull/205798.\r\n\r\nThere was a typo
in the root Jest config for running unit tests locally.\r\nAlso fixing
reference in README.\r\n\r\n### To test\r\n\r\n`yarn jest
--config\r\nx-pack/platform/plugins/shared/fleet/jest.config.dev.js`
should run\r\nFleet unit tests
correctly.","sha":"36332b1bd014c5f09af0cfedcf1f8905f781c9b0"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/207211","number":207211,"mergeCommit":{"message":"[Fleet]
Fix Jest dev config (#207211)\n\n## Summary\r\n\r\nFollowup to
https://github.com/elastic/kibana/pull/205798.\r\n\r\nThere was a typo
in the root Jest config for running unit tests locally.\r\nAlso fixing
reference in README.\r\n\r\n### To test\r\n\r\n`yarn jest
--config\r\nx-pack/platform/plugins/shared/fleet/jest.config.dev.js`
should run\r\nFleet unit tests
correctly.","sha":"36332b1bd014c5f09af0cfedcf1f8905f781c9b0"}}]}]
BACKPORT-->

Co-authored-by: Jill Guyonnet <jill.guyonnet@elastic.co>
This commit is contained in:
Kibana Machine 2025-01-22 03:33:47 +11:00 committed by GitHub
parent 022cc3dbb6
commit 3abc1783a6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 11 additions and 6 deletions

View file

@ -129,13 +129,18 @@ Note: if you need to do simultaneous Kibana and Fleet Server development, refer
Kibana primarily uses Jest for unit testing. Each plugin or package defines a `jest.config.js` that extends a preset provided by the `@kbn/test` package. Unless you intend to run all unit tests within the project, you should provide the Jest configuration for Fleet. The following command runs all Fleet unit tests:
```sh
yarn jest --config x-pack/platform/plugins/shared/fleet/jest.config.js
yarn jest --config x-pack/platform/plugins/shared/fleet/jest.config.dev.js
```
You can also run a specific test by passing the filepath as an argument, e.g.:
```sh
yarn jest --config x-pack/platform/plugins/shared/fleet/jest.config.js x-pack/platform/plugins/shared/fleet/common/services/validate_package_policy.test.ts
yarn jest --config x-pack/platform/plugins/shared/fleet/jest.config.dev.js x-pack/platform/plugins/shared/fleet/common/services/validate_package_policy.test.ts
```
Or alternatively:
```sh
yarn test:jest x-pack/platform/plugins/shared/fleet/common/services/validate_package_policy.test.ts
```
#### API integration tests (stateful)

View file

@ -6,12 +6,12 @@
*/
module.exports = {
preset: '@kbn/test/jest',
preset: '@kbn/test',
rootDir: '../../../../..',
roots: ['<rootDir>/x-pack/platform/plugins/shared/fleet'],
projects: [
'<rootDir>/x-pack/platform/plugins/shared/fleet/common/*/jest.config.js',
'<rootDir>/x-pack/platform/plugins/shared/fleet/server/*/jest.config.js',
'<rootDir>/x-pack/platform/plugins/shared/fleet/public/*/jest.config.js',
'<rootDir>/x-pack/platform/plugins/shared/fleet/common/jest.config.js',
'<rootDir>/x-pack/platform/plugins/shared/fleet/server/jest.config.js',
'<rootDir>/x-pack/platform/plugins/shared/fleet/public/jest.config.js',
],
};