@telefonica/acceptance-testing 3.0.0-beta8 → 3.0.0
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 +27 -0
- package/dist/acceptance-testing.cjs.development.js +185 -275
- package/dist/acceptance-testing.cjs.development.js.map +1 -1
- package/dist/acceptance-testing.cjs.production.min.js +1 -1
- package/dist/acceptance-testing.cjs.production.min.js.map +1 -1
- package/dist/acceptance-testing.esm.js +185 -275
- package/dist/acceptance-testing.esm.js.map +1 -1
- package/dist/coverage.d.ts +8 -8
- package/dist/index.d.ts +91 -93
- package/dist/utils.d.ts +4 -4
- package/docker-compose.yaml +1 -1
- package/jest-puppeteer-config.js +24 -37
- package/package.json +13 -14
- package/dist/__tests__/utils.test.d.ts +0 -1
package/README.md
CHANGED
|
@@ -274,6 +274,8 @@ After running the tests, you can use a tool like `nyc` to generate the coverage
|
|
|
274
274
|
|
|
275
275
|
## Troubleshooting
|
|
276
276
|
|
|
277
|
+
### Unhandled browser errors
|
|
278
|
+
|
|
277
279
|
If you see an acceptance test failing without any apparent reason, it could be caused by an unhandled error in
|
|
278
280
|
the browser. You can inspect it by adding a listener to the `pageerror` event:
|
|
279
281
|
|
|
@@ -283,3 +285,28 @@ page.on('pageerror', (err) => {
|
|
|
283
285
|
process.emit('uncaughtException', err);
|
|
284
286
|
});
|
|
285
287
|
```
|
|
288
|
+
|
|
289
|
+
### Executing with --ui fails (Linux)
|
|
290
|
+
|
|
291
|
+
If your desktop environment uses Wayland, you may see the following error when running the tests with the
|
|
292
|
+
`--ui` flag:
|
|
293
|
+
|
|
294
|
+
```
|
|
295
|
+
Error: Jest: Got error running globalSetup - /home/pladaria/bra/mistica-web/node_modules/jest-environment-puppeteer/setup.js, reason: ErrorEvent {
|
|
296
|
+
"error": [Error: socket hang up],
|
|
297
|
+
"message": "socket hang up",
|
|
298
|
+
...
|
|
299
|
+
```
|
|
300
|
+
|
|
301
|
+
To workaround this issue, you can install a newer Chrome in the repo where you are using the
|
|
302
|
+
`acceptance-testing` library:
|
|
303
|
+
|
|
304
|
+
- From the repo root: `npx @puppeteer/browsers install chrome@stable`
|
|
305
|
+
- Remove the chrome installed by puppeteer:
|
|
306
|
+
`rm -rf node_modules/puppeteer/.local-chromium/linux-901912/chrome-linux`
|
|
307
|
+
- Move downloaded chrome to the expected location:
|
|
308
|
+
`mv chrome/linux-<version>/chrome-linux64 node_modules/puppeteer/.local-chromium/linux-901912/chrome-linux`
|
|
309
|
+
- Cleanup. Remove chrome folder from the repo root: `rm -rf chrome`
|
|
310
|
+
|
|
311
|
+
Note that this browser will only be used when running the tests with the `--ui` flag. In headless mode, the
|
|
312
|
+
dockerized chromium will be used.
|
|
@@ -380,13 +380,13 @@ var getRootPath = function getRootPath() {
|
|
|
380
380
|
}
|
|
381
381
|
return rootPath;
|
|
382
382
|
};
|
|
383
|
-
/**
|
|
384
|
-
* We want to clear coverage files from previous runs, but at this point it is not easy because each
|
|
385
|
-
* worker runs a different instance of this script, so we can't just clear the coverage folder at
|
|
386
|
-
* the beginning of the test run.
|
|
387
|
-
*
|
|
388
|
-
* The solution is to remove the coverage folder when the stored ppid (parent process id) is
|
|
389
|
-
* different from the current one
|
|
383
|
+
/**
|
|
384
|
+
* We want to clear coverage files from previous runs, but at this point it is not easy because each
|
|
385
|
+
* worker runs a different instance of this script, so we can't just clear the coverage folder at
|
|
386
|
+
* the beginning of the test run.
|
|
387
|
+
*
|
|
388
|
+
* The solution is to remove the coverage folder when the stored ppid (parent process id) is
|
|
389
|
+
* different from the current one
|
|
390
390
|
*/
|
|
391
391
|
var prepareCoverageReportPath = function prepareCoverageReportPath(_ref) {
|
|
392
392
|
var coveragePath = _ref.coveragePath;
|
|
@@ -406,9 +406,9 @@ var prepareCoverageReportPath = function prepareCoverageReportPath(_ref) {
|
|
|
406
406
|
fs.writeFileSync(ppidFile, ppid);
|
|
407
407
|
}
|
|
408
408
|
};
|
|
409
|
-
/**
|
|
410
|
-
* Asumes the code was instrumented with istanbul and the coverage report stored in `window.__coverage__`.
|
|
411
|
-
* If not, this function does nothing.
|
|
409
|
+
/**
|
|
410
|
+
* Asumes the code was instrumented with istanbul and the coverage report stored in `window.__coverage__`.
|
|
411
|
+
* If not, this function does nothing.
|
|
412
412
|
*/
|
|
413
413
|
var collectCoverageIfAvailable = /*#__PURE__*/function () {
|
|
414
414
|
var _ref3 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(_ref2) {
|
|
@@ -453,8 +453,8 @@ var collectCoverageIfAvailable = /*#__PURE__*/function () {
|
|
|
453
453
|
};
|
|
454
454
|
}();
|
|
455
455
|
|
|
456
|
-
/**
|
|
457
|
-
* Returns true if the current path matches the spied path, including parameters
|
|
456
|
+
/**
|
|
457
|
+
* Returns true if the current path matches the spied path, including parameters
|
|
458
458
|
*/
|
|
459
459
|
var matchPath = function matchPath(spiedPath, currentPath) {
|
|
460
460
|
var normalizedCurrentPath = path.normalize(currentPath);
|
|
@@ -462,7 +462,8 @@ var matchPath = function matchPath(spiedPath, currentPath) {
|
|
|
462
462
|
return pattern.test(normalizedCurrentPath);
|
|
463
463
|
};
|
|
464
464
|
|
|
465
|
-
var _excluded = ["
|
|
465
|
+
var _excluded = ["captureBeyondViewport"],
|
|
466
|
+
_excluded2 = ["userAgent", "isDarkMode", "viewport", "cookies"];
|
|
466
467
|
var _pkg$acceptanceTests, _ref, _projectConfig$covera;
|
|
467
468
|
var LINUX_DOCKER_HOST_IP = '172.17.0.1';
|
|
468
469
|
var getGlobalBrowser = function getGlobalBrowser() {
|
|
@@ -472,7 +473,7 @@ var getGlobalPage$1 = function getGlobalPage() {
|
|
|
472
473
|
return global.page;
|
|
473
474
|
};
|
|
474
475
|
var isCi = /*#__PURE__*/process.argv.includes('--ci') || process.env.CI;
|
|
475
|
-
var isUsingDockerizedChromium =
|
|
476
|
+
var isUsingDockerizedChromium = isCi || /*#__PURE__*/new URL( /*#__PURE__*/getGlobalBrowser().wsEndpoint()).port === '9223';
|
|
476
477
|
/** Check if running inside WSL */
|
|
477
478
|
var isWsl = function isWsl() {
|
|
478
479
|
if (process.platform !== 'linux') {
|
|
@@ -543,7 +544,7 @@ var toMatchImageSnapshot = /*#__PURE__*/jestImageSnapshot.configureToMatchImageS
|
|
|
543
544
|
failureThresholdType: 'percent',
|
|
544
545
|
customSnapshotIdentifier: function customSnapshotIdentifier(_ref2) {
|
|
545
546
|
var defaultIdentifier = _ref2.defaultIdentifier;
|
|
546
|
-
return defaultIdentifier
|
|
547
|
+
return defaultIdentifier;
|
|
547
548
|
}
|
|
548
549
|
});
|
|
549
550
|
var calledToMatchImageSnapshotOutsideDocker = false;
|
|
@@ -633,15 +634,18 @@ var waitForPaintEnd = /*#__PURE__*/function () {
|
|
|
633
634
|
return _ref3.apply(this, arguments);
|
|
634
635
|
};
|
|
635
636
|
}();
|
|
636
|
-
var normalizeSreenshotOptions = function normalizeSreenshotOptions(
|
|
637
|
-
|
|
637
|
+
var normalizeSreenshotOptions = function normalizeSreenshotOptions(_temp2) {
|
|
638
|
+
var _ref5 = _temp2 === void 0 ? {} : _temp2,
|
|
639
|
+
_ref5$captureBeyondVi = _ref5.captureBeyondViewport,
|
|
640
|
+
captureBeyondViewport = _ref5$captureBeyondVi === void 0 ? false : _ref5$captureBeyondVi,
|
|
641
|
+
options = _objectWithoutPropertiesLoose(_ref5, _excluded);
|
|
642
|
+
// Puppeter default for captureBeyondViewport is true, but we think false is a better default.
|
|
643
|
+
// When this is true, the fixed elements (like fixed footers) are relative to the original page
|
|
644
|
+
// viewport, not to the full page, so those elements look weird in fullPage screenshots.
|
|
645
|
+
return _extends({}, options, {
|
|
646
|
+
captureBeyondViewport: captureBeyondViewport
|
|
647
|
+
});
|
|
638
648
|
};
|
|
639
|
-
// const normalizeSreenshotOptions = ({captureBeyondViewport = false, ...options}: ScreenshotOptions = {}) => {
|
|
640
|
-
// // Puppeter default for captureBeyondViewport is true, but we think false is a better default.
|
|
641
|
-
// // When this is true, the fixed elements (like fixed footers) are relative to the original page
|
|
642
|
-
// // viewport, not to the full page, so those elements look weird in fullPage screenshots.
|
|
643
|
-
// return {...options, captureBeyondViewport};
|
|
644
|
-
// };
|
|
645
649
|
// Puppeteer already calls scrollIntoViewIfNeeded before clicking an element. But it doesn't work in all situations
|
|
646
650
|
// For example, when there is a fixed footer in the page and the element to click is under it, the browser won't scroll
|
|
647
651
|
// because the element is already in the viewport (the ifNeeded part is important here). By forcing the scroll to the
|
|
@@ -654,238 +658,144 @@ var scrollIntoView = function scrollIntoView(el) {
|
|
|
654
658
|
});
|
|
655
659
|
};
|
|
656
660
|
var getPageApi = function getPageApi(page) {
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
while (1) switch (_context5.prev = _context5.next) {
|
|
729
|
-
case 0:
|
|
730
|
-
if (options != null && options.skipNetworkWait) {
|
|
731
|
-
_context5.next = 3;
|
|
732
|
-
break;
|
|
733
|
-
}
|
|
661
|
+
var api = Object.create(page);
|
|
662
|
+
api.type = /*#__PURE__*/function () {
|
|
663
|
+
var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(elementHandle, text, options) {
|
|
664
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
665
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
666
|
+
case 0:
|
|
667
|
+
_context2.next = 2;
|
|
668
|
+
return scrollIntoView(elementHandle);
|
|
669
|
+
case 2:
|
|
670
|
+
return _context2.abrupt("return", elementHandle.type(text, options));
|
|
671
|
+
case 3:
|
|
672
|
+
case "end":
|
|
673
|
+
return _context2.stop();
|
|
674
|
+
}
|
|
675
|
+
}, _callee2);
|
|
676
|
+
}));
|
|
677
|
+
return function (_x3, _x4, _x5) {
|
|
678
|
+
return _ref6.apply(this, arguments);
|
|
679
|
+
};
|
|
680
|
+
}();
|
|
681
|
+
api.click = /*#__PURE__*/function () {
|
|
682
|
+
var _ref7 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(elementHandle, options) {
|
|
683
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
684
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
685
|
+
case 0:
|
|
686
|
+
_context3.next = 2;
|
|
687
|
+
return scrollIntoView(elementHandle);
|
|
688
|
+
case 2:
|
|
689
|
+
return _context3.abrupt("return", elementHandle.click(options));
|
|
690
|
+
case 3:
|
|
691
|
+
case "end":
|
|
692
|
+
return _context3.stop();
|
|
693
|
+
}
|
|
694
|
+
}, _callee3);
|
|
695
|
+
}));
|
|
696
|
+
return function (_x6, _x7) {
|
|
697
|
+
return _ref7.apply(this, arguments);
|
|
698
|
+
};
|
|
699
|
+
}();
|
|
700
|
+
api.select = /*#__PURE__*/function () {
|
|
701
|
+
var _ref8 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(elementHandle) {
|
|
702
|
+
var _len,
|
|
703
|
+
values,
|
|
704
|
+
_key,
|
|
705
|
+
_args4 = arguments;
|
|
706
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
707
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
708
|
+
case 0:
|
|
709
|
+
_context4.next = 2;
|
|
710
|
+
return scrollIntoView(elementHandle);
|
|
711
|
+
case 2:
|
|
712
|
+
for (_len = _args4.length, values = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
713
|
+
values[_key - 1] = _args4[_key];
|
|
714
|
+
}
|
|
715
|
+
return _context4.abrupt("return", elementHandle.select.apply(elementHandle, values));
|
|
716
|
+
case 4:
|
|
717
|
+
case "end":
|
|
718
|
+
return _context4.stop();
|
|
719
|
+
}
|
|
720
|
+
}, _callee4);
|
|
721
|
+
}));
|
|
722
|
+
return function (_x8) {
|
|
723
|
+
return _ref8.apply(this, arguments);
|
|
724
|
+
};
|
|
725
|
+
}();
|
|
726
|
+
api.screenshot = /*#__PURE__*/function () {
|
|
727
|
+
var _ref9 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(options) {
|
|
728
|
+
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
729
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
730
|
+
case 0:
|
|
731
|
+
if (options != null && options.skipNetworkWait) {
|
|
734
732
|
_context5.next = 3;
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
return
|
|
774
|
-
}
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
};
|
|
785
|
-
}
|
|
786
|
-
},
|
|
787
|
-
$: page.$.bind(page),
|
|
788
|
-
$$: page.$$.bind(page),
|
|
789
|
-
$$eval: page.$$eval.bind(page),
|
|
790
|
-
$eval: page.$eval.bind(page),
|
|
791
|
-
accessibility: page.accessibility,
|
|
792
|
-
addScriptTag: page.addScriptTag.bind(page),
|
|
793
|
-
addStyleTag: page.addStyleTag.bind(page),
|
|
794
|
-
authenticate: page.authenticate.bind(page),
|
|
795
|
-
bringToFront: page.bringToFront.bind(page),
|
|
796
|
-
browser: page.browser.bind(page),
|
|
797
|
-
browserContext: page.browserContext.bind(page),
|
|
798
|
-
close: page.close.bind(page),
|
|
799
|
-
content: page.content,
|
|
800
|
-
cookies: page.cookies.bind(page),
|
|
801
|
-
coverage: page.coverage,
|
|
802
|
-
createCDPSession: page.createCDPSession.bind(page),
|
|
803
|
-
createPDFStream: page.createPDFStream.bind(page),
|
|
804
|
-
deleteCookie: page.deleteCookie.bind(page),
|
|
805
|
-
emit: page.emit.bind(page),
|
|
806
|
-
emulate: page.emulate.bind(page),
|
|
807
|
-
emulateCPUThrottling: page.emulateCPUThrottling.bind(page),
|
|
808
|
-
emulateIdleState: page.emulateIdleState.bind(page),
|
|
809
|
-
emulateMediaFeatures: page.emulateMediaFeatures.bind(page),
|
|
810
|
-
emulateMediaType: page.emulateMediaType.bind(page),
|
|
811
|
-
emulateNetworkConditions: page.emulateNetworkConditions.bind(page),
|
|
812
|
-
emulateTimezone: page.emulateTimezone.bind(page),
|
|
813
|
-
emulateVisionDeficiency: page.emulateVisionDeficiency.bind(page),
|
|
814
|
-
evaluate: page.evaluate.bind(page),
|
|
815
|
-
evaluateHandle: page.evaluateHandle.bind(page),
|
|
816
|
-
evaluateOnNewDocument: page.evaluateOnNewDocument.bind(page),
|
|
817
|
-
exposeFunction: page.exposeFunction.bind(page),
|
|
818
|
-
focus: page.focus.bind(page),
|
|
819
|
-
frames: page.frames.bind(page),
|
|
820
|
-
getDefaultTimeout: page.getDefaultTimeout.bind(page),
|
|
821
|
-
goBack: page.goBack.bind(page),
|
|
822
|
-
goForward: page.goForward.bind(page),
|
|
823
|
-
"goto": page["goto"].bind(page),
|
|
824
|
-
hover: page.hover.bind(page),
|
|
825
|
-
isClosed: page.isClosed.bind(page),
|
|
826
|
-
isDragInterceptionEnabled: page.isDragInterceptionEnabled.bind(page),
|
|
827
|
-
isJavaScriptEnabled: page.isJavaScriptEnabled.bind(page),
|
|
828
|
-
isServiceWorkerBypassed: page.isServiceWorkerBypassed.bind(page),
|
|
829
|
-
keyboard: page.keyboard,
|
|
830
|
-
listenerCount: page.listenerCount.bind(page),
|
|
831
|
-
locator: page.locator.bind(page),
|
|
832
|
-
mainFrame: page.mainFrame.bind(page),
|
|
833
|
-
metrics: page.metrics.bind(page),
|
|
834
|
-
mouse: page.mouse,
|
|
835
|
-
off: page.off.bind(page),
|
|
836
|
-
on: page.on.bind(page),
|
|
837
|
-
once: page.once.bind(page),
|
|
838
|
-
pdf: page.pdf,
|
|
839
|
-
queryObjects: page.queryObjects.bind(page),
|
|
840
|
-
reload: page.reload.bind(page),
|
|
841
|
-
removeAllListeners: page.removeAllListeners.bind(page),
|
|
842
|
-
removeExposedFunction: page.removeExposedFunction.bind(page),
|
|
843
|
-
removeScriptToEvaluateOnNewDocument: page.removeScriptToEvaluateOnNewDocument.bind(page),
|
|
844
|
-
screencast: page.screencast,
|
|
845
|
-
setBypassCSP: page.setBypassCSP.bind(page),
|
|
846
|
-
setBypassServiceWorker: page.setBypassServiceWorker.bind(page),
|
|
847
|
-
setCacheEnabled: page.setCacheEnabled.bind(page),
|
|
848
|
-
setContent: page.setContent.bind(page),
|
|
849
|
-
setCookie: page.setCookie.bind(page),
|
|
850
|
-
setDefaultNavigationTimeout: page.setDefaultNavigationTimeout.bind(page),
|
|
851
|
-
setDefaultTimeout: page.setDefaultTimeout.bind(page),
|
|
852
|
-
setDragInterception: page.setDragInterception.bind(page),
|
|
853
|
-
setExtraHTTPHeaders: page.setExtraHTTPHeaders.bind(page),
|
|
854
|
-
setJavaScriptEnabled: page.setJavaScriptEnabled.bind(page),
|
|
855
|
-
setOfflineMode: page.setOfflineMode.bind(page),
|
|
856
|
-
setRequestInterception: page.setRequestInterception.bind(page),
|
|
857
|
-
setUserAgent: page.setUserAgent.bind(page),
|
|
858
|
-
setViewport: page.setViewport.bind(page),
|
|
859
|
-
tap: page.tap.bind(page),
|
|
860
|
-
target: page.target.bind(page),
|
|
861
|
-
title: page.title,
|
|
862
|
-
touchscreen: page.touchscreen,
|
|
863
|
-
tracing: page.tracing,
|
|
864
|
-
url: page.url,
|
|
865
|
-
viewport: page.viewport,
|
|
866
|
-
waitForDevicePrompt: page.waitForDevicePrompt.bind(page),
|
|
867
|
-
waitForFileChooser: page.waitForFileChooser.bind(page),
|
|
868
|
-
waitForFrame: page.waitForFrame.bind(page),
|
|
869
|
-
waitForFunction: page.waitForFunction.bind(page),
|
|
870
|
-
waitForNavigation: page.waitForNavigation.bind(page),
|
|
871
|
-
waitForNetworkIdle: page.waitForNetworkIdle.bind(page),
|
|
872
|
-
waitForRequest: page.waitForRequest.bind(page),
|
|
873
|
-
waitForResponse: page.waitForResponse.bind(page),
|
|
874
|
-
waitForSelector: page.waitForSelector.bind(page),
|
|
875
|
-
workers: page.workers
|
|
733
|
+
break;
|
|
734
|
+
}
|
|
735
|
+
_context5.next = 3;
|
|
736
|
+
return page.waitForNetworkIdle();
|
|
737
|
+
case 3:
|
|
738
|
+
_context5.next = 5;
|
|
739
|
+
return waitForPaintEnd(page, options);
|
|
740
|
+
case 5:
|
|
741
|
+
return _context5.abrupt("return", page.screenshot(normalizeSreenshotOptions(options)));
|
|
742
|
+
case 6:
|
|
743
|
+
case "end":
|
|
744
|
+
return _context5.stop();
|
|
745
|
+
}
|
|
746
|
+
}, _callee5);
|
|
747
|
+
}));
|
|
748
|
+
return function (_x9) {
|
|
749
|
+
return _ref9.apply(this, arguments);
|
|
750
|
+
};
|
|
751
|
+
}();
|
|
752
|
+
api.clear = /*#__PURE__*/function () {
|
|
753
|
+
var _ref10 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(elementHandle) {
|
|
754
|
+
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
755
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
756
|
+
case 0:
|
|
757
|
+
_context6.next = 2;
|
|
758
|
+
return elementHandle.click({
|
|
759
|
+
clickCount: 3
|
|
760
|
+
});
|
|
761
|
+
case 2:
|
|
762
|
+
_context6.next = 4;
|
|
763
|
+
return elementHandle.press('Delete');
|
|
764
|
+
case 4:
|
|
765
|
+
case "end":
|
|
766
|
+
return _context6.stop();
|
|
767
|
+
}
|
|
768
|
+
}, _callee6);
|
|
769
|
+
}));
|
|
770
|
+
return function (_x10) {
|
|
771
|
+
return _ref10.apply(this, arguments);
|
|
772
|
+
};
|
|
773
|
+
}();
|
|
774
|
+
// For some reason, puppeteer browserContext.overridePermissions doesn't work with newer chrome versions.
|
|
775
|
+
// This workaround polyfills the browser geolocation api to return the mocked position
|
|
776
|
+
api.setGeolocation = function (position) {
|
|
777
|
+
return page.evaluate(function (position) {
|
|
778
|
+
window.navigator.geolocation.getCurrentPosition = function (callback) {
|
|
779
|
+
// @ts-expect-error - puppeteer's setGeoLocation does not expect a timestamp to be passed
|
|
780
|
+
callback({
|
|
781
|
+
coords: position
|
|
782
|
+
});
|
|
783
|
+
};
|
|
784
|
+
}, position);
|
|
876
785
|
};
|
|
786
|
+
return api;
|
|
877
787
|
};
|
|
878
788
|
var needsRequestInterception = false;
|
|
879
789
|
var requestHandlers = [];
|
|
880
790
|
var requestInterceptor = function requestInterceptor(req) {
|
|
881
791
|
var _requestHandlers$find;
|
|
882
|
-
var
|
|
883
|
-
var matcher =
|
|
792
|
+
var _ref11 = (_requestHandlers$find = requestHandlers.find(function (_ref12) {
|
|
793
|
+
var matcher = _ref12.matcher;
|
|
884
794
|
return matcher(req);
|
|
885
795
|
})) != null ? _requestHandlers$find : {
|
|
886
796
|
handler: null
|
|
887
797
|
},
|
|
888
|
-
handler =
|
|
798
|
+
handler = _ref11.handler;
|
|
889
799
|
if (!handler) {
|
|
890
800
|
req["continue"]();
|
|
891
801
|
return;
|
|
@@ -902,12 +812,12 @@ var interceptRequest = function interceptRequest(matcher) {
|
|
|
902
812
|
});
|
|
903
813
|
return spy;
|
|
904
814
|
};
|
|
905
|
-
var createApiEndpointMock = function createApiEndpointMock(
|
|
906
|
-
var
|
|
907
|
-
var
|
|
908
|
-
origin =
|
|
909
|
-
baseUrl =
|
|
910
|
-
var originRegExp = globToRegExp((
|
|
815
|
+
var createApiEndpointMock = function createApiEndpointMock(_temp3) {
|
|
816
|
+
var _ref14;
|
|
817
|
+
var _ref13 = _temp3 === void 0 ? {} : _temp3,
|
|
818
|
+
origin = _ref13.origin,
|
|
819
|
+
baseUrl = _ref13.baseUrl;
|
|
820
|
+
var originRegExp = globToRegExp((_ref14 = origin != null ? origin : baseUrl) != null ? _ref14 : '*');
|
|
911
821
|
interceptRequest(function (req) {
|
|
912
822
|
var _URL = new URL(req.url()),
|
|
913
823
|
origin = _URL.origin;
|
|
@@ -955,12 +865,12 @@ var createApiEndpointMock = function createApiEndpointMock(_temp2) {
|
|
|
955
865
|
};
|
|
956
866
|
};
|
|
957
867
|
var openPage = /*#__PURE__*/function () {
|
|
958
|
-
var
|
|
868
|
+
var _ref16 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(_ref15) {
|
|
959
869
|
var userAgent, isDarkMode, viewport, cookies, urlConfig, url, currentUserAgent, page, connectionError;
|
|
960
870
|
return _regeneratorRuntime().wrap(function _callee7$(_context7) {
|
|
961
871
|
while (1) switch (_context7.prev = _context7.next) {
|
|
962
872
|
case 0:
|
|
963
|
-
userAgent =
|
|
873
|
+
userAgent = _ref15.userAgent, isDarkMode = _ref15.isDarkMode, viewport = _ref15.viewport, cookies = _ref15.cookies, urlConfig = /*#__PURE__*/_objectWithoutPropertiesLoose(_ref15, _excluded2);
|
|
964
874
|
url = function () {
|
|
965
875
|
if (urlConfig.url !== undefined) {
|
|
966
876
|
return urlConfig.url;
|
|
@@ -1071,13 +981,13 @@ var openPage = /*#__PURE__*/function () {
|
|
|
1071
981
|
}, _callee7, null, [[27, 32]]);
|
|
1072
982
|
}));
|
|
1073
983
|
return function openPage(_x11) {
|
|
1074
|
-
return
|
|
984
|
+
return _ref16.apply(this, arguments);
|
|
1075
985
|
};
|
|
1076
986
|
}();
|
|
1077
|
-
var buildQueryMethods = function buildQueryMethods(
|
|
1078
|
-
var
|
|
1079
|
-
page =
|
|
1080
|
-
element =
|
|
987
|
+
var buildQueryMethods = function buildQueryMethods(_temp4) {
|
|
988
|
+
var _ref17 = _temp4 === void 0 ? {} : _temp4,
|
|
989
|
+
page = _ref17.page,
|
|
990
|
+
element = _ref17.element;
|
|
1081
991
|
var boundQueries = {};
|
|
1082
992
|
var _loop = function _loop() {
|
|
1083
993
|
var _Object$entries$_i = _Object$entries[_i],
|
|
@@ -1122,7 +1032,7 @@ var buildQueryMethods = function buildQueryMethods(_temp3) {
|
|
|
1122
1032
|
elementHandle = _context12.sent;
|
|
1123
1033
|
newElementHandle = Object.create(elementHandle);
|
|
1124
1034
|
newElementHandle.screenshot = /*#__PURE__*/function () {
|
|
1125
|
-
var
|
|
1035
|
+
var _ref19 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(options) {
|
|
1126
1036
|
return _regeneratorRuntime().wrap(function _callee8$(_context8) {
|
|
1127
1037
|
while (1) switch (_context8.prev = _context8.next) {
|
|
1128
1038
|
case 0:
|
|
@@ -1146,11 +1056,11 @@ var buildQueryMethods = function buildQueryMethods(_temp3) {
|
|
|
1146
1056
|
}, _callee8);
|
|
1147
1057
|
}));
|
|
1148
1058
|
return function (_x12) {
|
|
1149
|
-
return
|
|
1059
|
+
return _ref19.apply(this, arguments);
|
|
1150
1060
|
};
|
|
1151
1061
|
}();
|
|
1152
1062
|
newElementHandle.click = /*#__PURE__*/function () {
|
|
1153
|
-
var
|
|
1063
|
+
var _ref20 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(options) {
|
|
1154
1064
|
return _regeneratorRuntime().wrap(function _callee9$(_context9) {
|
|
1155
1065
|
while (1) switch (_context9.prev = _context9.next) {
|
|
1156
1066
|
case 0:
|
|
@@ -1165,11 +1075,11 @@ var buildQueryMethods = function buildQueryMethods(_temp3) {
|
|
|
1165
1075
|
}, _callee9);
|
|
1166
1076
|
}));
|
|
1167
1077
|
return function (_x13) {
|
|
1168
|
-
return
|
|
1078
|
+
return _ref20.apply(this, arguments);
|
|
1169
1079
|
};
|
|
1170
1080
|
}();
|
|
1171
1081
|
newElementHandle.type = /*#__PURE__*/function () {
|
|
1172
|
-
var
|
|
1082
|
+
var _ref21 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(text, options) {
|
|
1173
1083
|
return _regeneratorRuntime().wrap(function _callee10$(_context10) {
|
|
1174
1084
|
while (1) switch (_context10.prev = _context10.next) {
|
|
1175
1085
|
case 0:
|
|
@@ -1184,7 +1094,7 @@ var buildQueryMethods = function buildQueryMethods(_temp3) {
|
|
|
1184
1094
|
}, _callee10);
|
|
1185
1095
|
}));
|
|
1186
1096
|
return function (_x14, _x15) {
|
|
1187
|
-
return
|
|
1097
|
+
return _ref21.apply(this, arguments);
|
|
1188
1098
|
};
|
|
1189
1099
|
}();
|
|
1190
1100
|
newElementHandle.select = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {
|
|
@@ -1271,14 +1181,14 @@ afterEach( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().ma
|
|
|
1271
1181
|
}
|
|
1272
1182
|
}, _callee14, null, [[2, 11]]);
|
|
1273
1183
|
})));
|
|
1274
|
-
/**
|
|
1275
|
-
* Returns a new path to the file that can be used by chromium in acceptance tests
|
|
1276
|
-
*
|
|
1277
|
-
* To be able to use `element.uploadFile()` in a dockerized chromium, the file must exist in the
|
|
1278
|
-
* host and the docker, and both sides must use the same path.
|
|
1279
|
-
*
|
|
1280
|
-
* To workaround this bug or limitation, this function prepares the file by copying it to /tmp in
|
|
1281
|
-
* the host and the container.
|
|
1184
|
+
/**
|
|
1185
|
+
* Returns a new path to the file that can be used by chromium in acceptance tests
|
|
1186
|
+
*
|
|
1187
|
+
* To be able to use `element.uploadFile()` in a dockerized chromium, the file must exist in the
|
|
1188
|
+
* host and the docker, and both sides must use the same path.
|
|
1189
|
+
*
|
|
1190
|
+
* To workaround this bug or limitation, this function prepares the file by copying it to /tmp in
|
|
1191
|
+
* the host and the container.
|
|
1282
1192
|
*/
|
|
1283
1193
|
var prepareFile = function prepareFile(filepath) {
|
|
1284
1194
|
var isLocal = !isCi;
|
|
@@ -1298,8 +1208,8 @@ var prepareFile = function prepareFile(filepath) {
|
|
|
1298
1208
|
return filepath;
|
|
1299
1209
|
}
|
|
1300
1210
|
};
|
|
1301
|
-
/**
|
|
1302
|
-
* A convenience method to defer an expectation
|
|
1211
|
+
/**
|
|
1212
|
+
* A convenience method to defer an expectation
|
|
1303
1213
|
*/
|
|
1304
1214
|
var wait = function wait(expectation, timeout, interval) {
|
|
1305
1215
|
if (timeout === void 0) {
|
|
@@ -1345,7 +1255,7 @@ var waitForElementToBeRemoved = function waitForElementToBeRemoved(element, time
|
|
|
1345
1255
|
}
|
|
1346
1256
|
var startStack = new Error().stack;
|
|
1347
1257
|
var wait = /*#__PURE__*/function () {
|
|
1348
|
-
var
|
|
1258
|
+
var _ref25 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15() {
|
|
1349
1259
|
var t0, box;
|
|
1350
1260
|
return _regeneratorRuntime().wrap(function _callee15$(_context15) {
|
|
1351
1261
|
while (1) switch (_context15.prev = _context15.next) {
|
|
@@ -1382,7 +1292,7 @@ var waitForElementToBeRemoved = function waitForElementToBeRemoved(element, time
|
|
|
1382
1292
|
}, _callee15);
|
|
1383
1293
|
}));
|
|
1384
1294
|
return function wait() {
|
|
1385
|
-
return
|
|
1295
|
+
return _ref25.apply(this, arguments);
|
|
1386
1296
|
};
|
|
1387
1297
|
}();
|
|
1388
1298
|
return wait()["catch"](function (error) {
|