MagicMirror/tests/electron/modules/weather_spec.js
Karsten Hassel 3fa2b96054
cleanup and try to stabilize weather e2e tests (#3848)
The weather e2e tests are failing sometimes, failing is not really
reproducable.

After changing `updateDom(0)` to `updateDom(300)` in `weather.js` it
seems to work (we will se if it really works in the long term).

This PR contains some other weather e2e changes/cleanups/simplifying.
2025-07-20 08:23:52 +02:00

40 lines
1.3 KiB
JavaScript

const helpers = require("../helpers/global-setup");
const weatherHelper = require("../helpers/weather-setup");
const { cleanupMockData } = require("../../utils/weather_mocker");
const CURRENT_WEATHER_CONFIG = "tests/configs/modules/weather/currentweather_default.js";
const SUNRISE_DATE = "13 Jan 2019 00:30:00 GMT";
const SUNSET_DATE = "13 Jan 2019 12:30:00 GMT";
const SUN_EVENT_SELECTOR = ".weather .normal.medium span:nth-child(4)";
const EXPECTED_SUNRISE_TEXT = "7:00 am";
const EXPECTED_SUNSET_TEXT = "3:45 pm";
describe("Weather module", () => {
afterEach(async () => {
await helpers.stopApplication();
cleanupMockData();
});
describe("Current weather with sunrise", () => {
beforeAll(async () => {
await weatherHelper.startApp(CURRENT_WEATHER_CONFIG, SUNRISE_DATE);
});
it("should render sunrise", async () => {
const isSunriseRendered = await weatherHelper.getText(SUN_EVENT_SELECTOR, EXPECTED_SUNRISE_TEXT);
expect(isSunriseRendered).toBe(true);
});
});
describe("Current weather with sunset", () => {
beforeAll(async () => {
await weatherHelper.startApp(CURRENT_WEATHER_CONFIG, SUNSET_DATE);
});
it("should render sunset", async () => {
const isSunsetRendered = await weatherHelper.getText(SUN_EVENT_SELECTOR, EXPECTED_SUNSET_TEXT);
expect(isSunsetRendered).toBe(true);
});
});
});