Read the statement by Michael Teeuw here.
Test suite for MagicMirror²
-
@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 thatprocess.env.MM_CONFIG_FILE = "tests/confs/config_name.js"line needs to be moved intobeforestep (seems to work there or it can go intobeforeEachif needed). Otherwise when runningnpm run test:e2efirst config that gets picked up seems to persist throughout all of the tests and always used by theapp.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.jsbut this would involve changingI think that’s easily solved by just changing it toapp.use("/tests/confs", express.static(path.resolve(global.root_path + "/tests/confs")));in theserver.jsto be somewhat dynamic and I’m not very familiar with express on how it can be done.app.use("/tests/configs", express.static(path.resolve(global.root_path + "/tests/configs"))); -
@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.
-
@roramirez cool thanks. I have it all ready on my fork. Will submit PR for review.
-
Two commits I’ve worked on for the testing.
-
Check keys in the translation files. Produces errors currently, so I’ve added
.skip.
https://github.com/qistoph/MagicMirror/commit/123392c54934e49a397d586c1fb8dbcc4cc5d12b -
To prevent loading
app.jsfrom corrupting the Mocha test environment, I suggest to execute theapp.jsin a virtual environment. This can also serve as an example for future test cases where code needs to be executed in theglobalnamespace.
https://github.com/qistoph/MagicMirror/commit/cd8bee1371ffc6cce7b7bf44f85cd03705e4c1bd
Any thoughts before I submit a PR?
-
-
@qistoph i like the idea of the sandbox
is there a way to just warn instead of error for missing translation keys?
-
@strawberry-3.141
How about this?
https://github.com/qistoph/MagicMirror/commit/406ae4e8c37cbf7e31c89f5341d7715bacbcf0d2try { expect(fileKeys).to.deep.equal(baseKeys); } catch(e) { if (e instanceof chai.AssertionError) { this.skip(); } else { throw e; } } -
@qistoph Nice work. Related with your first point there a discussion about translations of JSON file.
https://github.com/MichMich/MagicMirror/pull/679 -
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/88f1f6bbd4fe6d7f3b9391993d207c7b9ebfb2e9Two 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:19I pushed a sample for shared with you and these are passing on Travis
https://travis-ci.org/roramirez/MagicMirror/jobs/200521954Anybody can give me some light?
-
Weird… don’t see anything wrong with your code and it also runs fine on my machine…
Probably not really helpful, though, sorry
-
@qistoph I’ll test in other instance.
What S.O are you using?
-
@roramirez what do you mean by “S.O”?
-
@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.
-
@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.
-
-
Hey guys,
I pushed up a small refactoring for tests.
https://github.com/MichMich/MagicMirror/pull/728This 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)
-
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/db87f9e15b79827e947316c3ffba5b4ca49854b7The 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?
-
I fixed before mentioned https://github.com/roramirez/MagicMirror/commit/2a94ee55ccb8fa06f4d07c2a67307b5ed0a659a3
:)
-
The last build of today.

-
I mention this here if someone can help
If use moment-timezone for a test this fail
-
Hi Guys, are you still alive?
Sometimes the build failed, an example here
https://travis-ci.org/MichMich/MagicMirror/jobs/227577643Someone have some idea how to fix this?
cc @qistoph @strawberry-3-141 @morozgrafix
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