Add Jest for Vue testing
Add Jest for Vue testing.
I went with Jest over trying to shove something into Mocha because I kept running into roadblocks and the shoddy setup didn't seem nice.
Part of https://gitlab.com/gitlab-org/gitter/webapp/merge_requests/1360
npm run jest
npm run jest -- test/public-js/vue/left-menu/components/index-test.js
- https://vue-test-utils.vuejs.org/guides/#testing-single-file-components-with-jest
- Also based off of gitlab-ce, https://gitlab.com/gitlab-org/gitlab-ce/tree/6418ffacfaf9394391b4662a97abc57e8fd78f9b/
Testing notes
Jest
- Aligns with what GitLab is moving forward with
- https://vue-test-utils.vuejs.org/guides/#testing-single-file-components-with-jest
- Built in snapshotting
Mocha
- https://vue-test-utils.vuejs.org/guides/testing-single-file-components-with-mocha-webpack.html
mocha-webpack
- Using https://github.com/bahmutov/snap-shot-it
- Running into
TypeError: Converting circular structure to JSON
when trying tosnapshot(vm.element);
- Running into
- Requires yet another webpack config
- Using beta version
mocha-webpack@2.0.0-beta.0
for webpack 4 support and project hasn't been touched in a year
You can see my attempt here, https://gitlab.com/gitlab-org/gitter/webapp/merge_requests/1360/diffs?commit_id=012a09443ae36ae4c2162f188667e4afbd9ab540
-
https://medium.com/blogfoster-engineering/how-to-use-the-power-of-jests-snapshot-testing-without-using-jest-eff3239154e5
- Doesn't account for
.vue
files and transpiling
- Doesn't account for
Edited by Eric Eastwood