-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
docs: Add test file location -> test runner table #34986
Changes from 3 commits
3b9ad4c
0b17e3e
5cdcdf4
4b6074c
bf89d8d
82c54af
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -335,11 +335,30 @@ Mocha tests are contained in `__tests__` directories. | |
#### Jest | ||
Jest tests are stored in the same directory as source code files with the `.test.js` suffix. | ||
|
||
### Running Jest Unit Tests | ||
|
||
```bash | ||
node scripts/jest | ||
``` | ||
### Running Kibana tests | ||
|
||
The following table outlines possible test file locations and how to invoke them: | ||
|
||
| Test location | Runner command (working directory is kibana root) | | ||
| ------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------- | | ||
| `src/**/*.test.js`<br>`src/**/*.test.ts` | `yarn test:jest -t regexp [test path]` | | ||
| `src/**/__tests__/**/*.js`<br>`packages/kbn-datemath/test/**/*.js`<br>`packages/kbn-dev-utils/src/**/__tests__/**/*.js`<br>`tasks/**/__tests__/**/*.js` | `node scripts/mocha --grep=regexp [test path]` | | ||
| `**/integration_tests/**/*.test.js` | `node scripts/jest_integration -t regexp [test path]` | | ||
| `test/*integration/**/config.js`<br>`test/*functional/**/config.js`<br>`x-pack/test/*integration/**/config.js`<br>`x-pack/test/*functional/config.js` | `node scripts/functional_tests --config test/[directory]/config.js --grep=regexp` | | ||
| `x-pack/**/*.test.js`<br>`x-pack/**/*.test.ts` | `cd x-pack && yarn test:jest -t regexp [test path]` | | ||
| `x-pack/test/*integration/**/config.ts` | ?? | | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think the value for this row can be:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We probably want to keep the X-Pack specific docs here: https://github.com/elastic/kibana/blob/master/x-pack/README.md until we unify all of the tooling. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. SGTM. It would be nice to cross-link between those two docs, in that case. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The problem I ran into here was how do I run functional tests if the config file is written as a typescript file as opposed to a javascript file? |
||
|
||
Test runner arguments: | ||
- Where applicable, the optional arguments `-t=regexp` or `--grep=regexp` will only run tests or test suites whose descriptions matches the regular expression. | ||
- `[test path]` is the relative path to the test file. | ||
|
||
Examples: | ||
- Run the entire elasticsearch_service test suite with yarn: | ||
`yarn test:jest src/core/server/elasticsearch/elasticsearch_service.test.ts` | ||
- Run the jest test case whose description matches 'stops both admin and data clients': | ||
`yarn test:jest -t 'stops both admin and data clients' src/core/server/elasticsearch/elasticsearch_service.test.ts` | ||
- Run the x-pack api integration test case whose description matches the given string: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We can remove this X-Pack example since you included in the X-Pack docs |
||
`node scripts/functional_tests --config x-pack/test/api_integration/config.js --grep='apis Monitoring Beats list with restarted beat instance should load multiple clusters'` | ||
|
||
### Debugging Unit Tests | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how about adding a column at the beginning of the table called “Type”? Values for each row could be “Jest”, “Mocha”, “Jest + API”, “Functional”, “Jest (X-Pack”), and “Integration (X-Pack)”
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think having the rows be by type would help simplify this quite a bit. They would then correspond to the locations they cover and the command to execute.