Link frontend fixtures to jest specs for selective test execution mapping
Objective
To enable Jest to identify the dependency from a test file to a JSON fixture. This would enable us to be more efficient in running tests when a JSON fixture changes, by running only the tests that are dependent on the fixtures that changed. To do so, we would need to use import
statement to import the JSON fixture into test file.
To illustrate this behaviour:
Before, jest
would not be able to identify tests that use a particular JSON fixture.
$ jest --config jest.config.js --listTests --findRelatedTests tmp/tests/frontend/fixtures-ee/api/freeze-periods/freeze_periods.json
Done in 15.44s.
After, jest
would not be able to identify tests that use a particular JSON fixture.
$ jest --config jest.config.js --listTests --findRelatedTests tmp/tests/frontend/fixtures-ee/api/freeze-periods/freeze_periods.json
spec/frontend/deploy_freeze/components/timezone_dropdown_spec.js
spec/frontend/deploy_freeze/components/deploy_freeze_settings_spec.js
spec/frontend/deploy_freeze/components/deploy_freeze_modal_spec.js
spec/frontend/deploy_freeze/store/actions_spec.js
spec/frontend/deploy_freeze/components/deploy_freeze_table_spec.js
spec/frontend/deploy_freeze/store/mutations_spec.js
Done in 19.39s.
Plan
- Set up a baseline to import JSON fixture and hook into jest resolver to warn the user when a fixture has not been generated. !70893 (merged)
- Deprecate
getJSONFixture
and direct to useimport
. !71808 (merged) - Move remaining instances of
getJSONFixture
toimport
. !71898 (merged) !71899 (merged) !71900 (merged) !71901 (merged) !71902 (merged) !71903 (merged) !71904 (merged) - Change usage of getJSONFixture using
static/
path !72358 (merged) - Change usage of getJSONFixture using dynamically generated path (mostly in analytics mock data) !72484 (merged)
Edited by Albert