Advertisement
Guest User

Untitled

a guest
Jul 19th, 2019
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.21 KB | None | 0 0
  1. module.exports = function() {
  2. var worldPath = path.join(config.paths.root, '../support/world')
  3. this.World = require(worldPath).World;
  4. }
  5.  
  6. function CustomWorld({attach, parameters}) {
  7.  
  8. this.waitForTestController = testControllerHolder.get()
  9. .then(function(tc) {
  10. return testController = tc;
  11. });
  12.  
  13. this.attach = attach;
  14.  
  15. this.setBrowser = function() {
  16. if (parameters.browser === undefined) {
  17. return 'chrome';
  18. } else {
  19. return parameters.browser;
  20. }
  21. };
  22.  
  23. this.addScreenshotToReport = function() {
  24. if (process.argv.includes('--format') || process.argv.includes('-f') || process.argv.includes('--format-options')) {
  25. testController.takeScreenshot()
  26. .then(function(screenshotPath) {
  27. const imgInBase64 = base64Img.base64Sync(screenshotPath);
  28. const imageConvertForCuc = imgInBase64.substring(imgInBase64.indexOf(',') + 1);
  29. return attach(imageConvertForCuc, 'image/png');
  30. })
  31. .catch(function(error) {
  32. console.warn('The screenshot was not attached to the report');
  33. });
  34. } else {
  35. return new Promise((resolve) => {
  36. resolve(null);
  37. });
  38. }
  39. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement