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

docs: Add test file location -> test runner table #34986

Merged
merged 6 commits into from
Apr 19, 2019
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 24 additions & 5 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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) |
Copy link
Contributor

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)”

Copy link
Contributor

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.

| ------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------- |
| `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` | ?? |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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"

Copy link
Contributor

@tylersmalley tylersmalley Apr 15, 2019

Choose a reason for hiding this comment

The 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.

Copy link
Contributor

Choose a reason for hiding this comment

The 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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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:
Copy link
Contributor

Choose a reason for hiding this comment

The 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

Expand Down