Where should unit tests be placed in Meteor?

后端 未结 4 2028
悲哀的现实
悲哀的现实 2021-02-01 19:12

Is there a place where my tests can live without being run by Meteor?

I just started my first Meteor project, and began by writing unit tests with Mocha

4条回答
  •  孤街浪徒
    2021-02-01 19:43

    Since This is question from 2012, and there is no single comprehensive answer here, I would like to attempt one here.

    This is a good starting point for starting to think about testing your meteor project.

    In a nutshell Step1: meteor add sanjo:jasmine Step2: meteor add velocity:html-reporter

    The moment you do this, and if your application is running ( or whenever you start your application back running) , on the right upper corner of browser- where you open your application is opened - you shall start seeing a blinking dot. That's it. You have now your testing framework in place.

    Now you can actually produce a directory structure with the help of this framework also. The moment you click on that blinking dot, you shall see a popup like below.

    This has convenience links for generating your test directory structure.

    Alternatively, you can do it manually as below. Next thing is to decide on directory structure. Meteor Documentation says enough about it. You need to have tests folder in your project root.

    Taking cue from here, you can go like this.

    
    |---jasmine
          |---client
                 |--- integration
                          |---- my.first.integration.spec.js
          |---client
                 |--- unit
                          |---- my.first.unit.spec.js
    |---jasmine
          |---server
                 |--- integration
                          |---- my.first.integration.spec.js
          |---server
                 |--- unit
                          |---- my.first.unit.spec.js
    

    And Viola, start writing your jasmine tests. These posts can further help you.

    • Post1
    • Jasmine Documentation
    • This is another good tutorial

提交回复
热议问题