This is my test file where i keep getting document is not defined when doing npm test:
describe('Testing de vista.js', () => {
beforeEach(() => {
clr();
});
test('Funció set', () => {
set(5);
expect(document.getElementById('display_val').value).toBe(5);
});
});
...
I've tried this on package.json but it doesn't work at all:
{
"scripts": {
"test": "jest --watch"
},
"devDependencies": {
"@babel/plugin-transform-modules-commonjs": "^7.24.1",
"jest": "^29.7.0",
"jest-environment-jsdom": "^29.7.0",
"jsdom": "^24.0.0",
"puppeteer": "^22.8.0"
}
}
Vscode screenshot
New contributor
Jona is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.