
Recently I was curious about something: Is it possible to write unit tests for front end code that doesn’t use any sort of UI framework or develope...
For further actions, you may consider blocking this person and/or reporting abuse
Over the top good news. I find Karma to be untenable most of the time, I want to avoid it, and have written a number of articles to that extent. None of them giving me a total solution. I will try your recommendations as I think, this method would also work for Angular which is my arena.... Thanks Tyler!!!!!!
You're welcome! Let me know if you discover anything interesting in your testing!
Legendary. I've been coding a lot of Vanilla JS lately, and imperative DOM manipulation feels very fragile compared to React. I'm going to use the techniques here to start adding some tests to make sure I don't break anything.
Excellent! Helped me a lot. I was facing exactly the same task. I was aware of the
runScripts: 'dangerously'
option, but I tried to configure it from jest.config.js without any luck.Hi there! It's a great article and all, but how do I test individual functions, variables, etc. in an external JavaScript file?
That should be simple enough to do just using Jest (or any other testing framework). Export the functions etc. from the Javascript file, import them into a test file and use your testing framework to assess that the functions work correctly. :)
Unless I have misunderstood the question...
Hi there! There are issues with ESM and what if these JS functions have DOM manipulations? Those seem to be my issues.
I have a question i tried to move the script to a new file and an the test doesn' t work anymore. What can I do?