@telefonica/acceptance-testing 3.0.0-beta3 → 3.0.0-beta5
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/jest-puppeteer-config.js +38 -11
- package/package.json +2 -1
package/jest-puppeteer-config.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
// @ts-check
|
|
1
2
|
const path = require('path');
|
|
2
3
|
const fs = require('fs');
|
|
3
4
|
const findRoot = require('find-root');
|
|
@@ -16,10 +17,19 @@ const poll = async (url) => {
|
|
|
16
17
|
throw Error(`Error fetching ${url}`);
|
|
17
18
|
};
|
|
18
19
|
|
|
20
|
+
/** @param args {Array<unknown>} */
|
|
21
|
+
const debug = (...args) => {
|
|
22
|
+
if (process.env.DEBUG) {
|
|
23
|
+
console.log('[acceptance-testing]', ...args);
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
|
|
19
27
|
/**
|
|
20
28
|
* CI => everything runs inside a docker
|
|
21
29
|
* Local, headless => connects to a dockerized chromium at port 9223 (see docker-compose.yaml)
|
|
22
30
|
* Local, with UI => launches a local chromium installed by puppetteer
|
|
31
|
+
*
|
|
32
|
+
* @returns {Promise<import('jest-environment-puppeteer').JestPuppeteerConfig>}
|
|
23
33
|
*/
|
|
24
34
|
const getPuppeteerConfig = async () => {
|
|
25
35
|
const isCi = process.argv.includes('--ci') || process.env.CI;
|
|
@@ -27,12 +37,12 @@ const getPuppeteerConfig = async () => {
|
|
|
27
37
|
const isHeadless = !!process.env.HEADLESS;
|
|
28
38
|
|
|
29
39
|
const rootDir = findRoot(process.cwd());
|
|
30
|
-
const
|
|
31
|
-
const projectConfig =
|
|
40
|
+
const packageJson = JSON.parse(fs.readFileSync(path.join(rootDir, 'package.json'), 'utf-8'));
|
|
41
|
+
const projectConfig = packageJson.acceptanceTests || {};
|
|
32
42
|
|
|
33
43
|
const server = (isCi ? projectConfig.ciServer : projectConfig.devServer) || projectConfig.server || {};
|
|
34
44
|
|
|
35
|
-
const
|
|
45
|
+
const baseConnectOrLaunchConfig = {
|
|
36
46
|
ignoreHTTPSErrors: true,
|
|
37
47
|
headless: isHeadless,
|
|
38
48
|
slowMo: isHeadless ? 0 : 50,
|
|
@@ -65,7 +75,7 @@ const getPuppeteerConfig = async () => {
|
|
|
65
75
|
// const {webSocketDebuggerUrl} = await fetch(`${dockerChromiumUrl}/json/version`).then((r) => r.json());
|
|
66
76
|
|
|
67
77
|
connect = {
|
|
68
|
-
...
|
|
78
|
+
...baseConnectOrLaunchConfig,
|
|
69
79
|
browserURL: dockerChromiumUrl,
|
|
70
80
|
// browserWSEndpoint: webSocketDebuggerUrl,
|
|
71
81
|
};
|
|
@@ -80,21 +90,20 @@ const getPuppeteerConfig = async () => {
|
|
|
80
90
|
launchTimeout: 60000,
|
|
81
91
|
};
|
|
82
92
|
|
|
83
|
-
|
|
93
|
+
/** @type import('jest-environment-puppeteer').JestPuppeteerConfig */
|
|
94
|
+
const config = {
|
|
84
95
|
launch: {
|
|
85
|
-
...
|
|
96
|
+
...baseConnectOrLaunchConfig,
|
|
86
97
|
// Launch chromium installed in docker in CI
|
|
87
98
|
...(isCi ? {executablePath: '/usr/bin/chromium'} : {}),
|
|
88
99
|
env: {
|
|
89
|
-
...process.env,
|
|
90
100
|
TZ: 'UTC',
|
|
91
101
|
LANG: 'es_ES',
|
|
92
102
|
LANGUAGE: 'es_ES',
|
|
93
103
|
},
|
|
104
|
+
// args must be the same as the ones defined in web-builder Dockerfile
|
|
94
105
|
args: [
|
|
95
|
-
|
|
96
|
-
'--no-sandbox', // probably not needed in ubuntu
|
|
97
|
-
'--font-render-hinting=none', // this flag is important because we use it when launching dockerized chromium too
|
|
106
|
+
'--lang=es_ES',
|
|
98
107
|
'--disable-background-networking',
|
|
99
108
|
'--disable-background-timer-throttling',
|
|
100
109
|
'--disable-breakpad',
|
|
@@ -108,7 +117,22 @@ const getPuppeteerConfig = async () => {
|
|
|
108
117
|
'--disable-prompt-on-repost',
|
|
109
118
|
'--disable-sync',
|
|
110
119
|
'--disable-translate',
|
|
111
|
-
'--disable-
|
|
120
|
+
'--disable-gpu',
|
|
121
|
+
'--metrics-recording-only',
|
|
122
|
+
'--no-first-run',
|
|
123
|
+
'--safebrowsing-disable-auto-update',
|
|
124
|
+
'--enable-automation',
|
|
125
|
+
'--password-store=basic',
|
|
126
|
+
'--use-mock-keychain',
|
|
127
|
+
'--headless',
|
|
128
|
+
'--hide-scrollbars',
|
|
129
|
+
'--no-sandbox',
|
|
130
|
+
'--font-render-hinting=none',
|
|
131
|
+
'--force-color-profile=sRGB',
|
|
132
|
+
'--disable-font-subpixel-positioning',
|
|
133
|
+
'--remote-debugging-port=9222',
|
|
134
|
+
'--remote-debugging-address=0.0.0.0',
|
|
135
|
+
'--ignore-certificate-errors',
|
|
112
136
|
],
|
|
113
137
|
},
|
|
114
138
|
browserContext: 'incognito',
|
|
@@ -121,6 +145,9 @@ const getPuppeteerConfig = async () => {
|
|
|
121
145
|
}
|
|
122
146
|
: undefined,
|
|
123
147
|
};
|
|
148
|
+
|
|
149
|
+
debug('jest-puppeteer-config', config);
|
|
150
|
+
return config;
|
|
124
151
|
};
|
|
125
152
|
|
|
126
153
|
module.exports = getPuppeteerConfig();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@telefonica/acceptance-testing",
|
|
3
|
-
"version": "3.0.0-
|
|
3
|
+
"version": "3.0.0-beta5",
|
|
4
4
|
"author": "Telefonica",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"module": "dist/acceptance-testing.esm.js",
|
|
@@ -32,6 +32,7 @@
|
|
|
32
32
|
"@typescript-eslint/eslint-plugin": "^7.9.0",
|
|
33
33
|
"@typescript-eslint/parser": "^7.9.0",
|
|
34
34
|
"babel-jest": "^29.7.0",
|
|
35
|
+
"jest-environment-puppeteer": "^10.0.1",
|
|
35
36
|
"tsdx": "^0.14.1",
|
|
36
37
|
"tslib": "^2.6.2",
|
|
37
38
|
"typescript": "^5.4.5"
|