signal-desktop/test/test.js

54 lines
1.3 KiB
JavaScript
Raw Normal View History

2023-01-03 19:55:46 +00:00
// Copyright 2014 Signal Messenger, LLC
2020-10-30 20:34:04 +00:00
// SPDX-License-Identifier: AGPL-3.0-only
/*
* global helpers for tests
*/
2023-01-13 00:24:59 +00:00
mocha.setup('bdd');
2022-09-01 18:56:25 +00:00
mocha.setup({ timeout: 10000 });
window.Events = {
getThemeSetting: () => 'light',
};
/* Delete the database before running any tests */
before(async () => {
await window.testUtilities.initialize();
2019-01-14 21:49:58 +00:00
await window.storage.fetch();
});
2023-01-13 00:24:59 +00:00
window.testUtilities.prepareTests();
delete window.testUtilities.prepareTests;
window.textsecure.storage.protocol = window.getSignalProtocolStore();
2023-01-13 00:24:59 +00:00
!(function () {
class Reporter extends Mocha.reporters.HTML {
constructor(runner, options) {
super(runner, options);
2024-06-28 00:22:06 +00:00
runner.on('pass', test => window.testUtilities.onTestEvent({
type: 'pass',
title: test.titlePath(),
2024-07-22 19:27:09 +00:00
duration: test.duration,
2024-06-28 00:22:06 +00:00
}));
runner.on('fail', (test, error) => window.testUtilities.onTestEvent({
type: 'fail',
title: test.titlePath(),
error: error?.stack || String(error),
}));
runner.on('end', () => window.testUtilities.onTestEvent({ type: 'end' }));
2023-01-13 00:24:59 +00:00
}
}
mocha.reporter(Reporter);
2024-06-28 00:22:06 +00:00
mocha.setup(window.testUtilities.setup);
2023-01-13 00:24:59 +00:00
mocha.run();
})();
window.getPreferredSystemLocales = () => ['en'];
window.getLocaleOverride = () => null;