• Recent
  • Tags
  • Unsolved
  • Solved
  • MagicMirror² Repository
  • Documentation
  • 3rd-Party-Modules
  • Donate
  • Discord
  • Register
  • Login
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 36.8k 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.
  • M Offline
    morozgrafix Moderator
    last edited by Jan 30, 2017, 4:48 PM

    I haven’t looked thoroughly at the code and I wanted to suggest setting a default timeout that can be overwritten in individual tests as needed. It may make test code a little bit cleaner and less repetitive.

    Good job getting it going!

    R 1 Reply Last reply Jan 30, 2017, 7:26 PM Reply Quote 0
    • R Offline
      roramirez Core Contributors @morozgrafix
      last edited by Jan 30, 2017, 7:26 PM

      @morozgrafix Yes, I knowed is not more cleaner and repetitive but was the first proof of concept ;)

      Good idea set default timeout. I added two new task in Trello board about you mentioned.

      Easy module development with MagicMirror Module Template

      M 1 Reply Last reply Jan 31, 2017, 6:49 AM Reply Quote 1
      • M Offline
        morozgrafix Moderator @roramirez
        last edited by morozgrafix Jan 31, 2017, 5:40 PM Jan 31, 2017, 6:49 AM

        @roramirez I’ve played a little with test suite and added basic test for clock module. Then I realized that if we want to test different config options for a given module we may need to have to create multiple configs, which may be challenging with current tests directory organization.
        Also I believe that process.env.MM_CONFIG_FILE = "tests/confs/config_name.js" line needs to be moved into before step (seems to work there or it can go into beforeEach if needed). Otherwise when running npm run test:e2e first config that gets picked up seems to persist throughout all of the tests and always used by the app.js.

        I was wondering if structure similar to this makes sense:

        tests
        ├── configs
        │   ├── env.js
        │   └── modules
        │   │   └── clock
        │   │   │   └── clock_12hr.js
        │   │   │   └── clock_24hr.js
        │   │   │   └── clock_analog.js
        │   │   └── helloworld
        │   │       └── helloworld.js
        ├── e2e
        │   ├── env_spec.js
        │   └── modules
        │       ├── clock_spec.js
        │       └── helloworld_spec.js
        ├── functions
        │   └── compare-version_spec.js
        └── global_vars
            └── root_path.js
        

        but this would involve changing app.use("/tests/confs", express.static(path.resolve(global.root_path + "/tests/confs"))); in the server.js to be somewhat dynamic and I’m not very familiar with express on how it can be done. I think that’s easily solved by just changing it to app.use("/tests/configs", express.static(path.resolve(global.root_path + "/tests/configs")));

        R 1 Reply Last reply Jan 31, 2017, 3:54 PM Reply Quote 0
        • R Offline
          roramirez Core Contributors @morozgrafix
          last edited by Jan 31, 2017, 3:54 PM

          @morozgrafix Seem good sense going to a refactor of the structure.

          I think we can take two way acord you mentioned.

          1.- Include your test for clock module with new format for name and respective directories
          2.- Do it the refactor to all tests that remain.

          I really like see how you resolve the multiples instances configuration in a one tests file.

          Easy module development with MagicMirror Module Template

          M 1 Reply Last reply Jan 31, 2017, 5:26 PM Reply Quote 0
          • M Offline
            morozgrafix Moderator @roramirez
            last edited by Jan 31, 2017, 5:26 PM

            @roramirez cool thanks. I have it all ready on my fork. Will submit PR for review.

            1 Reply Last reply Reply Quote 0
            • Q Offline
              qistoph
              last edited by Feb 2, 2017, 12:25 PM

              Two commits I’ve worked on for the testing.

              1. Check keys in the translation files. Produces errors currently, so I’ve added .skip.
                https://github.com/qistoph/MagicMirror/commit/123392c54934e49a397d586c1fb8dbcc4cc5d12b

              2. To prevent loading app.js from corrupting the Mocha test environment, I suggest to execute the app.js in a virtual environment. This can also serve as an example for future test cases where code needs to be executed in the global namespace.
                https://github.com/qistoph/MagicMirror/commit/cd8bee1371ffc6cce7b7bf44f85cd03705e4c1bd

              Any thoughts before I submit a PR?

              S R 2 Replies Last reply Feb 2, 2017, 12:31 PM Reply Quote 1
              • S Offline
                strawberry 3.141 Project Sponsor Module Developer @qistoph
                last edited by Feb 2, 2017, 12:31 PM

                @qistoph i like the idea of the sandbox

                is there a way to just warn instead of error for missing translation keys?

                Please create a github issue if you need help, so I can keep track

                Q 1 Reply Last reply Feb 2, 2017, 1:54 PM Reply Quote 0
                • Q Offline
                  qistoph @strawberry 3.141
                  last edited by Feb 2, 2017, 1:54 PM

                  @strawberry-3.141
                  How about this?
                  https://github.com/qistoph/MagicMirror/commit/406ae4e8c37cbf7e31c89f5341d7715bacbcf0d2

                  			try {
                  				expect(fileKeys).to.deep.equal(baseKeys);
                  			} catch(e) {
                  				if (e instanceof chai.AssertionError) {
                  					this.skip();
                  				} else {
                  					throw e;
                  				}
                  			}
                  
                  1 Reply Last reply Reply Quote 0
                  • R Offline
                    roramirez Core Contributors @qistoph
                    last edited by Feb 2, 2017, 3:14 PM

                    @qistoph Nice work. Related with your first point there a discussion about translations of JSON file.
                    https://github.com/MichMich/MagicMirror/pull/679

                    Easy module development with MagicMirror Module Template

                    1 Reply Last reply Reply Quote 0
                    • R Offline
                      roramirez Core Contributors
                      last edited by Feb 10, 2017, 10:58 PM

                      Hi Guys,

                      Today I’ve playing with test suite I something going me crazy

                      I create the follow test
                      https://github.com/roramirez/MagicMirror/commit/88f1f6bbd4fe6d7f3b9391993d207c7b9ebfb2e9

                      Two check on same test case. On my enviroment ever but ever give me fail

                      smirror :: ~/MagicMirror ‹without-modules-test*› » ./node_modules/mocha/bin/mocha tests/e2e/without_modules.js
                      
                      
                        Check configuration without modules
                          ✓ Show the message create file config (83ms)
                          1) Show the message create file config 2
                      
                      
                        1 passing (6s)
                        1 failing
                      
                        1) Check configuration without modules Show the message create file config 2:
                           Error: An element could not be located on the page using the given search parameters ("#module_2_helloworld .module-content").
                            at elements("#module_2_helloworld .module-content") - getText.js:18:17
                            at execute(, "isLoading", , "require") - api.js:350:19
                      

                      I pushed a sample for shared with you and these are passing on Travis
                      https://travis-ci.org/roramirez/MagicMirror/jobs/200521954

                      Anybody can give me some light?

                      Easy module development with MagicMirror Module Template

                      1 Reply Last reply Reply Quote 0
                      • 1
                      • 2
                      • 3
                      • 4
                      • 5
                      • 2 / 5
                      • 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