trailheadapps / dreamhouse-lwc

Sample application for Lightning Web Components on Salesforce Platform. Part of the sample gallery. Real estate use case. Get inspired and learn best practices.
https://developer.salesforce.com
Apache License 2.0
382 stars 768 forks source link

VSCode Test Explorer unable to run tests #593

Closed drmacm closed 7 months ago

drmacm commented 7 months ago

Summary

After cloning the repo, VSCode's Test Explorer is unable to run the tests in the app. The tests work when running npm run test:unit in terminal.

Fixed by running npm install jest-environment-jsdom --save-dev.

I can submit a PR with extra dependency if you agree with the approach.

Salesforce Org Type

Scratch Org

Steps To Reproduce

  1. Clone the repo
  2. Open it with VSCode
  3. Run npm install
  4. Run npm run test:unit and observe that the tests pass
  5. Open VSTest Explorer click on "Run all" icon

Current Behavior

All tests fail

Expected Behavior

All tests pass

Relevant Log Output

● Test suite failed to run

    TypeError: Cannot read properties of undefined (reading 'html')

      at new JSDOMEnvironment (node_modules/jest-environment-jsdom/build/index.js:72:44)

Code of Conduct

github-actions[bot] commented 7 months ago

Thank you for posting this issue. 🙇🏼‍♂️
We will come back to you shortly.

albarivas commented 7 months ago

Hello,

This issue occurs because Jest v28 stopped bundling the extra jest-environment-jsdom dependency. This is required for LWC, and has been pre-packaged by sfdx-lwc-jest. I'll update sfdx-lwc-jest to get it fixed.

Thanks for your contribution!

albarivas commented 7 months ago

Fixed on https://github.com/trailheadapps/dreamhouse-lwc/pull/594