-
-
Notifications
You must be signed in to change notification settings - Fork 129
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
344f4cb
commit 8001704
Showing
5 changed files
with
127 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
--- | ||
title: Debugging | ||
--- | ||
|
||
# Core Development Documentation: Debugging | ||
|
||
Tips and tricks for debugging MagicMirror², | ||
|
||
## Breakpoints | ||
|
||
Node.js has support for [built-in breakpoints](https://nodejs.org/api/debugger.html), or [VSCode](https://code.visualstudio.com/) allows for | ||
visual breakpoints and inspecting of objects. | ||
|
||
## Date | ||
|
||
It can be very useful to set the current date to debug calendar issues. In order to do this, override `Date.now` with a lambda in *config/config.js*: | ||
|
||
```js | ||
Date.now = () => new Date('2023-12-31T14:05:32'); | ||
``` | ||
|
||
This will cause every request for the current time to return the specified time, at least for the core and built-in modules. | ||
|
||
**NOTE:** Some modules may use `new Date()` to get the current date/time, though this is not recommended. If this is the case, | ||
the external module will not work correctly for date debugging. | ||
|
||
## Timezone | ||
|
||
The `TZ` environment variable can be used to specify a valid [canonical timezone name](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones) | ||
from the [tz database](https://en.wikipedia.org/wiki/Tz_database). | ||
|
||
Several tests do this, such as this example in *tests/electron/helpers/global-setup.js*: | ||
|
||
```js | ||
process.env.TZ = "GMT"; | ||
``` | ||
|
||
The *package.json* could also be modified to force a timezone for a given script, such as `start:dev`: | ||
|
||
```json | ||
"start:dev": "TZ=Europe/Madrid ./node_modules/.bin/electron js/electron.js dev" | ||
``` | ||
|
||
Or when running from the command line (Linux example): | ||
```sh | ||
TZ=Europe/Madrid npm run start:dev | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
--- | ||
title: Introduction | ||
--- | ||
|
||
# Core Development Documentation | ||
|
||
This documentation describes core MagicMirror² development. | ||
|
||
## General | ||
|
||
MagicMirror² is a community-driven development effort, and [contributions](../about/contributing.md) are | ||
welcome! | ||
|
||
In general, new features and bug fixes should be tracked against an [issue in the MagicMirror repo](https://github.com/MichMich/MagicMirror/issues). | ||
It is always a good idea to search existing issues to see if a problem you're experiencing has already been reported, | ||
or if someone has already suggested a feature you'd like to propose. Creating or finding an issue also starts the | ||
discussion and helps build consensus around your proposed fix or feature. | ||
|
||
The MagicMirror² core is [developed on GitHub](https://github.com/MichMich/MagicMirror/) out of the | ||
*develop* branch. To begin developing MagicMirror² core, please fork the GitHub project and | ||
create a new branch based off of the *develop* branch. | ||
|
||
When your development is ready for review and testing, create a new *Pull Request* targeting the *develop* branch. | ||
The development team and other contributors will be able to review your changes and provide feedback, and | ||
the test system will run automated tests against your changes. Make sure to mention the issue(s) that your Pull | ||
Request solves. | ||
|
||
## Development Environment | ||
|
||
Although Node.js applications are typically platform-independent, many of the scripts created for MagicMirror² are | ||
Linux-based. While Windows/Mac development is possible, you may run into issues. (Improvements here are welcome!) | ||
|
||
You will need to have [Node.js installed](https://nodejs.org/en/download). When doing Linux development, on newer | ||
distributions Node.js is available from package managers. | ||
|
||
Many Node.js or experienced Javascript developers have an environment that works for them. New developers | ||
to Node.js / Electron can download [VSCode for free](https://code.visualstudio.com/download) and use many extensions available for debugging and developing Javascript. | ||
|
||
Also checkout [Building Node.js Apps with VSCode](https://code.visualstudio.com/docs/nodejs/nodejs-tutorial). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
--- | ||
title: Testing | ||
--- | ||
|
||
# Core Development Documentation: Testing | ||
|
||
Unit tests are important to ensure the quality of the project as changes occur. | ||
|
||
All tests are located in the [*tests* top-level directory](https://github.com/MichMich/MagicMirror/tree/master/tests). | ||
|
||
## Hierarchy of Tests | ||
|
||
Below the *tests* directory are other directories that organize the tests: | ||
|
||
* *configs* - Configuration files for tests. | ||
* *e2e* - End-to-end tests that start and run MagicMirror² in various configurations. | ||
* *electron* - Electron application tests. | ||
* *mocks* - Mock-up data for tests. | ||
* *unit* - Unit tests for utilities and smaller portions of MagicMirror². | ||
* *utils* - Testing utilities. | ||
|
||
## Writing a Test | ||
|
||
Almost all pull requests must have test coverage of changes. Usually, it is easier to find an existing test and | ||
extend it to test your new functionality. | ||
|
||
For example, if you were writing a test for a fix in the Calendar module, you might locate *tests/e2e/modules/calendar_spec.js* | ||
and add an additional test there. | ||
|
||
If you have questions about how to write a test, you can also ask in the [MagicMirror forums](https://forum.magicmirror.builders/). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters