docs: Add test file location -> test runner table#34986
docs: Add test file location -> test runner table#34986rudolf merged 6 commits intoelastic:masterfrom
Conversation
|
Pinging @elastic/kibana-operations |
💚 Build Succeeded |
💚 Build Succeeded |
💚 Build Succeeded |
CONTRIBUTING.md
Outdated
| | `**/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.
I think the value for this row can be:
cd x-pack && node scripts/functional_tests_server.js
node scripts/functional_test_runner.js --config x-pack/test/api_integration/config.js --grep "Some string from the test case name"
There was a problem hiding this comment.
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.
SGTM. It would be nice to cross-link between those two docs, in that case.
There was a problem hiding this comment.
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?
CONTRIBUTING.md
Outdated
|
|
||
| The following table outlines possible test file locations and how to invoke them: | ||
|
|
||
| | Test location | Runner command (working directory is kibana root) | |
There was a problem hiding this comment.
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.
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.
|
@cjcenizal @tylersmalley I played with grouping tests by "type" and splitting x-pack tests out of this file (just pasting as a comment, didn't push any code yet). It felt weird to group integration and functional tests under the "functional" type, wouldn't it be two distinct types "functional" and "integration"?
But then I wondered if it would be simpler to group it under the test runner, in which case both functional and integration tests uses the "functional test runner":
|
💚 Build Succeeded |
💚 Build Succeeded |
tylersmalley
left a comment
There was a problem hiding this comment.
Just a couple small changes - thanks for your work on this!
CONTRIBUTING.md
Outdated
|
|
||
| | Test runner | Test location | Runner command (working directory is kibana root) | | ||
| | ----------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------- | | ||
| | Jest | `src/**/*.test.js`<br>`src/**/*.test.ts` | `yarn test:jest -t regexp [test path]` | |
There was a problem hiding this comment.
Can we update this to node scripts/jest
CONTRIBUTING.md
Outdated
| | Jest | `src/**/*.test.js`<br>`src/**/*.test.ts` | `yarn test:jest -t regexp [test path]` | | ||
| | Jest (integration) | `**/integration_tests/**/*.test.js` | `node scripts/jest_integration -t regexp [test path]` | | ||
| | Mocha | `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]` | | ||
| | Functional | `test/*integration/**/config.js`<br>`test/*functional/**/config.js` | `node scripts/functional_tests --config test/[directory]/config.js --grep=regexp` | |
There was a problem hiding this comment.
While this will run the tests, I am concerned folks will use this for debugging which takes a large amount of time to start Kibana/ES each time. We have details here regarding how to run for development: https://www.elastic.co/guide/en/kibana/current/development-functional-tests.html#_running_functional_tests
I would suggest we update this command to outline the two:
node scripts/functional_tests_server --config test/[directory]/config.jsnode scripts/functional_test_runner --config test/[directory]/config.js --grep=regexp
x-pack/README.md
Outdated
| ## Running specific tests | ||
| | Test runner | Test location | Runner command (working directory is kibana/x-pack) | | ||
| | ------------ | ----------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------- | | ||
| | Jest | `x-pack/**/*.test.js`<br>`x-pack/**/*.test.ts` | `cd x-pack && yarn test:jest -t regexp [test path]` | |
There was a problem hiding this comment.
Same feedback as for Kibana - use scripts/jest and outline the separate server/runner functional test scripts.
CONTRIBUTING.md
Outdated
| `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.
We can remove this X-Pack example since you included in the X-Pack docs
cjcenizal
left a comment
There was a problem hiding this comment.
💯 This is fantastic! Thanks so much for doing this.
💚 Build Succeeded |
* docs: Add test file location -> test runner table * Use scripts/mocha instead of if yarn test:mocha and clarify arguments * docs: add some examples of running tests suites with grep patterns * Split out x-pack testing docs, add test runner column * Split out x-pack testing docs, add test runner column #2 * Use node scripts for jest and split functional runner/server
* docs: Add test file location -> test runner table * Use scripts/mocha instead of if yarn test:mocha and clarify arguments * docs: add some examples of running tests suites with grep patterns * Split out x-pack testing docs, add test runner column * Split out x-pack testing docs, add test runner column #2 * Use node scripts for jest and split functional runner/server
Summary
Following discussions around #34557 this adds documentation to CONTRIBUTING.md to try to address the following pain point:
Please add suggestions for further test locations/runner invocations if there's anything I missed.
I wasn't able to figure out the following:
The following table outlines possible test file locations and how to invoke them:
src/**/*.test.jssrc/**/*.test.tsyarn test:jest -t regexp [test path]src/**/__tests__/**/*.jspackages/kbn-datemath/test/**/*.jspackages/kbn-dev-utils/src/**/__tests__/**/*.jstasks/**/__tests__/**/*.jsnode scripts/mocha --grep=regexp [test path]**/integration_tests/**/*.test.jsnode scripts/jest_integration -t regexp [test path]test/*integration/**/config.jstest/*functional/**/config.jsx-pack/test/*integration/**/config.jsx-pack/test/*functional/config.jsnode scripts/functional_tests --config test/[directory]/config.js --grep=regexpx-pack/**/*.test.jsx-pack/**/*.test.tscd x-pack && yarn test:jest -t regexp [test path]x-pack/test/*integration/**/config.tsTest runner arguments:
-t=regexpor--grep=regexpwill only run tests or test suites whose descriptions matches the regular expression.[test path]is the relative path to the test file.Examples:
yarn test:jest src/core/server/elasticsearch/elasticsearch_service.test.tsyarn test:jest -t 'stops both admin and data clients' src/core/server/elasticsearch/elasticsearch_service.test.tsnode scripts/functional_tests --config x-pack/test/api_integration/config.js --grep='apis Monitoring Beats list with restarted beat instance should load multiple clusters'