Skip to content

Conversation

@spalger
Copy link
Contributor

@spalger spalger commented Jul 17, 2019

While inspecting some Jest test output I noticed a troubling error message printed out:

14:49:31     
14:49:31         Returning a Promise from "describe" is not supported. Tests must be defined synchronously.
14:49:31         Returning a value from "describe" will fail the test in a future version of Jest.
14:49:31     
14:49:31           59 | 
14:49:31           60 | describe('license checks', () => {
14:49:31         > 61 |   describe('with a basic license', async () => {
14:49:31              |   ^
14:49:31           62 |     let usageStats;
14:49:31           63 |     beforeAll(async () => {
14:49:31           64 |       const serverWithBasicLicenseMock = getServerMock();
14:49:31     
14:49:31           at addSpecsToSuite (../node_modules/jest-jasmine2/build/jasmine/Env.js:504:17)
14:49:31           at Suite.describe (legacy/plugins/reporting/server/usage/get_reporting_usage_collector.test.js:61:3)
14:49:31           at Object.describe (legacy/plugins/reporting/server/usage/get_reporting_usage_collector.test.js:60:1)
14:49:31     

This error is only logged to the console and does not prevent the tests from running. The code was written (I assume) to maintain backwards compatibility, but won't actually fail the tests until Jest 25. Instead, the jest team recommends in a comment on the PR that we should be validating describe calls with eslint.

@spalger spalger added test Team:Operations Kibana-Operations Team v8.0.0 release_note:skip Skip the PR/issue when compiling release notes v7.3.0 v7.2.1 v7.4.0 v6.8.2 labels Jul 17, 2019
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-operations

@spalger spalger force-pushed the fix/jest-async-describe branch from 65b60dc to 123f62c Compare July 17, 2019 16:02
@spalger spalger requested a review from a team as a code owner July 17, 2019 16:02
@spalger spalger changed the title [jest] don't allow async describe functions [jest] disallow invalid describe calls Jul 17, 2019
@elasticmachine

This comment has been minimized.

@spalger spalger requested a review from a team as a code owner July 18, 2019 13:57
@elasticmachine
Copy link
Contributor

💔 Build Failed

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

@spalger spalger merged commit c3f31c7 into elastic:master Jul 18, 2019
@spalger spalger deleted the fix/jest-async-describe branch July 18, 2019 17:11
spalger pushed a commit to spalger/kibana that referenced this pull request Jul 18, 2019
* [jest] disallow invalid describe calls

* correct other describe calls

* remove unnecessary glob

* cast decribe names to strings

* remove new async describe function

# Conflicts:
#	x-pack/legacy/plugins/index_management/__jest__/client_integration/home.test.ts
#	x-pack/test/functional/apps/uptime/monitor.ts
spalger pushed a commit to spalger/kibana that referenced this pull request Jul 18, 2019
* [jest] disallow invalid describe calls

* correct other describe calls

* remove unnecessary glob

* cast decribe names to strings

* remove new async describe function

# Conflicts:
#	test/functional/apps/dashboard/dashboard_filtering.js
#	x-pack/legacy/plugins/index_management/__jest__/client_integration/home.test.ts
#	x-pack/legacy/plugins/reporting/server/usage/get_reporting_usage_collector.test.js
#	x-pack/test/functional/apps/uptime/monitor.ts
#	x-pack/test_utils/jest/integration_tests/example_integration.test.ts
spalger pushed a commit to spalger/kibana that referenced this pull request Jul 18, 2019
* [jest] disallow invalid describe calls

* correct other describe calls

* remove unnecessary glob

* cast decribe names to strings

* remove new async describe function

# Conflicts:
#	src/legacy/core_plugins/data/public/filter/filter_manager/filter_manager.test.ts
#	test/functional/apps/dashboard/dashboard_filtering.js
#	test/functional/apps/visualize/_point_series_options.js
#	x-pack/legacy/plugins/cross_cluster_replication/__jest__/client_integration/auto_follow_pattern_list.test.js
#	x-pack/legacy/plugins/cross_cluster_replication/__jest__/client_integration/follower_indices_list.test.js
#	x-pack/legacy/plugins/index_management/__jest__/client_integration/home.test.ts
#	x-pack/legacy/plugins/maps/public/connected_components/map/feature_properties.test.js
#	x-pack/legacy/plugins/maps/public/connected_components/map/feature_tooltip.test.js
#	x-pack/legacy/plugins/remote_clusters/__jest__/client_integration/remote_clusters_list.test.js
#	x-pack/legacy/plugins/reporting/export_types/csv/server/__tests__/execute_job.js
#	x-pack/legacy/plugins/reporting/server/usage/get_reporting_usage_collector.test.js
#	x-pack/legacy/plugins/security/server/lib/authorization/privileges/privileges.test.ts
#	x-pack/legacy/plugins/siem/public/components/last_event_time/index.test.tsx
#	x-pack/legacy/plugins/siem/public/components/page/add_to_kql/index.test.tsx
#	x-pack/legacy/plugins/siem/public/components/page/hosts/first_last_seen_host/index.test.tsx
#	x-pack/test/functional/apps/canvas/smoke_test.js
#	x-pack/test/functional/apps/maps/documents_source/top_hits.js
#	x-pack/test/functional/apps/rollup_job/rollup_jobs.js
#	x-pack/test/functional/apps/uptime/monitor.ts
#	x-pack/test_utils/jest/integration_tests/example_integration.test.ts
spalger pushed a commit to spalger/kibana that referenced this pull request Jul 18, 2019
* [jest] disallow invalid describe calls

* correct other describe calls

* remove unnecessary glob

* cast decribe names to strings

* remove new async describe function

# Conflicts:
#	.eslintrc.js
#	src/legacy/core_plugins/data/public/filter/filter_manager/filter_manager.test.ts
#	src/legacy/ui/public/courier/fetch/request/serialize_fetch_params/serialize_fetch_params.test.js
#	src/legacy/ui/public/kfetch/kfetch.test.ts
#	test/api_integration/apis/management/saved_objects/relationships.js
#	test/functional/apps/dashboard/create_and_add_embeddables.js
#	test/functional/apps/dashboard/dashboard_filter_bar.js
#	test/functional/apps/dashboard/dashboard_filtering.js
#	test/functional/apps/dashboard/dashboard_listing.js
#	test/functional/apps/dashboard/dashboard_options.js
#	test/functional/apps/dashboard/dashboard_query_bar.js
#	test/functional/apps/dashboard/dashboard_time.js
#	test/functional/apps/dashboard/embed_mode.js
#	test/functional/apps/dashboard/empty_dashboard.js
#	test/functional/apps/dashboard/full_screen_mode.js
#	test/functional/apps/dashboard/view_edit.js
#	test/functional/apps/discover/_discover.js
#	test/functional/apps/visualize/_point_series_options.js
#	test/functional/apps/visualize/_visualize_listing.js
#	x-pack/legacy/plugins/canvas/migrations.test.js
#	x-pack/legacy/plugins/canvas/server/routes/workpad.test.js
#	x-pack/legacy/plugins/cross_cluster_replication/__jest__/client_integration/auto_follow_pattern_list.test.js
#	x-pack/legacy/plugins/cross_cluster_replication/__jest__/client_integration/follower_indices_list.test.js
#	x-pack/legacy/plugins/grokdebugger/server/lib/license_pre_routing_factory/__tests__/license_pre_routing_factory.js
#	x-pack/legacy/plugins/index_management/__jest__/client_integration/home.test.ts
#	x-pack/legacy/plugins/maps/public/connected_components/map/feature_properties.test.js
#	x-pack/legacy/plugins/maps/public/connected_components/map/feature_tooltip.test.js
#	x-pack/legacy/plugins/monitoring/server/lib/elasticsearch_settings/__tests__/find_reason.js
#	x-pack/legacy/plugins/remote_clusters/__jest__/client_integration/remote_clusters_list.test.js
#	x-pack/legacy/plugins/reporting/export_types/csv/server/__tests__/execute_job.js
#	x-pack/legacy/plugins/reporting/server/routes/jobs.test.js
#	x-pack/legacy/plugins/reporting/server/usage/get_reporting_usage_collector.test.js
#	x-pack/legacy/plugins/security/server/lib/authorization/privileges/privileges.test.ts
#	x-pack/legacy/plugins/siem/public/components/last_event_time/index.test.tsx
#	x-pack/legacy/plugins/siem/public/components/page/add_to_kql/index.test.tsx
#	x-pack/legacy/plugins/siem/public/components/page/hosts/first_last_seen_host/index.test.tsx
#	x-pack/test/api_integration/apis/management/index_lifecycle_management/nodes.js
#	x-pack/test/api_integration/apis/security/roles.js
#	x-pack/test/functional/apps/canvas/smoke_test.js
#	x-pack/test/functional/apps/discover/feature_controls/discover_spaces.ts
#	x-pack/test/functional/apps/maps/documents_source/top_hits.js
#	x-pack/test/functional/apps/maps/es_geo_grid_source.js
#	x-pack/test/functional/apps/rollup_job/rollup_jobs.js
#	x-pack/test/functional/apps/spaces/spaces_selection.ts
#	x-pack/test/functional/apps/uptime/monitor.ts
#	x-pack/test_utils/jest/integration_tests/example_integration.test.ts
spalger pushed a commit that referenced this pull request Jul 18, 2019
* [jest] disallow invalid describe calls

* correct other describe calls

* remove unnecessary glob

* cast decribe names to strings

* remove new async describe function

# Conflicts:
#	x-pack/legacy/plugins/index_management/__jest__/client_integration/home.test.ts
#	x-pack/test/functional/apps/uptime/monitor.ts
@spalger
Copy link
Contributor Author

spalger commented Jul 18, 2019

7.x/7.4: 68f1441
7.3: 4d5764f
7.2: cd19911
6.8: ec50f86

spalger pushed a commit that referenced this pull request Jul 18, 2019
* [jest] disallow invalid describe calls (#41378)

* [jest] disallow invalid describe calls

* correct other describe calls

* remove unnecessary glob

* cast decribe names to strings

* remove new async describe function

# Conflicts:
#	test/functional/apps/dashboard/dashboard_filtering.js
#	x-pack/legacy/plugins/index_management/__jest__/client_integration/home.test.ts
#	x-pack/legacy/plugins/reporting/server/usage/get_reporting_usage_collector.test.js
#	x-pack/test/functional/apps/uptime/monitor.ts
#	x-pack/test_utils/jest/integration_tests/example_integration.test.ts

* fix eslint violation
spalger pushed a commit that referenced this pull request Jul 19, 2019
* [jest] disallow invalid describe calls (#41378)

* [jest] disallow invalid describe calls

* correct other describe calls

* remove unnecessary glob

* cast decribe names to strings

* remove new async describe function

# Conflicts:
#	src/legacy/core_plugins/data/public/filter/filter_manager/filter_manager.test.ts
#	test/functional/apps/dashboard/dashboard_filtering.js
#	test/functional/apps/visualize/_point_series_options.js
#	x-pack/legacy/plugins/cross_cluster_replication/__jest__/client_integration/auto_follow_pattern_list.test.js
#	x-pack/legacy/plugins/cross_cluster_replication/__jest__/client_integration/follower_indices_list.test.js
#	x-pack/legacy/plugins/index_management/__jest__/client_integration/home.test.ts
#	x-pack/legacy/plugins/maps/public/connected_components/map/feature_properties.test.js
#	x-pack/legacy/plugins/maps/public/connected_components/map/feature_tooltip.test.js
#	x-pack/legacy/plugins/remote_clusters/__jest__/client_integration/remote_clusters_list.test.js
#	x-pack/legacy/plugins/reporting/export_types/csv/server/__tests__/execute_job.js
#	x-pack/legacy/plugins/reporting/server/usage/get_reporting_usage_collector.test.js
#	x-pack/legacy/plugins/security/server/lib/authorization/privileges/privileges.test.ts
#	x-pack/legacy/plugins/siem/public/components/last_event_time/index.test.tsx
#	x-pack/legacy/plugins/siem/public/components/page/add_to_kql/index.test.tsx
#	x-pack/legacy/plugins/siem/public/components/page/hosts/first_last_seen_host/index.test.tsx
#	x-pack/test/functional/apps/canvas/smoke_test.js
#	x-pack/test/functional/apps/maps/documents_source/top_hits.js
#	x-pack/test/functional/apps/rollup_job/rollup_jobs.js
#	x-pack/test/functional/apps/uptime/monitor.ts
#	x-pack/test_utils/jest/integration_tests/example_integration.test.ts

* fix eslint violations
spalger pushed a commit that referenced this pull request Jul 19, 2019
* [jest] disallow invalid describe calls (#41378)

* [jest] disallow invalid describe calls

* correct other describe calls

* remove unnecessary glob

* cast decribe names to strings

* remove new async describe function

# Conflicts:
#	.eslintrc.js
#	src/legacy/core_plugins/data/public/filter/filter_manager/filter_manager.test.ts
#	src/legacy/ui/public/courier/fetch/request/serialize_fetch_params/serialize_fetch_params.test.js
#	src/legacy/ui/public/kfetch/kfetch.test.ts
#	test/api_integration/apis/management/saved_objects/relationships.js
#	test/functional/apps/dashboard/create_and_add_embeddables.js
#	test/functional/apps/dashboard/dashboard_filter_bar.js
#	test/functional/apps/dashboard/dashboard_filtering.js
#	test/functional/apps/dashboard/dashboard_listing.js
#	test/functional/apps/dashboard/dashboard_options.js
#	test/functional/apps/dashboard/dashboard_query_bar.js
#	test/functional/apps/dashboard/dashboard_time.js
#	test/functional/apps/dashboard/embed_mode.js
#	test/functional/apps/dashboard/empty_dashboard.js
#	test/functional/apps/dashboard/full_screen_mode.js
#	test/functional/apps/dashboard/view_edit.js
#	test/functional/apps/discover/_discover.js
#	test/functional/apps/visualize/_point_series_options.js
#	test/functional/apps/visualize/_visualize_listing.js
#	x-pack/legacy/plugins/canvas/migrations.test.js
#	x-pack/legacy/plugins/canvas/server/routes/workpad.test.js
#	x-pack/legacy/plugins/cross_cluster_replication/__jest__/client_integration/auto_follow_pattern_list.test.js
#	x-pack/legacy/plugins/cross_cluster_replication/__jest__/client_integration/follower_indices_list.test.js
#	x-pack/legacy/plugins/grokdebugger/server/lib/license_pre_routing_factory/__tests__/license_pre_routing_factory.js
#	x-pack/legacy/plugins/index_management/__jest__/client_integration/home.test.ts
#	x-pack/legacy/plugins/maps/public/connected_components/map/feature_properties.test.js
#	x-pack/legacy/plugins/maps/public/connected_components/map/feature_tooltip.test.js
#	x-pack/legacy/plugins/monitoring/server/lib/elasticsearch_settings/__tests__/find_reason.js
#	x-pack/legacy/plugins/remote_clusters/__jest__/client_integration/remote_clusters_list.test.js
#	x-pack/legacy/plugins/reporting/export_types/csv/server/__tests__/execute_job.js
#	x-pack/legacy/plugins/reporting/server/routes/jobs.test.js
#	x-pack/legacy/plugins/reporting/server/usage/get_reporting_usage_collector.test.js
#	x-pack/legacy/plugins/security/server/lib/authorization/privileges/privileges.test.ts
#	x-pack/legacy/plugins/siem/public/components/last_event_time/index.test.tsx
#	x-pack/legacy/plugins/siem/public/components/page/add_to_kql/index.test.tsx
#	x-pack/legacy/plugins/siem/public/components/page/hosts/first_last_seen_host/index.test.tsx
#	x-pack/test/api_integration/apis/management/index_lifecycle_management/nodes.js
#	x-pack/test/api_integration/apis/security/roles.js
#	x-pack/test/functional/apps/canvas/smoke_test.js
#	x-pack/test/functional/apps/discover/feature_controls/discover_spaces.ts
#	x-pack/test/functional/apps/maps/documents_source/top_hits.js
#	x-pack/test/functional/apps/maps/es_geo_grid_source.js
#	x-pack/test/functional/apps/rollup_job/rollup_jobs.js
#	x-pack/test/functional/apps/spaces/spaces_selection.ts
#	x-pack/test/functional/apps/uptime/monitor.ts
#	x-pack/test_utils/jest/integration_tests/example_integration.test.ts

* fix eslint violations
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release_note:skip Skip the PR/issue when compiling release notes Team:Operations Kibana-Operations Team test v6.8.2 v7.2.1 v7.3.0 v7.4.0 v8.0.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants