2021-04-02 02:35:26 +03:00
|
|
|
/**
|
|
|
|
* Copyright (c) Microsoft Corporation.
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
2021-04-07 02:09:54 +03:00
|
|
|
import * as folio from 'folio';
|
2021-04-02 02:35:26 +03:00
|
|
|
import * as path from 'path';
|
|
|
|
import { test as pageTest } from './pageTest';
|
2021-04-29 21:11:32 +03:00
|
|
|
import { AndroidEnv, androidTest } from './androidTest';
|
|
|
|
import type { BrowserContext } from '../../index';
|
2021-04-02 02:35:26 +03:00
|
|
|
|
2021-04-07 02:09:54 +03:00
|
|
|
const config: folio.Config = {
|
2021-04-02 02:35:26 +03:00
|
|
|
testDir: path.join(__dirname, '..'),
|
2021-04-07 18:07:31 +03:00
|
|
|
outputDir: path.join(__dirname, '..', '..', 'test-results'),
|
2021-04-02 02:35:26 +03:00
|
|
|
timeout: 120000,
|
2021-04-05 19:18:56 +03:00
|
|
|
globalTimeout: 7200000,
|
|
|
|
workers: 1,
|
2021-04-02 02:35:26 +03:00
|
|
|
};
|
|
|
|
if (process.env.CI) {
|
|
|
|
config.forbidOnly = true;
|
2021-04-05 05:32:14 +03:00
|
|
|
config.retries = 1; // Multiple retries are too slow on Android.
|
2021-04-02 02:35:26 +03:00
|
|
|
}
|
2021-04-07 02:09:54 +03:00
|
|
|
folio.setConfig(config);
|
|
|
|
|
|
|
|
if (process.env.CI) {
|
|
|
|
folio.setReporters([
|
|
|
|
new folio.reporters.dot(),
|
2021-04-07 18:07:31 +03:00
|
|
|
new folio.reporters.json({ outputFile: path.join(__dirname, '..', '..', 'test-results', 'report.json') }),
|
2021-04-07 02:09:54 +03:00
|
|
|
]);
|
|
|
|
}
|
2021-04-02 02:35:26 +03:00
|
|
|
|
2021-04-29 21:11:32 +03:00
|
|
|
class AndroidPageEnv extends AndroidEnv {
|
|
|
|
private _context?: BrowserContext;
|
|
|
|
|
|
|
|
async beforeAll(args: any, workerInfo: folio.WorkerInfo) {
|
|
|
|
await super.beforeAll(args, workerInfo);
|
|
|
|
this._context = await this._device!.launchBrowser();
|
|
|
|
}
|
|
|
|
|
|
|
|
async beforeEach(args: any, testInfo: folio.TestInfo) {
|
|
|
|
const result = await super.beforeEach(args, testInfo);
|
|
|
|
const page = await this._context!.newPage();
|
2021-04-30 23:26:13 +03:00
|
|
|
return { ...result, browserVersion: this._browserVersion, browserMajorVersion: this._browserMajorVersion, page, isAndroid: true, isElectron: false };
|
2021-04-29 21:11:32 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
async afterEach({}, testInfo: folio.TestInfo) {
|
|
|
|
for (const page of this._context!.pages())
|
|
|
|
await page.close();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const envConfig = {
|
|
|
|
tag: 'android',
|
|
|
|
options: {
|
|
|
|
mode: 'default' as const,
|
2021-04-30 23:26:13 +03:00
|
|
|
browserName: 'chromium' as const,
|
2021-04-29 21:11:32 +03:00
|
|
|
loopback: '10.0.2.2',
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
pageTest.runWith(envConfig, new AndroidPageEnv());
|
|
|
|
androidTest.runWith(envConfig);
|