New to Quasar & Typescript, would like to write unit tests
-
I am an experienced developer, but coming from C++ / Python worlds. I am proud to have developed a small Quasar-based game, and I successfully turned it into a Typescript project, but I had to use
quasar create
again, toggling TS usage, and compared the resulting files, modifying my existing project in many ways I hardly understood. In particular, I think I was confused by eslint setups, which differed between VS Code and whatquasar dev
output through webpack. Anyhow, I am very new to the whole toolchain, and I am not capable of setting up stuff by myself.Now, I have a small “Axis” helper class in
src/services/axis.ts
, and I would like to write unit tests for it. Can someone tell me how to do so? I don’t know where to start:- Which unit test package should I use? (Are there many?)
- Where should I place my tests?
- How should I run them?
- Should I test through quasar or not? (For now, I am not testing quasar components, but a simple helper class. Still, I would like to know about best quasar practices.)
Any pointers to documentation, relevant software projects, tutorials, or simple example repositories would be very welcome.
-
I found this blogpost: https://medium.com/@RupaniChirag/writing-unit-tests-in-typescript-d4719b8a0a40
Given that, I did
npm -D jest ts-jest
, but the post just gives the following “sample test”:describe('calculate', function() { it('add', function() { let result = Calculator.Sum(5, 2); expect(result).toBe(7); });
but I have no clue where to put this? Further up in the post, it seems to suggest that I put tests into a
tests
subdirectory. Should that be insrc/tests/axis.ts
for me? Orsrc/tests/test_axis.ts
? What isdescribe()
? andit()
?expect()
is certainly jest syntax, so I would try googling that, but I am afraid that I lack general knowledge about how to import tested code, whether tests need to be exported, how to structure such code in files, etc.