Welcome to mirror list, hosted at ThFree Co, Russian Federation.

run-tests.js « screenshot-testing « lib « tests - github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 7dc4c808883afc24b8971293ab8cc96ef81f6b0c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/*!
 * Matomo - free/libre analytics platform
 *
 * UI test runner script
 *
 * @link https://matomo.org
 * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
 */

process.env.NODE_TLS_REJECT_UNAUTHORIZED = 0; // ignore ssl errors

const path = require('path');
const puppeteer = require('puppeteer');
const setUpGlobals = require('./support/globals.js');
const Mocha = require('mocha');
const chai = require('chai');
const chaiFiles = require('chai-files');
require('./support/fs-extras');

main();

async function main() {
    const browser = await puppeteer.launch({ args: ['--no-sandbox', '--ignore-certificate-errors'] });
    const webpage = await browser.newPage();
    await webpage._client.send('Animation.setPlaybackRate', { playbackRate: 50 }); // make animations run 50 times faster, so we don't have to wait as much

    // required modules
    let config = require("./../../UI/config.dist");
    try {
        config = Object.assign({}, config, require("./../../UI/config"));
    } catch (e) {
        // ignore
    }

    // assume the URI points to a folder and make sure Piwik won't cut off the last path segment
    if (config.phpServer.REQUEST_URI.slice(-1) !== '/') {
        config.phpServer.REQUEST_URI += '/';
    }

    const originalUserAgent = await browser.userAgent();

    setUpGlobals(config, webpage, originalUserAgent);

    mocha = new Mocha({
        ui: 'bdd',
        reporter: config.reporter,
        bail: false,
        useColors: true,
        timeout: options.timeout || 240000,
    });

    const imageAssert = require('./support/chai-extras');
    chai.use(imageAssert());
    chai.use(chaiFiles);

    // run script
    if (options['help']) {
        app.printHelpAndExit();
    }

    // the mocha-super-suite imports the individual specs. kept for expedience when converting to chromium
    // headless.
    mocha.addFile(path.join(__dirname, 'mocha-super-suite.js'));

    app.runTests(mocha)
}