Coder Social home page Coder Social logo

Add unit tests about quizdown-js HOT 5 OPEN

bonartm avatar bonartm commented on June 17, 2024
Add unit tests

from quizdown-js.

Comments (5)

kheitkamp avatar kheitkamp commented on June 17, 2024 1

I've created a new fork and added the changes there in the main branch.

from quizdown-js.

kheitkamp avatar kheitkamp commented on June 17, 2024

Hi Malte,
I've created a unit test for the Button component. If you would give me the proper rights, I could push it into a new branch called issue13_add_unit_tests

from quizdown-js.

kheitkamp avatar kheitkamp commented on June 17, 2024

I used the following tutorial:
https://testing-library.com/docs/svelte-testing-library/intro

I had to add the following packages to the package.json to make the tutorial work:
"@testing-library/jest-dom": "^5.16.1",
"@testing-library/svelte": "^3.0.3",

I also needed to add the following comment at the top of the test file:
/**

  • @jest-environment jsdom
    */

Jest-dom is described here:
https://github.com/testing-library/jest-dom#usage

You'll find an overview of testing queries here:
https://testing-library.com/docs/queries/byrole/

from quizdown-js.

kheitkamp avatar kheitkamp commented on June 17, 2024

For better unit testing I would recommend to break the quiz.ts file into a module which imports all the classes currently included in the quiz.ts file. Like with java, where every class has it's own file.
It will make your code much more readable and force you to give your classes a clear structure and interdependency while preventing your code to become spaghetti ;-)
Also there are a lot of loose functions within the quiz.ts file which mostly seem to be methods that belong to the BaseQuestion class and therefore should be part of it. Quiz just seems to need a bit clean up ;-)
Also I would put each type declaration into its own model file which then should be imported by each class that needs it.
Drawing a UML class diagram could be very helpful for structuring the classes: https://www.tutorialspoint.com/uml/uml_class_diagram.htm
Typescript has a very detailed documentation of how to summarise different classes into one module: https://www.typescriptlang.org/docs/handbook/modules.html

from quizdown-js.

bonartm avatar bonartm commented on June 17, 2024

Thanks a lot, Kristian, for your work and suggestions. I will look into it in the upcoming weeks.

from quizdown-js.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.