No More Posting New Topics!

If you have a question or an issue, please start a thread in our Github Discussions Forum.
This forum is closed for new threads/ topics.

Navigation

    Quasar Framework

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search

    New to Quasar & Typescript, would like to write unit tests

    Help
    1
    2
    169
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • H
      hans_meine last edited by

      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 what quasar 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.

      1 Reply Last reply Reply Quote 0
      • H
        hans_meine last edited by

        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 in src/tests/axis.ts for me? Or src/tests/test_axis.ts? What is describe()? and it()? 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.

        1 Reply Last reply Reply Quote 0
        • First post
          Last post