signal-desktop/libtextsecure/test/_test.js

71 lines
1.6 KiB
JavaScript
Raw Normal View History

2020-10-30 20:34:04 +00:00
// Copyright 2015-2020 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
/* global chai */
2018-11-02 18:02:53 +00:00
2018-05-02 16:51:22 +00:00
mocha.setup('bdd');
window.assert = chai.assert;
2018-11-02 18:02:53 +00:00
const OriginalReporter = mocha._reporter;
const SauceReporter = function Constructor(runner) {
2018-11-02 18:02:53 +00:00
const failedTests = [];
runner.on('end', () => {
window.mochaResults = runner.stats;
window.mochaResults.reports = failedTests;
});
runner.on('fail', (test, err) => {
const flattenTitles = item => {
const titles = [];
while (item.parent.title) {
titles.push(item.parent.title);
// eslint-disable-next-line no-param-reassign
item = item.parent;
}
return titles.reverse();
};
failedTests.push({
name: test.title,
result: false,
message: err.message,
stack: err.stack,
titles: flattenTitles(test),
});
2018-11-02 18:02:53 +00:00
});
2018-11-02 18:02:53 +00:00
// eslint-disable-next-line no-new
new OriginalReporter(runner);
};
2018-11-02 18:02:53 +00:00
SauceReporter.prototype = OriginalReporter.prototype;
2018-11-02 18:02:53 +00:00
mocha.reporter(SauceReporter);
/*
* global helpers for tests
*/
window.Whisper = window.Whisper || {};
window.Whisper.events = {
on() {},
trigger() {},
};
2021-03-04 21:44:57 +00:00
before(async () => {
try {
window.SignalWindow.log.info('Initializing SQL in renderer');
const isTesting = true;
await window.sqlInitializer.initialize(isTesting);
window.SignalWindow.log.info('SQL initialized in renderer');
2021-03-04 21:44:57 +00:00
} catch (err) {
window.SignalWindow.log.error(
2021-03-04 21:44:57 +00:00
'SQL failed to initialize',
err && err.stack ? err.stack : err
);
}
2021-09-15 18:45:22 +00:00
await window.Signal.Util.initializeMessageCounter();
2021-03-04 21:44:57 +00:00
});