set Timezone Europe/Berlin in unit tests (#3087)

needed for new formatTime unit tests.

Avoiding ugly TZ setting in github workflows, see
https://github.com/MichMich/MagicMirror/pull/3073
This commit is contained in:
Karsten Hassel 2023-04-08 08:55:43 +02:00 committed by GitHub
parent 32192d1698
commit 09f117c3d9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 8 additions and 16 deletions

View File

@ -22,12 +22,6 @@ jobs:
steps:
- name: "Checkout code"
uses: actions/checkout@v3
- name: "Set timezone"
uses: szenius/set-timezone@v1.2
with:
timezoneLinux: "Europe/Berlin"
timezoneMacos: "Europe/Berlin"
timezoneWindows: "Europe/Berlin"
- name: "Use Node.js ${{ matrix.node-version }}"
uses: actions/setup-node@v3
with:

View File

@ -19,12 +19,6 @@ jobs:
steps:
- name: "Checkout code"
uses: actions/checkout@v3
- name: "Set timezone"
uses: szenius/set-timezone@v1.2
with:
timezoneLinux: "Europe/Berlin"
timezoneMacos: "Europe/Berlin"
timezoneWindows: "Europe/Berlin"
- name: "Install dependencies and run coverage"
run: |
Xvfb :99 -screen 0 1024x768x16 &

View File

@ -12,6 +12,7 @@ _This release is scheduled to be released on 2023-07-01._
### Added
- Added tests for severonly
- Set Timezone `Europe/Berlin` in unit tests (needed for new formatTime tests)
### Removed

View File

@ -6,23 +6,24 @@ module.exports = async () => {
projects: [
{
displayName: "unit",
globalSetup: "<rootDir>/tests/unit/helpers/global-setup.js",
moduleNameMapper: {
logger: "<rootDir>/js/logger.js"
},
testMatch: ["**/tests/unit/**/*.[jt]s?(x)"],
testPathIgnorePatterns: ["<rootDir>/tests/unit/mocks"]
testPathIgnorePatterns: ["<rootDir>/tests/unit/mocks", "<rootDir>/tests/unit/helpers"]
},
{
displayName: "electron",
testMatch: ["**/tests/electron/**/*.[jt]s?(x)"],
testPathIgnorePatterns: ["<rootDir>/tests/electron/helpers/"]
testPathIgnorePatterns: ["<rootDir>/tests/electron/helpers"]
},
{
displayName: "e2e",
setupFilesAfterEnv: ["<rootDir>/tests/e2e/helpers/mock-console.js"],
testMatch: ["**/tests/e2e/**/*.[jt]s?(x)"],
modulePaths: ["<rootDir>/js/"],
testPathIgnorePatterns: ["<rootDir>/tests/e2e/helpers/", "<rootDir>/tests/e2e/mocks"]
testPathIgnorePatterns: ["<rootDir>/tests/e2e/helpers", "<rootDir>/tests/e2e/mocks"]
}
],
collectCoverageFrom: ["./clientonly/**/*.js", "./js/**/*.js", "./modules/default/**/*.js", "./serveronly/**/*.js"],

View File

@ -0,0 +1,3 @@
module.exports = async () => {
process.env.TZ = "Europe/Berlin";
};

View File

@ -116,7 +116,6 @@ describe("Default modules utils tests", () => {
beforeAll(() => {
jest.useFakeTimers();
moment.tz.setDefault("Europe/Berlin");
});
beforeEach(async () => {