site-kit-wp
site-kit-wp copied to clipboard
Fix error in `DashboardNavigation` stories
Bug Description
VRT runs currently show the following ReferenceError
that happens several times during a test run:
Unexpected error while loading ./components/DashboardNavigation/index.stories.js: ReferenceError: describe is not defined
This is from the stories module importing a helper from a Jest test file which includes calls to describe
as a side-effect. This is provided automatically by Jest so it errors as undefined in VRT runs.
Steps to reproduce
- Run VRT or inspect the output of a run
- See the error above
Do not alter or remove anything below. The following sections will be managed by moderators only.
Acceptance criteria
- The
describe is not defined
error should not be raised during VRT runs
Implementation Brief
- We need to import the
setupDefaultChips()
function into the story file from a non-Jest file so thatdescribe
isn't called as a side-effect. - Inside
assets/js/components/DashboardNavigation
:- Create a new file named
test-utils.js
. In this file:- Add the default file header comments. The description of the file should be
DashboardNavigation test utility functions.
. - Copy over the
setupDefaultChips()
function fromindex.test.js
to this file (including relevant imports and JSDoc comments).
- Add the default file header comments. The description of the file should be
- In
index.test.js
, importsetupDefaultChips()
fromtest-utils.js
. Remove unnecessary dependencies - In
index.stories.js
, importsetupDefaultChips()
fromtest-utils.js
instead ofindex.test.js
.
- Create a new file named
Test Coverage
- N/A
QA Brief
- QA:Eng - The Reference Error mentioned in the AC will not show up in VRT test logs.
- Check it in the PR run.
- Check locally as well.
Changelog entry
- Fix js errors in the storybook stories.
Hey @nfmohit, this IB looks good. One minor tweak I would suggest is to use the filename test-utils.js
rather than utils.js
, just to make it clear that what's in the file is related to non-production code only.
Hey @nfmohit, this IB looks good. One minor tweak I would suggest is to use the filename
test-utils.js
rather thanutils.js
, just to make it clear that what's in the file is related to non-production code only.
Very valid suggestion. I've updated the IB. Thank you @techanvil!
Thanks @nfmohit!
IB :white_check_mark:
QA:Eng Verified ✅
- Verified it in the PR run.
- Verified running VRT locally as well.