how to solve the problem?
/var/www/html# npm run test > test > jest FAIL tests/components/Home.test.js ✕ displays message (2 ms) ● displays message The error below may be caused by using the wrong test environment, see https://jestjs.io/docs/configuration#testenvironment-string. Consider using the "jsdom" test environment. ReferenceError: document is not defined 7 | 8 | test("displays message", () => { > 9 | const wrapper = mount(Home); | ^ 10 | 11 | expect(wrapper.text()).toContain("Home component"); 12 | }); at mount (node_modules/@vue/test-utils/dist/vue-test-utils.cjs.js:7840:14) at Object.<anonymous> (tests/components/Home.test.js:9:21) Test Suites: 1 failed, 1 total Tests: 1 failed, 1 total Snapshots: 0 total Time: 4.516 s Ran all test suites.
So on your package.json, replace: { ... "scripts": { ... "test": "jest" ... }, }
with
{ ... "scripts": { ... "test": "jest --env=jsdom" ... }, }
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
how to solve the problem?
So on your package.json, replace:
{
...
"scripts": {
...
"test": "jest"
...
},
}
with
{
...
"scripts": {
...
"test": "jest --env=jsdom"
...
},
}