Test framework in VSCode

I have an online interview for an entry level developer role (JavaScript + React) next week and they asked me to prepare some IDE with a test framework of my choice. I use VSCode for coding but what do they mean by the test framework? I’m a bit confused. Can someone advise please?

Thank you

I’m guessing he means unit testing. For me, for React, Jest is the default. I would google some videos on Jest tutorials. There are others out there, but in my (limited) experience, Jest is the most common. I also see enzyme and RTL. But once you get one down, the others aren’t too hard. I’d just do a Jest tutorial and get things running. It’s entry level so they probably just want to see if you understand the basics of unit testing and understand its importance.

There are other kinds of testing: integration, end-to-end, etc. But unit testing is the bedrock and it’s where you usually start.

1 Like

Makes sense. Thank you!

You would normally use a test runner, which is a program that runs tests.

You install the runner in a project, and you normally provide the runner with some configuration that tells the it what files are test files, which ones to evaluate. Then when you run the test runner program, it looks for those files and runs the tests in them.

Jest is an example of a test runner, the most common for frontend code (others include Mocha, Tape and UVU). It’s set up to basically work out-of-the-box – it will automatically assume any files with the suffix .test.js (rather than any that are just .js) or any files in a folder called __test__ are test files and try to run the tests in them.

A test framework is something you can use in your tests, normally to allow you to test a specific tool. For React, “React Testing Library” is the most widely used (there is also Enzyme & the basic testing utilities provided by React). What it does is make it easy to mount specific components then make assertions about them (“if I give X component Y props, Z text should be rendered”, for example).

Create React App comes with Jest + React Testing Library set up and ready to go.

Regarding IDE integration, if I take VSCode as an example, there is a Jest plugin that will allow VSCode to run the tests (and do fancy stuff like mark tests in your files when you have them open, allowing you to run them individually and showing you in the file what’s passing and what’s failing).

3 Likes

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.