@telefonica/acceptance-testing 4.1.0 → 5.0.0-beta2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +21 -2
- package/dist/config.d.ts +22 -0
- package/dist/config.js +57 -0
- package/dist/constants.d.ts +1 -0
- package/dist/constants.js +4 -0
- package/dist/coverage.d.ts +15 -15
- package/dist/coverage.js +119 -0
- package/dist/index.d.ts +86 -91
- package/dist/index.js +424 -8
- package/dist/jest-puppeteer.config.d.ts +1 -0
- package/{jest-puppeteer-config.js → dist/jest-puppeteer.config.js} +19 -60
- package/dist/utils.d.ts +12 -8
- package/dist/utils.js +43 -0
- package/dist/wsl.d.ts +6 -0
- package/dist/wsl.js +49 -0
- package/jest-puppeteer.config.js +1 -0
- package/package.json +15 -13
- package/dist/acceptance-testing.cjs.development.js +0 -1472
- package/dist/acceptance-testing.cjs.development.js.map +0 -1
- package/dist/acceptance-testing.cjs.production.min.js +0 -2
- package/dist/acceptance-testing.cjs.production.min.js.map +0 -1
- package/dist/acceptance-testing.esm.js +0 -1453
- package/dist/acceptance-testing.esm.js.map +0 -1
package/README.md
CHANGED
|
@@ -51,13 +51,15 @@ If you want to autostart a server before running the acceptance tests, you can c
|
|
|
51
51
|
}
|
|
52
52
|
```
|
|
53
53
|
|
|
54
|
-
Additionally, you can include
|
|
54
|
+
Additionally, you can include `host`, `protocol` and `path` parameters. The path will be used to check if the
|
|
55
|
+
server is ready:
|
|
55
56
|
|
|
56
57
|
```json
|
|
57
58
|
{
|
|
58
59
|
"acceptanceTests": {
|
|
59
60
|
"ciServer": {
|
|
60
61
|
"command": "yarn dev",
|
|
62
|
+
"host": "127.0.0.1",
|
|
61
63
|
"port": 3000,
|
|
62
64
|
"path": "api/health",
|
|
63
65
|
"protocol": "https"
|
|
@@ -66,6 +68,13 @@ Additionally, you can include path and protocol parameters, that will be used to
|
|
|
66
68
|
}
|
|
67
69
|
```
|
|
68
70
|
|
|
71
|
+
The `command` can be overridden by setting the `ACCEPTANCE_TESTING_SERVER_COMMAND` environment variable. For
|
|
72
|
+
example:
|
|
73
|
+
|
|
74
|
+
```sh
|
|
75
|
+
ACCEPTANCE_TESTING_SERVER_COMMAND="yarn start" yarn test-acceptance
|
|
76
|
+
```
|
|
77
|
+
|
|
69
78
|
#### `protocol`
|
|
70
79
|
|
|
71
80
|
Type: `string`, (`https`, `http`, `tcp`, `socket`) defaults to `tcp` or `http` if `path` is set.
|
|
@@ -254,7 +263,8 @@ await elementHandle.uploadFile(prepareFile('/path/to/file'));
|
|
|
254
263
|
|
|
255
264
|
## Collecting coverage
|
|
256
265
|
|
|
257
|
-
Set the `
|
|
266
|
+
Set the `ACCEPTANCE_TESTING_COLLECT_COVERAGE` environment variable to enable coverage collection or run with
|
|
267
|
+
the `--coverage` flag.
|
|
258
268
|
|
|
259
269
|
The code must be instrumented with [nyc](https://github.com/istanbuljs/nyc/blob/main/docs/instrument.md),
|
|
260
270
|
[babel-plugin-istanbul](https://github.com/istanbuljs/babel-plugin-istanbul) or any
|
|
@@ -326,6 +336,9 @@ page.on('pageerror', (err) => {
|
|
|
326
336
|
});
|
|
327
337
|
```
|
|
328
338
|
|
|
339
|
+
Page errors can be ignored by setting the `ACCEPTANCE_TESTING_IGNORE_PAGE_ERRORS` environment variable. Do not
|
|
340
|
+
enable this by default as it could hide legitimate errors in your tests.
|
|
341
|
+
|
|
329
342
|
### Executing with --ui fails (Linux)
|
|
330
343
|
|
|
331
344
|
If your desktop environment uses Wayland, you may see the following error when running the tests with the
|
|
@@ -350,3 +363,9 @@ To workaround this issue, you can install a newer Chrome in the repo where you a
|
|
|
350
363
|
|
|
351
364
|
Note that this browser will only be used when running the tests with the `--ui` flag. In headless mode, the
|
|
352
365
|
dockerized chromium will be used.
|
|
366
|
+
|
|
367
|
+
### Debug mode
|
|
368
|
+
|
|
369
|
+
If you need additional logs to debug the `acceptance-testing` library, you can set the
|
|
370
|
+
`ACCEPTANCE_TESTING_DEBUG` environment variable or run the `acceptance-testing` command with the `--debug`
|
|
371
|
+
flag.
|
package/dist/config.d.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
type Config = {
|
|
2
|
+
debug: boolean;
|
|
3
|
+
isCi: boolean;
|
|
4
|
+
isHeadless: boolean;
|
|
5
|
+
isLocal: boolean;
|
|
6
|
+
coveragePath: string;
|
|
7
|
+
coverageUrls: string[];
|
|
8
|
+
collectCoverage: boolean;
|
|
9
|
+
/** complete list of server options: https://www.npmjs.com/package/jest-dev-server */
|
|
10
|
+
server: {
|
|
11
|
+
command: string;
|
|
12
|
+
host?: string;
|
|
13
|
+
port?: number;
|
|
14
|
+
path?: string;
|
|
15
|
+
usedPortAction?: 'error' | 'ignore';
|
|
16
|
+
launchTimeout?: number;
|
|
17
|
+
protocol?: 'http' | 'tcp';
|
|
18
|
+
debug?: boolean;
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
export declare const getConfig: () => Config;
|
|
22
|
+
export {};
|
package/dist/config.js
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.getConfig = void 0;
|
|
7
|
+
const find_root_1 = __importDefault(require("find-root"));
|
|
8
|
+
const fs_1 = __importDefault(require("fs"));
|
|
9
|
+
const path_1 = __importDefault(require("path"));
|
|
10
|
+
const IS_CI = !!process.env.CI || process.argv.includes('--ci');
|
|
11
|
+
const IS_DEBUG = !!process.env.ACCEPTANCE_TESTING_DEBUG || process.argv.includes('--debug');
|
|
12
|
+
const DEFAULT_CONFIG = {
|
|
13
|
+
debug: IS_DEBUG,
|
|
14
|
+
isCi: IS_CI,
|
|
15
|
+
isLocal: !IS_CI,
|
|
16
|
+
isHeadless: !!process.env.HEADLESS,
|
|
17
|
+
coveragePath: 'reports/coverage-acceptance',
|
|
18
|
+
collectCoverage: !!process.env.ACCEPTANCE_TESTING_COLLECT_COVERAGE || process.argv.includes('--coverage'),
|
|
19
|
+
coverageUrls: [],
|
|
20
|
+
server: {
|
|
21
|
+
debug: IS_DEBUG,
|
|
22
|
+
command: 'tail -f /dev/null',
|
|
23
|
+
host: '127.0.0.1',
|
|
24
|
+
usedPortAction: IS_CI ? 'error' : 'ignore', // In dev, if port is already taken, assume server is already running.
|
|
25
|
+
launchTimeout: 60000,
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
const PACKAGE_JSON_CONFIG = (() => {
|
|
29
|
+
const rootDir = (0, find_root_1.default)(process.cwd());
|
|
30
|
+
const packageJson = JSON.parse(fs_1.default.readFileSync(path_1.default.join(rootDir, 'package.json'), 'utf-8'));
|
|
31
|
+
const acceptanceTestsConfig = packageJson.acceptanceTests || {};
|
|
32
|
+
const server = (IS_CI ? acceptanceTestsConfig.ciServer : acceptanceTestsConfig.devServer) ||
|
|
33
|
+
acceptanceTestsConfig.server;
|
|
34
|
+
// not needed in the final config
|
|
35
|
+
delete acceptanceTestsConfig.ciServer;
|
|
36
|
+
delete acceptanceTestsConfig.devServer;
|
|
37
|
+
return {
|
|
38
|
+
...acceptanceTestsConfig,
|
|
39
|
+
server,
|
|
40
|
+
};
|
|
41
|
+
})();
|
|
42
|
+
const CONFIG = (() => {
|
|
43
|
+
const config = {
|
|
44
|
+
...DEFAULT_CONFIG,
|
|
45
|
+
...PACKAGE_JSON_CONFIG,
|
|
46
|
+
server: {
|
|
47
|
+
...DEFAULT_CONFIG.server,
|
|
48
|
+
...PACKAGE_JSON_CONFIG.server,
|
|
49
|
+
},
|
|
50
|
+
};
|
|
51
|
+
config.server.protocol = config.server.path ? 'http' : 'tcp';
|
|
52
|
+
// overrides
|
|
53
|
+
config.server.command = process.env.ACCEPTANCE_TESTING_SERVER_COMMAND || config.server.command;
|
|
54
|
+
return config;
|
|
55
|
+
})();
|
|
56
|
+
const getConfig = () => CONFIG;
|
|
57
|
+
exports.getConfig = getConfig;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const LINUX_DOCKER_HOST_IP = "172.17.0.1";
|
package/dist/coverage.d.ts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
export declare const getRootPath: () => any;
|
|
2
|
-
/**
|
|
3
|
-
* Assumes the code was instrumented with istanbul/nyc and the coverage report stored in `window.__coverage__`.
|
|
4
|
-
* If not, this function does nothing.
|
|
5
|
-
*/
|
|
6
|
-
export declare const collectFrontendCoverage: ({ coveragePath }: {
|
|
7
|
-
coveragePath: string;
|
|
8
|
-
}) => Promise<void>;
|
|
9
|
-
/**
|
|
10
|
-
* Collects backend coverage reports from the provided URLs and stores them in the coverage folder
|
|
11
|
-
*/
|
|
12
|
-
export declare const collectBackendCoverage: ({ coveragePath, coverageUrls, }: {
|
|
13
|
-
coveragePath: string;
|
|
14
|
-
coverageUrls: Array<string>;
|
|
15
|
-
}) => Promise<void>;
|
|
1
|
+
export declare const getRootPath: () => any;
|
|
2
|
+
/**
|
|
3
|
+
* Assumes the code was instrumented with istanbul/nyc and the coverage report stored in `window.__coverage__`.
|
|
4
|
+
* If not, this function does nothing.
|
|
5
|
+
*/
|
|
6
|
+
export declare const collectFrontendCoverage: ({ coveragePath }: {
|
|
7
|
+
coveragePath: string;
|
|
8
|
+
}) => Promise<void>;
|
|
9
|
+
/**
|
|
10
|
+
* Collects backend coverage reports from the provided URLs and stores them in the coverage folder
|
|
11
|
+
*/
|
|
12
|
+
export declare const collectBackendCoverage: ({ coveragePath, coverageUrls, }: {
|
|
13
|
+
coveragePath: string;
|
|
14
|
+
coverageUrls: Array<string>;
|
|
15
|
+
}) => Promise<void>;
|
package/dist/coverage.js
ADDED
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.collectBackendCoverage = exports.collectFrontendCoverage = exports.getRootPath = void 0;
|
|
7
|
+
const path_1 = __importDefault(require("path"));
|
|
8
|
+
const fs_1 = __importDefault(require("fs"));
|
|
9
|
+
const utils_1 = require("./utils");
|
|
10
|
+
const istanbul_lib_coverage_1 = __importDefault(require("istanbul-lib-coverage"));
|
|
11
|
+
const getGlobalPage = () => global.page;
|
|
12
|
+
const getRootPath = () => {
|
|
13
|
+
const rootPath = expect.getState().snapshotState._rootDir;
|
|
14
|
+
if (!rootPath) {
|
|
15
|
+
throw new Error('Root path not found');
|
|
16
|
+
}
|
|
17
|
+
return rootPath;
|
|
18
|
+
};
|
|
19
|
+
exports.getRootPath = getRootPath;
|
|
20
|
+
/**
|
|
21
|
+
* We want to clear coverage files from previous runs, but at this point it is not easy because each
|
|
22
|
+
* worker runs a different instance of this script, so we can't just clear the coverage folder at
|
|
23
|
+
* the beginning of the test run.
|
|
24
|
+
*
|
|
25
|
+
* The solution is to remove the coverage folder when the stored ppid (parent process id) is
|
|
26
|
+
* different from the current one
|
|
27
|
+
*/
|
|
28
|
+
const prepareCoverageReportPath = ({ coveragePath }) => {
|
|
29
|
+
const ppidFile = path_1.default.join(coveragePath, '.ppid');
|
|
30
|
+
const nycOutputPath = path_1.default.join(coveragePath, '.nyc_output');
|
|
31
|
+
const ppid = process.ppid.toString();
|
|
32
|
+
if (!fs_1.default.existsSync(ppidFile) || fs_1.default.readFileSync(ppidFile, 'utf-8') !== ppid) {
|
|
33
|
+
// the condition is just to make sure we don't remove files outside the repo
|
|
34
|
+
if ((0, exports.getRootPath)() === process.cwd() && path_1.default.normalize(coveragePath).startsWith(process.cwd())) {
|
|
35
|
+
fs_1.default.rmSync(nycOutputPath, { recursive: true, force: true });
|
|
36
|
+
}
|
|
37
|
+
fs_1.default.mkdirSync(nycOutputPath, { recursive: true });
|
|
38
|
+
fs_1.default.writeFileSync(ppidFile, ppid);
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
const workerId = process.env.JEST_WORKER_ID || '0';
|
|
42
|
+
/**
|
|
43
|
+
* Writes the coverage reports into single files, one per each coverage object (path). This makes it easier to merge them.
|
|
44
|
+
* The `workerId` from jest is used to avoid race conditions when multiple workers are running in parallel.
|
|
45
|
+
*/
|
|
46
|
+
const writeCombinedCoverage = (nycOutputPath, coverage) => {
|
|
47
|
+
Object.values(coverage).forEach((value) => {
|
|
48
|
+
if (value && value.path && value.hash) {
|
|
49
|
+
const filename = path_1.default.join(nycOutputPath, `${value.hash}-${workerId}.json`);
|
|
50
|
+
const currentCoverage = { [value.path]: value };
|
|
51
|
+
const previousCoverage = fs_1.default.existsSync(filename)
|
|
52
|
+
? JSON.parse(fs_1.default.readFileSync(filename, 'utf8'))
|
|
53
|
+
: {};
|
|
54
|
+
const mergedCoverage = istanbul_lib_coverage_1.default.createCoverageMap(previousCoverage);
|
|
55
|
+
mergedCoverage.merge(currentCoverage);
|
|
56
|
+
(0, utils_1.debug)('Writing merged coverage:', value.path, value.hash);
|
|
57
|
+
fs_1.default.writeFileSync(filename, JSON.stringify(mergedCoverage.toJSON(), null, 2));
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
(0, utils_1.debug)('Skip write coverage. Missing path or hash:', value);
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
};
|
|
64
|
+
/**
|
|
65
|
+
* Assumes the code was instrumented with istanbul/nyc and the coverage report stored in `window.__coverage__`.
|
|
66
|
+
* If not, this function does nothing.
|
|
67
|
+
*/
|
|
68
|
+
const collectFrontendCoverage = async ({ coveragePath }) => {
|
|
69
|
+
const nycOutputPath = path_1.default.join(coveragePath, '.nyc_output');
|
|
70
|
+
const coverage = await getGlobalPage().evaluate(() => {
|
|
71
|
+
return window.__coverage__;
|
|
72
|
+
});
|
|
73
|
+
if (!coverage) {
|
|
74
|
+
(0, utils_1.debug)('Skipping coverage collection. No coverage found.');
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
(0, utils_1.debug)('Frontend coverage found');
|
|
78
|
+
prepareCoverageReportPath({ coveragePath });
|
|
79
|
+
fs_1.default.mkdirSync(nycOutputPath, { recursive: true });
|
|
80
|
+
writeCombinedCoverage(nycOutputPath, coverage);
|
|
81
|
+
};
|
|
82
|
+
exports.collectFrontendCoverage = collectFrontendCoverage;
|
|
83
|
+
const writeCoverage = (nycOutputPath, nameSuffix, coverage) => {
|
|
84
|
+
Object.values(coverage).forEach((value) => {
|
|
85
|
+
if (value && value.path && value.hash) {
|
|
86
|
+
const filename = path_1.default.join(nycOutputPath, `${value.hash}${nameSuffix}.json`);
|
|
87
|
+
(0, utils_1.debug)('Writing coverage:', value.path, value.hash);
|
|
88
|
+
fs_1.default.writeFileSync(filename, JSON.stringify({ [value.path]: value }, null, 2));
|
|
89
|
+
}
|
|
90
|
+
else {
|
|
91
|
+
(0, utils_1.debug)('Skip write coverage. Missing path or hash:', value);
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
};
|
|
95
|
+
/**
|
|
96
|
+
* Collects backend coverage reports from the provided URLs and stores them in the coverage folder
|
|
97
|
+
*/
|
|
98
|
+
const collectBackendCoverage = async ({ coveragePath, coverageUrls, }) => {
|
|
99
|
+
const nycOutputPath = path_1.default.join(coveragePath, '.nyc_output');
|
|
100
|
+
(0, utils_1.debug)('Collecting backend coverage reports', coverageUrls);
|
|
101
|
+
const serverReports = await Promise.all(coverageUrls.map((url) => fetch(url)
|
|
102
|
+
.then((res) => {
|
|
103
|
+
if (res.ok &&
|
|
104
|
+
res.status === 200 &&
|
|
105
|
+
res.headers.get('content-type')?.includes('application/json')) {
|
|
106
|
+
return res.json();
|
|
107
|
+
}
|
|
108
|
+
(0, utils_1.debug)('Error fetching coverage report:', { url, status: res.status });
|
|
109
|
+
return null;
|
|
110
|
+
})
|
|
111
|
+
.catch(() => {
|
|
112
|
+
(0, utils_1.debug)('Error fetching coverage report:', { url });
|
|
113
|
+
return null;
|
|
114
|
+
})));
|
|
115
|
+
serverReports.forEach((report, index) => {
|
|
116
|
+
writeCoverage(nycOutputPath, `-backend${index}`, report.coverage);
|
|
117
|
+
});
|
|
118
|
+
};
|
|
119
|
+
exports.collectBackendCoverage = collectBackendCoverage;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,91 +1,86 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
declare
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
export declare const
|
|
9
|
-
export
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
declare
|
|
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
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
*
|
|
79
|
-
*
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
*
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
export declare const
|
|
87
|
-
/**
|
|
88
|
-
* A convenience method to defer an expectation
|
|
89
|
-
*/
|
|
90
|
-
export declare const wait: <T>(expectation: () => T | Promise<T>, timeout?: number, interval?: number) => Promise<T>;
|
|
91
|
-
export declare const waitForElementToBeRemoved: (element: ElementHandle<Element>, timeout?: number, interval?: number) => Promise<void>;
|
|
1
|
+
import type { Browser, ClickOptions, ElementHandle, HTTPRequest, Page, ResponseForRequest, ScreenshotOptions, Viewport } from 'puppeteer';
|
|
2
|
+
type CustomScreenshotOptions = ScreenshotOptions & {
|
|
3
|
+
skipNetworkWait?: boolean;
|
|
4
|
+
};
|
|
5
|
+
export declare const getGlobalBrowser: () => Browser;
|
|
6
|
+
export declare const getGlobalPage: () => Page;
|
|
7
|
+
export declare const serverHostName: string;
|
|
8
|
+
export declare const serverPort: number | undefined;
|
|
9
|
+
export interface PageApi extends Omit<Page, 'click' | 'type' | 'select'> {
|
|
10
|
+
clear: (selector: ElementHandle) => Promise<void>;
|
|
11
|
+
type: (selector: ElementHandle, text: string, options?: {
|
|
12
|
+
delay: number;
|
|
13
|
+
}) => Promise<void>;
|
|
14
|
+
click: (selector: ElementHandle, options?: ClickOptions) => Promise<void>;
|
|
15
|
+
select: (selector: ElementHandle, ...values: string[]) => Promise<string[]>;
|
|
16
|
+
screenshot: (options?: CustomScreenshotOptions) => Promise<Buffer | string | void>;
|
|
17
|
+
}
|
|
18
|
+
export declare const getPageApi: (page: Page) => PageApi;
|
|
19
|
+
type RequestMatcherFn = (req: HTTPRequest) => boolean;
|
|
20
|
+
export declare const interceptRequest: (matcher: RequestMatcherFn) => jest.Mock<Partial<ResponseForRequest> | Promise<Partial<ResponseForRequest>>, [HTTPRequest]>;
|
|
21
|
+
type ApiEndpointMock = {
|
|
22
|
+
spyOn<T = any>(path: string, method?: string): jest.Mock<T, [HTTPRequest]>;
|
|
23
|
+
};
|
|
24
|
+
export declare const createApiEndpointMock: ({ origin }?: {
|
|
25
|
+
origin?: string;
|
|
26
|
+
}) => ApiEndpointMock;
|
|
27
|
+
type CookieConfig = {
|
|
28
|
+
name: string;
|
|
29
|
+
value: string;
|
|
30
|
+
url?: string;
|
|
31
|
+
domain?: string;
|
|
32
|
+
path?: string;
|
|
33
|
+
secure?: boolean;
|
|
34
|
+
httpOnly?: boolean;
|
|
35
|
+
sameSite?: 'Strict' | 'Lax' | 'None';
|
|
36
|
+
expires?: number;
|
|
37
|
+
priority?: 'Low' | 'Medium' | 'High';
|
|
38
|
+
sameParty?: boolean;
|
|
39
|
+
sourceScheme?: 'Unset' | 'NonSecure' | 'Secure';
|
|
40
|
+
sourcePort?: number;
|
|
41
|
+
};
|
|
42
|
+
export interface TestViewport extends Viewport {
|
|
43
|
+
safeAreaInset?: {
|
|
44
|
+
top?: number | string;
|
|
45
|
+
right?: number | string;
|
|
46
|
+
bottom?: number | string;
|
|
47
|
+
left?: number | string;
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
interface OpenPageCommonConfig {
|
|
51
|
+
userAgent?: string;
|
|
52
|
+
viewport?: TestViewport;
|
|
53
|
+
isDarkMode?: boolean;
|
|
54
|
+
cookies?: Array<CookieConfig>;
|
|
55
|
+
}
|
|
56
|
+
interface OpenPageUrlConfig extends OpenPageCommonConfig {
|
|
57
|
+
url: string;
|
|
58
|
+
}
|
|
59
|
+
interface OpenPagePathConfig extends OpenPageCommonConfig {
|
|
60
|
+
url?: undefined;
|
|
61
|
+
path?: string;
|
|
62
|
+
port?: number;
|
|
63
|
+
protocol?: string;
|
|
64
|
+
hostname?: string;
|
|
65
|
+
}
|
|
66
|
+
type OpenPageConfig = OpenPageUrlConfig | OpenPagePathConfig;
|
|
67
|
+
export declare const openPage: ({ userAgent, isDarkMode, viewport, cookies, ...urlConfig }: OpenPageConfig) => Promise<PageApi>;
|
|
68
|
+
export declare const getScreen: (page: Page) => import("pptr-testing-library/dist/typedefs").IQueryUtils & import("pptr-testing-library/dist/typedefs").IScopedQueryUtils;
|
|
69
|
+
export declare const screen: import("pptr-testing-library/dist/typedefs").IQueryUtils & import("pptr-testing-library/dist/typedefs").IScopedQueryUtils;
|
|
70
|
+
export declare const within: (element: ElementHandle) => import("pptr-testing-library/dist/typedefs").IQueryUtils & import("pptr-testing-library/dist/typedefs").IScopedQueryUtils;
|
|
71
|
+
export type { ElementHandle, Viewport } from 'puppeteer';
|
|
72
|
+
/**
|
|
73
|
+
* Returns a new path to the file that can be used by chromium in acceptance tests
|
|
74
|
+
*
|
|
75
|
+
* To be able to use `element.uploadFile()` in a dockerized chromium, the file must exist in the
|
|
76
|
+
* host and the docker, and both sides must use the same path.
|
|
77
|
+
*
|
|
78
|
+
* To workaround this bug or limitation, this function prepares the file by copying it to /tmp in
|
|
79
|
+
* the host and the container.
|
|
80
|
+
*/
|
|
81
|
+
export declare const prepareFile: (filepath: string) => string;
|
|
82
|
+
/**
|
|
83
|
+
* A convenience method to defer an expectation
|
|
84
|
+
*/
|
|
85
|
+
export declare const wait: <T>(expectation: () => Promise<T> | T, timeout?: number, interval?: number) => Promise<T>;
|
|
86
|
+
export declare const waitForElementToBeRemoved: (element: ElementHandle<Element>, timeout?: number, interval?: number) => Promise<void>;
|