- Make sure that you have a copy of this repository. Please fork this to do so. Step by step instructions can be found here.
- Here's a guide on how to install this Chrome extension on your local machine, if you would like to see it in action.
-
All test files are inside the
test
folder of either directory. -
To add a new test file, you can create a new file under the
test
folder with the following format:{{ filename }}.test.js
☁️ Do not forget to add the
.test.js
. If you simply adding.js
, Jest will not be able to recognize this file. -
Please use the ES6 syntax in writing your test files. Some pages to visit if you haven't used ES6:
-
Please create tests with value. A test like the one below, while good as an example, is not really something we need to test out since it's obvious.
describe('example', () => { it('runs a example test and passes', () => { expect(1 + 1).toEqual(2); }); });
☁️ Check out items that do not have tests yet with the test coverage.
-
If you have no experience with Jest yet, I highly suggest looking for tutorials on it. Here are some to get you started (these helped me out too):
- Unit Testing -- VueJS by Vue.js
- Testing Vue with Jest by DigitalOcean
- Using Jest to test your Node.js application by Dimitri
☁️ You can use this repository to practice!
-
You can run all tests in either the
client
orserver
directories with this command:npm test
-
You can run a single file with:
npm test {{ filename }} npm test OptionsButton.test.js
Running npm test
on it's own gives a nice summary on its own, but if you would like a more detailed version, you can open the coverage/index.html
file in either directories.
Upon opening that in the browser, you should see something like this:
☁️ It's bloody red right now since testing was just added (June 2020), but if you would like to help in this repo having 100% test coverage, please check out this issue.
If you click on one file, this actually highlights the untested code. You can use this to decide on what tests you want to do!
> jest
FAIL test/src/components/OptionsButton.test.js
● Test suite failed to run
TypeError: (0 , _vm(...).compileFunction) is not a function
at Runtime._execModule (node_modules/jest-runtime/build/index.js:1166:56)
If you encounter something like this when running npm run test
, make sure that your node version (node -v
) is v.12.18.0
(latest stable version as of writing) or above.
I myself encountered this as my node version was just v.10.4.0
. This was first documented in this issue. Here's an article to help you out in updating your node version.