MagicMirror Forum
    • Recent
    • Tags
    • Unsolved
    • Solved
    • MagicMirror² Repository
    • Documentation
    • 3rd-Party-Modules
    • Donate
    • Discord
    • Register
    • Login
    A New Chapter for MagicMirror: The Community Takes the Lead
    Read the statement by Michael Teeuw here.

    Test suite for MagicMirror²

    Scheduled Pinned Locked Moved Upcoming Features
    42 Posts 5 Posters 47.3k Views 6 Watching
    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.
    • Q Offline
      qistoph @roramirez
      last edited by

      @roramirez what do you mean by “S.O”?

      R 1 Reply Last reply Reply Quote 0
      • R Offline
        roramirez Core Contributors @qistoph
        last edited by

        @qistoph Sorry, Spanish acronymous. I mean Operating System.

        On the another hand. The same commit is passed in Travis on my personal forked but in the main Mich’s repository failed.

        https://travis-ci.org/roramirez/MagicMirror/builds/200750569 (Pass)
        https://travis-ci.org/MichMich/MagicMirror/builds/200750793 (Fail)

        It’s so weird.

        Easy module development with MagicMirror Module Template

        Q 1 Reply Last reply Reply Quote 0
        • Q Offline
          qistoph @roramirez
          last edited by

          @roramirez my tests ran on Ubuntu.

          The failed build you’re linking has timeouts. That’s the issue I added to the Trello board. We could increase the timeout a bit and see if it happens again in the next days.

          Ask Mich to re-run the failed build, he should be able to click that option in Travis, being the owner of the project. See if that fails again. That resolved it for me before.

          R 1 Reply Last reply Reply Quote 0
          • R Offline
            roramirez Core Contributors @qistoph
            last edited by

            @qistoph it’s pushed https://github.com/MichMich/MagicMirror/pull/716

            Easy module development with MagicMirror Module Template

            1 Reply Last reply Reply Quote 0
            • R Offline
              roramirez Core Contributors
              last edited by

              Hey guys,

              I pushed up a small refactoring for tests.
              https://github.com/MichMich/MagicMirror/pull/728

              This is a improvement for create new tests without unnecessary repeat inside of code.

              Something I wasnt think now is how can be integrate the case test created by @qistoph because this is set a app.path inside of test (It’s something I have not tried…yet)

              https://github.com/MichMich/MagicMirror/blob/e62df3b3b18cc98b65656194fa5baa53b9110fbc/tests/e2e/dev_console.js#L37

              Easy module development with MagicMirror Module Template

              1 Reply Last reply Reply Quote 0
              • R Offline
                roramirez Core Contributors
                last edited by

                A little update and I requests ideas and help

                Today I’m playing with a test for newsfeed module. Its not functional. I’m using the same MagicMirror as backend for response a feed (in the future can be good idea a fake server for testing purposes).

                The patch can you find on
                https://github.com/roramirez/MagicMirror/commit/db87f9e15b79827e947316c3ffba5b4ca49854b7

                The main case is the waiting the tests for module title and titles of news. There a delay around a 1 second after the “loading…” when is show in screen. Somebody have an idea to gets this test?

                Easy module development with MagicMirror Module Template

                R 1 Reply Last reply Reply Quote 0
                • R Offline
                  roramirez Core Contributors @roramirez
                  last edited by

                  I fixed before mentioned https://github.com/roramirez/MagicMirror/commit/2a94ee55ccb8fa06f4d07c2a67307b5ed0a659a3

                  :)

                  Easy module development with MagicMirror Module Template

                  1 Reply Last reply Reply Quote 0
                  • R Offline
                    roramirez Core Contributors
                    last edited by

                    The last build of today.

                    0_1490719678643_Screenshot at 2017-03-28 13-42-01.png

                    Easy module development with MagicMirror Module Template

                    R 1 Reply Last reply Reply Quote 1
                    • R Offline
                      roramirez Core Contributors @roramirez
                      last edited by

                      I mention this here if someone can help

                      If use moment-timezone for a test this fail

                      • Fail in Travis: https://travis-ci.org/roramirez/MagicMirror/builds/220155902
                      • Commit example: https://github.com/roramirez/MagicMirror/commit/05d7c9556e773bf2b941035953200ff327efb476

                      Easy module development with MagicMirror Module Template

                      1 Reply Last reply Reply Quote 0
                      • R Offline
                        roramirez Core Contributors
                        last edited by

                        Hi Guys, are you still alive?

                        Sometimes the build failed, an example here
                        https://travis-ci.org/MichMich/MagicMirror/jobs/227577643

                        Someone have some idea how to fix this?

                        cc @qistoph @strawberry-3-141 @morozgrafix

                        Easy module development with MagicMirror Module Template

                        Q 1 Reply Last reply Reply Quote 0
                        • Q Offline
                          qistoph @roramirez
                          last edited by

                          @roramirez sorry, haven’t had much time to spend on MagicMirror lately.

                          My guess is that some of the tests take too long. Especially the ones actually starting MM and not just load a module.

                          I imagine Travis runs the tests in some sort of container with multiple containers running on the same system. If there is some heavy load at the same time as the MM test is run this might slow down our test with a certain factor. Seeing the difference in the usual runtime between tests (couple of ms vs multiple seconds) makes me think some of our tests are on the heavier end. Having a multiple second test delayed by a factor, say, 2 makes it easily run 5 seconds. Hitting the 5 sec maximum (see log).

                          Two possibilities I see to fix this:

                          1. Reduce the runtime of long running tests
                          2. Increase the allowed runtime before timeout

                          Hopefully this helps.

                          Best regards and thanks for keeping this thread alive!

                          R 1 Reply Last reply Reply Quote 0
                          • R Offline
                            roramirez Core Contributors @qistoph
                            last edited by

                            @qistoph Well I’ve testing de CircleCI vs Travis.

                            For same Build
                            Failed: https://travis-ci.org/roramirez/MagicMirror/builds/234342109
                            Sucess: https://circleci.com/gh/roramirez/MagicMirror/6

                            Easy module development with MagicMirror Module Template

                            Q 1 Reply Last reply Reply Quote 0
                            • Q Offline
                              qistoph @roramirez
                              last edited by

                              @roramirez
                              Except for one of the errors I think all can still be explained by my last post.

                              R 1 Reply Last reply Reply Quote 0
                              • R Offline
                                roramirez Core Contributors @qistoph
                                last edited by

                                @qistoph said in Test suite for MagicMirror²:

                                Except for one of the errors I think all can still be explained by my last post.

                                Yes, you’re rigth. Can you help in this area?

                                Easy module development with MagicMirror Module Template

                                R 1 Reply Last reply Reply Quote 0
                                • R Offline
                                  roramirez Core Contributors @roramirez
                                  last edited by

                                  Yay! After a long fight the test are passing in Travis CI

                                  https://github.com/MichMich/MagicMirror/pull/953

                                  Easy module development with MagicMirror Module Template

                                  1 Reply Last reply Reply Quote 2
                                  • CatoC Offline
                                    Cato Module Developer
                                    last edited by

                                    I’m trying to find some information on testing in Magic Mirror for devs/contributors but it’s (too) hard to find. I can’t find any related forum, it’s not mentioned in the “MagicMirror² Module Development Documentation”, and not directly mentioned in any README-ish files on GitHub.

                                    Of course, some of this can be deduced from the source code, but a small “Getting Started” guide would help more people getting … eh started. :-)

                                    I’m living in Visual Studio as my day job, but not so much with writing tests, so my knowledge of other tools are limited. What I need is some information on software requirements and where tests should be and how testing is done.

                                    R 1 Reply Last reply Reply Quote 0
                                    • R Offline
                                      roramirez Core Contributors @Cato
                                      last edited by

                                      @Cato Hi!, The documentation for tests are living only in test source ;) This is something. We need to an better documentation.

                                      Are you interested to do it? https://trello.com/c/UwqL27A3/29-add-documentation-of-testsuite

                                      I’m not a very good at writing documentation.

                                      But in short terms,

                                      The tests are living in tests directory, there two kind of test, unit and e2e.

                                      We are using mocha and spectron`, the last one is for the tests of e2e. For every e2e test is using a configuration file. When the test run load the configuration file and we check expected result of the MagicMirror instance in Electron mode.

                                      You can using the follow sentences to run testsuite

                                      • Unit test: npm run test:unit
                                      • E2e tests: npm run test:e2e
                                      • Unit + e2e: npm test

                                      If you can run especific test you need execute mocha from your path where is installed, in my case inside of MagicMirror directorio. Example of running the specific unit test for calendar functions.

                                      NODE_ENV=test ./node_modules/mocha/bin/mocha tests/unit/functions/calendar_spec.js

                                      Result:

                                        Functions into modules/default/calendar/calendar.js
                                          capFirst
                                            ✓ for 'rodrigo' should return 'Rodrigo'
                                            ✓ for '123m' should return '123m'
                                            ✓ for 'magic mirror' should return 'Magic mirror'
                                            ✓ for ',a' should return ',a'
                                            ✓ for 'ñandú' should return 'Ñandú'
                                          shorten
                                            ✓ for ' String with whitespace at the beginning that needs trimming' should return 'String with whit…'
                                            ✓ for 'long string that needs shortening' should return 'long string that…'
                                            ✓ for 'short string' should return 'short string'
                                            ✓ for 'long string with no maxLength defined' should return 'long string with no maxLength defined'
                                            ✓ should return an empty string if shorten is called with a non-string
                                            ✓ should not shorten the string if shorten is called with a non-number maxLength
                                            ✓ should wrap the string instead of shorten it if shorten is called with wrapEvents = true (with maxLength defined as 20)
                                            ✓ should wrap the string instead of shorten it if shorten is called with wrapEvents = true (without maxLength defined, default 25)
                                      
                                      
                                        13 passing (29ms)
                                      

                                      If need something is not clear let me know.

                                      Easy module development with MagicMirror Module Template

                                      1 Reply Last reply Reply Quote 1

                                      Hello! It looks like you're interested in this conversation, but you don't have an account yet.

                                      Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

                                      With your input, this post could be even better 💗

                                      Register Login
                                      • 1
                                      • 2
                                      • 3
                                      • 2 / 3
                                      • First post
                                        Last post
                                      Enjoying MagicMirror? Please consider a donation!
                                      MagicMirror created by Michael Teeuw.
                                      Forum managed by Sam, technical setup by Karsten.
                                      This forum is using NodeBB as its core | Contributors
                                      Contact | Privacy Policy