Best JavaScript code snippet using cypress
appshell_extensions.js
Source:appshell_extensions.js
1/*2 * Copyright (c) 2012 - present Adobe Systems Incorporated. All rights reserved.3 *4 * Permission is hereby granted, free of charge, to any person obtaining a5 * copy of this software and associated documentation files (the "Software"),6 * to deal in the Software without restriction, including without limitation7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,8 * and/or sell copies of the Software, and to permit persons to whom the9 * Software is furnished to do so, subject to the following conditions:10 *11 * The above copyright notice and this permission notice shall be included in12 * all copies or substantial portions of the Software.13 *14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING19 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER20 * DEALINGS IN THE SOFTWARE.21 *22 */2324// This is the JavaScript code for bridging to native functionality25// See appshell_extentions_[platform] for implementation of native methods.26//27// Note: All file native file i/o functions are synchronous, but are exposed28// here as asynchronous calls. 2930var appshell;31if (!appshell) {32 appshell = {};33}34if (!appshell.fs) {35 appshell.fs = {};36}37if (!appshell.app) {38 appshell.app = {};39}40(function () {41 // Error values. These MUST be in sync with the error values42 // at the top of appshell_extensions_platform.h.43 44 /**45 * @constant No error.46 */47 appshell.fs.NO_ERROR = 0;48 49 /**50 * @constant Unknown error occurred.51 */52 appshell.fs.ERR_UNKNOWN = 1;53 54 /**55 * @constant Invalid parameters passed to function.56 */57 appshell.fs.ERR_INVALID_PARAMS = 2;58 59 /**60 * @constant File or directory was not found.61 */62 appshell.fs.ERR_NOT_FOUND = 3;63 64 /**65 * @constant File or directory could not be read.66 */67 appshell.fs.ERR_CANT_READ = 4;68 69 /**70 * @constant An unsupported encoding value was specified.71 */72 appshell.fs.ERR_UNSUPPORTED_ENCODING = 5;73 74 /**75 * @constant File could not be written.76 */77 appshell.fs.ERR_CANT_WRITE = 6;78 79 /**80 * @constant Target directory is out of space. File could not be written.81 */82 appshell.fs.ERR_OUT_OF_SPACE = 7;83 84 /**85 * @constant Specified path does not point to a file.86 */87 appshell.fs.ERR_NOT_FILE = 8;88 89 /**90 * @constant Specified path does not point to a directory.91 */92 appshell.fs.ERR_NOT_DIRECTORY = 9;93 94 /**95 * @constant Specified file already exists.96 */97 appshell.fs.ERR_FILE_EXISTS = 10;9899 /**100 * @constant The required browser is not installed101 */102 appshell.fs.ERR_BROWSER_NOT_INSTALLED = 11;103 104 /**105 * @constant User cancelled the password dialog while installing command line tools.106 */107 appshell.app.ERR_CL_TOOLS_CANCELLED = 12;108 109 /**110 * @constant Removing and existing sysmlink failed111 */112 appshell.app.ERR_CL_TOOLS_RMFAILED = 13;113 114 /**115 * @constant Directory, into which symlink needs to be copied, creation failed116 */117 appshell.app.ERR_CL_TOOLS_MKDIRFAILED = 14;118 119 /**120 * @constant Symlink creation failed121 */122 appshell.app.ERR_CL_TOOLS_SYMLINKFAILED = 15;123 124 /**125 * @constant Brackets could not create an Authorization object126 */127 appshell.app.ERR_CL_TOOLS_SERVFAILED = 16;128129 /**130 * @constant Command Line Installation not supported on the specific platform131 */132 appshell.app.ERR_CL_TOOLS_NOTSUPPORTED = 17;133 134 /**135 * @constant No error.136 */137 appshell.app.NO_ERROR = 0;138139 /**140 * @constant Node has not yet launched. Try again later.141 */142 appshell.app.ERR_NODE_NOT_YET_STARTED = -1;143144 /**145 * @constant Node is in the process of launching, but has not yet set the port.146 * Try again later.147 */148 appshell.app.ERR_NODE_PORT_NOT_YET_SET = -2;149150 /**151 * @constant Node encountered a fatal error while launching or running.152 * It cannot be restarted.153 */154 appshell.app.ERR_NODE_FAILED = -3;155156 /*157 * @private 158 */159 var _dummyCallback = function () {160 };161162 /**163 * Display the OS File Open dialog, allowing the user to select164 * files or directories.165 *166 * @param {boolean} allowMultipleSelection If true, multiple files/directories can be selected.167 * @param {boolean} chooseDirectory If true, only directories can be selected. If false, only 168 * files can be selected.169 * @param {string} title Tile of the open dialog.170 * @param {string} initialPath Initial path to display in the dialog. Pass NULL or "" to 171 * display the last path chosen.172 * @param {Array.<string>} fileTypes Array of strings specifying the selectable file extensions. 173 * These strings should not contain '.'. This parameter is ignored when 174 * chooseDirectory=true.175 * @param {function(err, selection)} callback Asynchronous callback function. The callback gets two arguments 176 * (err, selection) where selection is an array of the names of the selected files.177 * Possible error values:178 * NO_ERROR179 * ERR_INVALID_PARAMS180 *181 * @return None. This is an asynchronous call that sends all return information to the callback.182 */183 native function ShowOpenDialog();184 appshell.fs.showOpenDialog = function (allowMultipleSelection, chooseDirectory, title, initialPath, fileTypes, callback) {185 setTimeout(function () {186 ShowOpenDialog(callback, allowMultipleSelection, chooseDirectory,187 title || 'Open', initialPath || '',188 fileTypes ? fileTypes.join(' ') : '');189 }, 10);190 };191 192 /**193 * Display the OS Save dialog, allowing the user to provide a path and name to save a file.194 *195 * @param {string} title Title of the Save As dialog.196 * @param {string} initialPath Initial path to display in the dialog. Pass NULL or "" to197 * display the last path chosen.198 * @param {function(err, selection)} callback Asynchronous callback function. The callback gets two arguments199 * (err, absolutefilepath) where absolutefilepath is a string with the absolute path to the file.200 * Possible error values:201 * NO_ERROR202 * ERR_INVALID_PARAMS203 *204 * @return None. This is an asynchronous call that sends all return information to the callback.205 */206 native function ShowSaveDialog();207 appshell.fs.showSaveDialog = function (title, initialPath, proposedNewFilename, callback) {208 setTimeout(function () {209 ShowSaveDialog(callback,210 title || 'Save As', initialPath || '', proposedNewFilename || '');211 }, 10);212 };213214 /**215 * Check whether a given path is from a network drive. 216 *217 * @param {string} path The path to check for a network drive.218 * @param {function(err, isRemote)} callback Asynchronous callback function. The callback gets two arguments 219 * (err, isRemote) where isRemote indicates whether the given path is a mapped network drive or not.220 * 221 * Possible error values:222 * NO_ERROR223 * ERR_INVALID_PARAMS224 * ERR_NOT_FOUND225 *226 * @return None. This is an asynchronous call that sends all return information to the callback.227 */228 native function IsNetworkDrive();229 appshell.fs.isNetworkDrive = function (path, callback) {230 var resultString = IsNetworkDrive(callback, path);231 };232 233 /**234 * Reads the contents of a directory. 235 *236 * @param {string} path The path of the directory to read.237 * @param {function(err, files)} callback Asynchronous callback function. The callback gets two arguments 238 * (err, files) where files is an array of the names of the files239 * in the directory excluding '.' and '..'.240 * Possible error values:241 * NO_ERROR242 * ERR_UNKNOWN243 * ERR_INVALID_PARAMS244 * ERR_NOT_FOUND245 * ERR_CANT_READ246 * 247 * @return None. This is an asynchronous call that sends all return information to the callback.248 */249 native function ReadDir();250 appshell.fs.readdir = function (path, callback) {251 var resultString = ReadDir(callback, path);252 };253 254 /**255 * Create a new directory.256 *257 * @param {string} path The path of the directory to create.258 * @param {number} mode The permissions for the directory, in numeric format (ie 0777)259 * @param {function(err)=} callback Asynchronous callback function. The callback gets one argument.260 *261 * @return None. This is an asynchronous call that sends all return information to the callback.262 **/263 native function MakeDir();264 appshell.fs.makedir = function (path, mode, callback) {265 // RFC: mode should be 0777 if it's undefined266 MakeDir(callback || _dummyCallback, path, mode);267 };268269 /**270 * Rename a file or directory.271 *272 * @param {string} oldPath The old name of the file or directory.273 * @param {string} newPath The new name of the file or directory.274 * @param {function(err)=} callback Asynchronous callback function. The callback gets one argument.275 *276 * @return None. This is an asynchronous call that sends all return information to the callback.277 **/278 native function Rename();279 appshell.fs.rename = function(oldPath, newPath, callback) {280 Rename(callback || _dummyCallback, oldPath, newPath);281 };282 283 /**284 * Get information for the selected file or directory.285 *286 * @param {string} path The path of the file or directory to read.287 * @param {function(err, stats)} callback Asynchronous callback function. The callback gets two arguments 288 * (err, stats) where stats is an object with isFile() and isDirectory() functions.289 * Possible error values:290 * NO_ERROR291 * ERR_UNKNOWN292 * ERR_INVALID_PARAMS293 * ERR_NOT_FOUND294 * 295 * @return None. This is an asynchronous call that sends all return information to the callback.296 */297 native function GetFileInfo();298 appshell.fs.stat = function (path, callback) {299 GetFileInfo(function (err, modtime, isDir, size, realPath) {300 callback(err, {301 isFile: function () {302 return !isDir;303 },304 isDirectory: function () {305 return isDir;306 },307 mtime: new Date(modtime * 1000), // modtime is seconds since 1970, convert to ms308 size: new Number(size),309 realPath: realPath ? realPath : null310 });311 }, path);312 };313 314 315 316 /**317 * Quits native shell application318 */319 native function QuitApplication();320 appshell.app.quit = function () {321 QuitApplication();322 };323 324 /**325 * Abort a quit operation326 */327 native function AbortQuit();328 appshell.app.abortQuit = function () {329 AbortQuit();330 };331332 /**333 * Invokes developer tools application334 */335 native function ShowDeveloperTools();336 appshell.app.showDeveloperTools = function () {337 ShowDeveloperTools();338 };339340 /**341 * Returns the TCP port of the current Node server 342 *343 * @param {function(err, port)} callback Asynchronous callback function. The callback gets two arguments 344 * (err, port) where port is the TCP port of the running server.345 * Possible error values:346 * ERR_NODE_PORT_NOT_SET = -1;347 * ERR_NODE_NOT_RUNNING = -2;348 * ERR_NODE_FAILED = -3;349 * 350 * @return None. This is an asynchronous call that sends all return information to the callback.351 */352 native function GetNodeState();353 appshell.app.getNodeState = function (callback) {354 GetNodeState(callback);355 };356357 /**358 * Reads the entire contents of a file. 359 *360 * @param {string} path The path of the file to read.361 * @param {string} encoding The encoding for the file. The only supported encoding is 'utf8'.362 * @param {function(err, data)} callback Asynchronous callback function. The callback gets two arguments 363 * (err, data) where data is the contents of the file.364 * Possible error values:365 * NO_ERROR366 * ERR_UNKNOWN367 * ERR_INVALID_PARAMS368 * ERR_NOT_FOUND369 * ERR_CANT_READ370 * ERR_UNSUPPORTED_ENCODING371 * 372 * @return None. This is an asynchronous call that sends all return information to the callback.373 */374 native function ReadFile();375 appshell.fs.readFile = function (path, encoding, callback) {376 ReadFile(callback, path, encoding);377 };378 379 /**380 * Write data to a file, replacing the file if it already exists. 381 *382 * @param {string} path The path of the file to write.383 * @param {string} data The data to write to the file.384 * @param {string} encoding The encoding for the file. The only supported encoding is 'utf8'.385 * @param {function(err)=} callback Asynchronous callback function. The callback gets one argument (err).386 * Possible error values:387 * NO_ERROR388 * ERR_UNKNOWN389 * ERR_INVALID_PARAMS390 * ERR_UNSUPPORTED_ENCODING391 * ERR_CANT_WRITE392 * ERR_OUT_OF_SPACE393 * 394 * @return None. This is an asynchronous call that sends all return information to the callback.395 */396 native function WriteFile();397 appshell.fs.writeFile = function (path, data, encoding, callback) {398 WriteFile(callback || _dummyCallback, path, data, encoding);399 };400 401 /**402 * Set permissions for a file or directory.403 *404 * @param {string} path The path of the file or directory405 * @param {number} mode The permissions for the file or directory, in numeric format (ie 0777)406 * @param {function(err)=} callback Asynchronous callback function. The callback gets one argument (err).407 * Possible error values:408 * NO_ERROR409 * ERR_UNKNOWN410 * ERR_INVALID_PARAMS411 * ERR_CANT_WRITE412 *413 * @return None. This is an asynchronous call that sends all return information to the callback.414 */415 native function SetPosixPermissions();416 appshell.fs.chmod = function (path, mode, callback) {417 SetPosixPermissions(callback || _dummyCallback, path, mode);418 };419 420 /**421 * Delete a file permanently.422 *423 * @param {string} path The path of the file to delete424 * @param {function(err)=} callback Asynchronous callback function. The callback gets one argument (err).425 * Possible error values:426 * NO_ERROR427 * ERR_UNKNOWN428 * ERR_INVALID_PARAMS429 * ERR_NOT_FOUND430 * ERR_NOT_FILE431 *432 * @return None. This is an asynchronous call that sends all return information to the callback.433 */434 native function DeleteFileOrDirectory();435 appshell.fs.unlink = function (path, callback) {436 DeleteFileOrDirectory(callback || _dummyCallback, path);437 };438 439 /**440 * Delete a file non-permanently (to trash).441 *442 * @param {string} path The path of the file or directory to delete443 * @param {function(err)=} callback Asynchronous callback function. The callback gets one argument (err).444 * Possible error values:445 * NO_ERROR446 * ERR_UNKNOWN447 * ERR_INVALID_PARAMS448 * ERR_NOT_FOUND449 * ERR_NOT_FILE450 *451 * @return None. This is an asynchronous call that sends all return information to the callback.452 */453 native function MoveFileOrDirectoryToTrash();454 appshell.fs.moveToTrash = function (path, callback) {455 MoveFileOrDirectoryToTrash(callback || _dummyCallback, path);456 }; 457458 /**459 * Copy src to dest, replacing the file at dest if it already exists.460 *461 * @param {string} path The path of the file to copy.462 * @param {string} data The destination to copy the file to463 * @param {function(err)} callback Asynchronous callback function. The callback gets one argument (err).464 * Possible error values:465 * NO_ERROR466 * ERR_UNKNOWN467 * ERR_INVALID_PARAMS468 * ERR_UNSUPPORTED_ENCODING469 * ERR_OUT_OF_SPACE470 *471 * @return None. This is an asynchronous call that sends all return information to the callback.472 */473 native function CopyFile();474 appshell.fs.copyFile = function (src, dest, callback) {475 CopyFile(callback || _dummyCallback, src, dest);476 };477 478 /**479 * Return the number of milliseconds that have elapsed since the application480 * was launched. 481 */482 native function GetElapsedMilliseconds();483 appshell.app.getElapsedMilliseconds = function () {484 return GetElapsedMilliseconds();485 }486 487 /**488 * Open the live browser489 *490 * @param {string} url491 * @param {boolean} enableRemoteDebugging492 * @param {function(err)=} callback Asynchronous callback function with one argument (the error)493 * Possible error values:494 * NO_ERROR495 * ERR_INVALID_PARAMS - invalid parameters496 * ERR_UNKNOWN - unable to launch the browser497 * ERR_NOT_FOUND - unable to find a browers to launch498 *499 * @return None. This is an asynchronous call that sends all return information to the callback.500 */501 native function OpenLiveBrowser();502 appshell.app.openLiveBrowser = function (url, enableRemoteDebugging, callback) {503 // enableRemoteDebugging flag is ignored on mac504 setTimeout(function() {505 OpenLiveBrowser(callback || _dummyCallback, url, enableRemoteDebugging);506 }, 0);507 };508 509 /**510 * Attempts to close the live browser. The browser can still give the user a chance to override511 * the close attempt if there is a page with unsaved changes. This function will fire the512 * callback when the browser is closed (No_ERROR) or after a three minute timeout (ERR_UNKNOWN). 513 *514 * @param {function(err)} callback Asynchronous callback function with one argument (the error) 515 * Possible error values:516 * NO_ERROR (all windows are closed by the time the callback is fired)517 * ERR_UNKNOWN - windows are currently open, though the user may be getting prompted by the 518 * browser to close them519 *520 * @return None. This is an asynchronous call that sends all return information to the callback.521 */522 native function CloseLiveBrowser();523 appshell.app.closeLiveBrowser = function (callback) {524 CloseLiveBrowser(callback || _dummyCallback);525 };526 527 /**528 * Open a URL in the default OS browser window. 529 *530 * @param {function(err)} callback Asynchronous callback function with one argument (the error)531 * NOTE: null or undefined can be used for this argument to avoid the callback532 * @param {string} url URL to open in the browser.533 *534 * @return None. This is an asynchronous call that sends all return information to the callback.535 */536 native function OpenURLInDefaultBrowser();537 appshell.app.openURLInDefaultBrowser = function (url, callback) {538 OpenURLInDefaultBrowser(callback || _dummyCallback, url);539 };540 541 /**542 * Get files passed to app at startup.543 *544 * @param {function(err, files)} callback Asynchronous callback function with two arguments:545 * err - error code546 * files - Array of file paths to open547 *548 * @return None. This is an asynchronous call that sends all return information to the callback.549 */550 native function GetPendingFilesToOpen();551 appshell.app.getPendingFilesToOpen = function (callback) {552 GetPendingFilesToOpen(function (err, files) {553 // "files" is a string, convert to Array554 callback(err, (err || !files) ? [] : JSON.parse(files));555 });556 };557558 /**559 * Get files and folders dropped onto the application.560 *561 * @param {function(err, files)} callback Asynchronous callback function with two arguments:562 * err - error code563 * files - Array of file paths564 *565 * @return None. This is an asynchronous call that sends all return information to the callback.566 */567 native function GetDroppedFiles();568 appshell.app.getDroppedFiles = function (callback) {569 GetDroppedFiles(function (err, files) {570 // "files" is a string, convert to Array571 callback(err, (err || !files) ? [] : JSON.parse(files));572 });573 };574 575 /**576 * Get the remote debugging port used by the appshell.577 *578 * @return int. The remote debugging port used by the appshell.579 */580 native function GetRemoteDebuggingPort();581 appshell.app.getRemoteDebuggingPort = function () {582 return GetRemoteDebuggingPort();583 };584 585 /**586 * Set menu enabled/checked state.587 * @param {string} command ID of the menu item.588 * @param {bool} enabled bool to enable or disable the command589 * @param {bool} checked bool to set the 'checked' attribute of the menu item.590 * @param {?function(integer)} callback Asynchronous callback function. The callback gets one argument, error code.591 * Possible error values:592 * NO_ERROR593 * ERR_INVALID_PARAMS594 * @return None. This is an asynchronous call that is not meant to have a return595 */596 native function SetMenuItemState();597 appshell.app.setMenuItemState = function (commandid, enabled, checked, callback) {598 SetMenuItemState(callback || _dummyCallback, commandid, enabled, checked);599 };600601 /**602 * Get menu enabled/checked state. For tests.603 * @param {string} command ID of the menu item.604 * @param {function(integer, bool, bool)} callback Asynchronous callback function.605 * The callback gets three arguments, error code, enabled, checked.606 * Possible error values:607 * NO_ERROR608 * ERR_INVALID_PARAMS609 * @return None. This is an asynchronous call that is not meant to have a return610 */611 native function GetMenuItemState();612 appshell.app.getMenuItemState = function (commandid, callback) {613 GetMenuItemState(callback, commandid);614 };615616 /**617 * Add a top level menu.618 * @param {string} title Menu title to display, e.g. "File"619 * @param {string} id Menu ID, e.g. "file"620 * @param {string} position Where to put the item; values are "before", "after", "first", "last", and ""621 * @param {string} relativeId The ID of the menu to which is this relative, for position "before" and "after"622 * @param {?function(integer)} callback Asynchronous callback function. The callback gets one argument, error code.623 * Possible error values:624 * NO_ERROR625 * ERR_INVALID_PARAMS626 * @return None. This is an asynchronous call that is not meant to have a return627 */628 native function AddMenu();629 appshell.app.addMenu = function (title, id, position, relativeId, callback) {630 position = position || '';631 relativeId = relativeId || '';632 AddMenu(callback || _dummyCallback, title, id, position, relativeId);633 };634635 /**636 * Add a menu item.637 * @param {string} parentId ID of containing menu638 * @param {string} title Menu title to display, e.g. "Open"639 * @param {string} id Command ID, e.g. "file.open"640 * @param {string} key Shortcut, e.g. "Cmd-O"641 * @param {string} displayStr Shortcut to display in menu. If "", use key.642 * @param {string} position Where to put the item; values are "before", "after", "first", "last", 643 * "firstInSection", "lastInSection", and ""644 * @param {string} relativeId The ID of the menu item to which is this relative, for position "before" and "after"645 * @param {?function(integer)} callback Asynchronous callback function. The callback gets one argument, error code.646 * Possible error values:647 * NO_ERROR648 * ERR_INVALID_PARAMS649 * @return None. This is an asynchronous call that is not meant to have a return650 *651 * SPECIAL NOTE ABOUT EDIT MENU ITEMS652 * The Undo, Redo, Cut, Copy, Paste, and Select All items are handled specially. The JavaScript code653 * will get the first chance to handle the events. If they are *not* handled by JavaScript, the default654 * implementation will call those methods on the CEF instance.655 *656 * In order for this to work correctly, you MUST use the following ids for these menu item:657 * Undo: "edit.undo"658 * Redo: "edit.redo"659 * Cut: "edit.cut"660 * Copy: "edit.copy"661 * Paste: "edit.paste"662 * Select All: "edit.selectAll"663 */664 native function AddMenuItem();665 appshell.app.addMenuItem = function (parentId, title, id, key, displayStr, position, relativeId, callback) {666 key = key || '';667 position = position || '';668 relativeId = relativeId || '';669 AddMenuItem(callback || _dummyCallback, parentId, title, id, key, displayStr, position, relativeId);670 };671672 /**673 * Change the title of a menu or menu item.674 * @param {string} commandid Menu/Command ID, e.g. "file" or "file.open"675 * @param {string} title Menu title to display, e.g. "File" or "Open"676 * @param {?function(integer)} callback Asynchronous callback function. The callback gets one argument, error code.677 * Possible error values:678 * NO_ERROR679 * ERR_INVALID_PARAMS, ERR_NOT_FOUND, ERR_UNKNOWN680 * @return None. This is an asynchronous call that is not meant to have a return681 */682 native function SetMenuTitle();683 appshell.app.setMenuTitle = function (commandid, title, callback) {684 SetMenuTitle(callback || _dummyCallback, commandid, title);685 };686 687 /**688 * Get menu title. For tests.689 * @param {string} commandid ID of the menu item.690 * @param {function(integer, string)} callback Asynchronous callback function.691 * The callback gets two arguments, error code, title.692 * Possible error values:693 * NO_ERROR694 * ERR_INVALID_PARAMS695 * @return None. This is an asynchronous call that is not meant to have a return696 */697 native function GetMenuTitle();698 appshell.app.getMenuTitle = function (commandid, callback) {699 GetMenuTitle(callback, commandid);700 };701702 /**703 * Set menu item shortuct. 704 * @param {string} commandId ID of the menu item.705 * @param {string} shortcut Shortcut string, like "Cmd-U".706 * @param {string} displayStr String to display in menu. If "", use shortcut.707 * @param {?function (err)} callback Asynchronous callback function. The callback gets an error code.708 * @return None. This is an asynchronous call that sends all return information to the callback.709 */710 native function SetMenuItemShortcut();711 appshell.app.setMenuItemShortcut = function (commandId, shortcut, displayStr, callback) {712 SetMenuItemShortcut(callback || _dummyCallback, commandId, shortcut, displayStr);713 };714 715 /**716 * Remove menu associated with commandId.717 * @param {string} commandid ID of the menu item.718 * @param {function(err)=} callback Asynchronous callback function. The callback gets an error code.719 * Possible error values:720 * NO_ERROR721 * ERR_INVALID_PARAMS722 * ERR_NOT_FOUND723 * 724 * @return None. This is an asynchronous call that sends all return information to the callback.725 */726 native function RemoveMenu();727 appshell.app.removeMenu = function (commandId, callback) {728 RemoveMenu(callback || _dummyCallback, commandId);729 };730731 /**732 * Remove menuitem associated with commandId.733 * @param {string} commandid ID of the menu item.734 * @param {function(err)=} callback Asynchronous callback function. The callback gets an error code.735 * Possible error values:736 * NO_ERROR737 * ERR_INVALID_PARAMS738 * ERR_NOT_FOUND739 * 740 * @return None. This is an asynchronous call that sends all return information to the callback.741 */742 native function RemoveMenuItem();743 appshell.app.removeMenuItem = function (commandId, callback) {744 RemoveMenuItem(callback || _dummyCallback, commandId);745 };746 747 /**748 * Get the position of the menu or menu item associated with commandId.749 * @param {string} command ID of the menu or menu item.750 * @param {function(err, parentId, index)} callback Asynchronous callback function. The callback gets an error code,751 * the ID of the immediate parent and the index of the menu or menu item. If the command is a top level menu,752 * it does not have a parent and parentId will be NULL. The returned index will be -1 if the command is not found.753 * In those not-found cases, the error value will also be ERR_NOT_FOUND.754 * Possible error values:755 * NO_ERROR756 * ERR_INVALID_PARAMS757 * ERR_NOT_FOUND758 * 759 * @return None. This is an asynchronous call that sends all return information to the callback.760 */761 native function GetMenuPosition();762 appshell.app.getMenuPosition = function (commandId, callback) {763 GetMenuPosition(callback, commandId);764 };765 766 /**767 * Return the user's language per operating system preferences.768 */769 native function GetCurrentLanguage();770 Object.defineProperty(appshell.app, "language", {771 writeable: false,772 get : function() { return GetCurrentLanguage(); },773 enumerable : true,774 configurable : false775 });776 777 /**778 * Returns the full path of the application support directory.779 * On the Mac, it's /Users/<user>/Library/Application Support[/GROUP_NAME]/APP_NAME780 * On Windows, it's C:\Users\<user>\AppData\Roaming[\GROUP_NAME]\APP_NAME781 *782 * @return {string} Full path of the application support directory783 */784 native function GetApplicationSupportDirectory();785 appshell.app.getApplicationSupportDirectory = function () {786 return GetApplicationSupportDirectory();787 };788 789 /**790 * Returns the full path of the user's documents directory.791 * On the Mac, it's /Users/<user>/Documents792 * On Windows, it's C:\Users\<user>\Documents (Windows Vista, 7, 8),793 * C:\Documents and Settings\<user>\My Documents (Windows XP)794 *795 * @return {string} Full path of the application support directory796 */797 native function GetUserDocumentsDirectory();798 appshell.app.getUserDocumentsDirectory = function () {799 return GetUserDocumentsDirectory();800 };801802803 /**804 * Open the specified folder in an OS file window.805 *806 * @param {string} path Path of the folder to show.807 * @param {function(err)=} callback Asyncrhonous callback function with one argument (the error)808 *809 * @return None. This is an asynchronous call that sends all return information to the callback.810 */811 native function ShowOSFolder();812 appshell.app.showOSFolder = function (path, callback) {813 ShowOSFolder(callback || _dummyCallback, path);814 };815 816 /**817 * Open the extensions folder in an OS file window.818 *819 * @param {string} appURL Not used820 * @param {function(err)=} callback Asynchronous callback function with one argument (the error)821 *822 * @return None. This is an asynchronous call that sends all return information to the callback.823 */824 appshell.app.showExtensionsFolder = function (appURL, callback) {825 appshell.app.showOSFolder(GetApplicationSupportDirectory() + "/extensions", callback);826 };827828 /**829 * Drag the main window830 *831 * @return None. This is an asynchronous call that sends all return information to the callback.832 */833 native function DragWindow();834 appshell.app.dragWindow = function () {835 DragWindow();836 };837838 /**839 * Get the browser zoom level840 *841 * @return None. This is an asynchronous call that sends all return information to the callback.842 */843 native function GetZoomLevel();844 appshell.app.getZoomLevel = function (callback) {845 GetZoomLevel(callback || _dummyCallback);846 };847848 /**849 * Set the browser zoom level850 *851 * @param {number} 852 *853 * @return None. This is an asynchronous call that sends all return information to the callback.854 */855 native function SetZoomLevel();856 appshell.app.setZoomLevel = function (zoomLevel, callback) {857 SetZoomLevel(callback || _dummyCallback, zoomLevel);858 };859860 /**861 * Install command line scripts to make Brackets launchable from command line.862 * Right now usage is restricted to MAC only.863 *864 * @param {number}865 *866 * @return int. The remote debugging port used by the appshell.867 */868 native function InstallCommandLineTools();869 appshell.app.installCommandLine = function (callback) {870 InstallCommandLineTools(callback);871 };872 873 874 // Alias the appshell object to brackets. This is temporary and should be removed.875 brackets = appshell;
...
main.js
Source:main.js
...274 if (brackets.inBrowser) {275 result.resolve();276 } else {277 var Inspector = brackets.getModule("LiveDevelopment/Inspector/Inspector");278 var port = brackets.app.getRemoteDebuggingPort ? brackets.app.getRemoteDebuggingPort() : 9234;279 Inspector.getDebuggableWindows("127.0.0.1", port)280 .fail(result.reject)281 .done(function (response) {282 var page = response[0];283 if (!page || !page.webSocketDebuggerUrl) {284 result.reject();285 return;286 }287 var _socket = new WebSocket(page.webSocketDebuggerUrl);288 // Disable the cache289 _socket.onopen = function _onConnect() {290 _socket.send(JSON.stringify({ id: 1, method: "Network.setCacheDisabled", params: { "cacheDisabled": true } }));291 };292 // The first message will be the confirmation => disconnected to allow remote debugging of Brackets...
chrome.js
Source:chrome.js
...168 return Promise["try"]((function(_this) {169 return function() {170 var args;171 args = _this._getArgs(options);172 return getRemoteDebuggingPort().then(function(port) {173 args.push("--remote-debugging-port=" + port);174 return Promise.all([utils.ensureCleanCache(browser, isTextTerminal), pluginsBeforeBrowserLaunch(options.browser, args), port]);175 });176 };177 })(this)).spread((function(_this) {178 return function(cacheDir, args, port) {179 return Promise.all([_this._writeExtension(browser, isTextTerminal, options.proxyUrl, options.socketIoRoute), _removeRootExtension(), _disableRestorePagesPrompt(userDir)]).spread(function(extDest) {180 args = _normalizeArgExtensions(extDest, args);181 args.push("--user-data-dir=" + userDir);182 args.push("--disk-cache-dir=" + cacheDir);183 debug("launching in chrome with debugging port", {184 url: url,185 args: args,186 port: port...
brackets_api.js
Source:brackets_api.js
1// Copyright (c) 2012 Adobe Systems Incorporated. All rights reserved.2// Copyright (c) 2013 Intel Corporation. All rights reserved.3//4// Permission is hereby granted, free of charge, to any person obtaining a5// copy of this software and associated documentation files (the "Software"),6// to deal in the Software without restriction, including without limitation7// the rights to use, copy, modify, merge, publish, distribute, sublicense,8// and/or sell copies of the Software, and to permit persons to whom the9// Software is furnished to do so, subject to the following conditions:10//11// The above copyright notice and this permission notice shall be included in12// all copies or substantial portions of the Software.13//14// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR15// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,16// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE17// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER18// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING19// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER20// DEALINGS IN THE SOFTWARE.21exports.app = {22 NO_ERROR: 0,23};24exports.fs = {25 NO_ERROR: 0,26 ERR_UNKNOWN: 1,27 ERR_INVALID_PARAMS: 2,28 ERR_NOT_FOUND: 3,29 ERR_CANT_READ: 4,30 ERR_UNSUPPORTED_ENCODING: 5,31 ERR_CANT_WRITE: 6,32 ERR_OUT_OF_SPACE: 7,33 ERR_NOT_FILE: 8,34 ERR_NOT_DIRECTORY: 9,35 ERR_FILE_EXISTS: 10,36};37var postMessage = (function() {38 var callbacks = {};39 var next_reply_id = 0;40 extension.setMessageListener(function(json) {41 var msg = JSON.parse(json);42 var reply_id = msg._reply_id;43 var callback = callbacks[reply_id];44 if (callback) {45 delete msg._reply_id;46 delete callbacks[reply_id];47 callback(msg);48 } else {49 console.log('Invalid reply_id received from Brackets extension: ' + reply_id);50 }51 });52 return function(msg, callback) {53 var reply_id = next_reply_id;54 next_reply_id += 1;55 callbacks[reply_id] = callback;56 msg._reply_id = reply_id.toString();57 extension.postMessage(JSON.stringify(msg));58 }59})();60// PROPERTIES61Object.defineProperty(exports.app, "language", {62 writeable: false,63 get : function() { return (navigator.language).toLowerCase(); },64 enumerable : true,65 configurable : false66});67// SETUP MESSAGES68var debugging_port = 0;69var msg = {70 'cmd': 'GetRemoteDebuggingPort'71};72postMessage(msg, function(r) {73 debugging_port = r.debugging_port;74});75// API76exports.fs.readFile = function(path, encoding, callback) {77 var msg = {78 'cmd': 'ReadFile',79 'path': path,80 'encoding': encoding81 };82 postMessage(msg, function(r) {83 callback(r.error, r.data);84 });85};86exports.fs.stat = function(path, callback) {87 var msg = {88 'cmd': 'GetFileModificationTime',89 'path': path90 };91 postMessage(msg, function (r) {92 callback(r.error, {93 isFile: function () {94 return !r.is_dir;95 },96 isDirectory: function () {97 return r.is_dir;98 },99 mtime: new Date(r.modtime * 1000)100 });101 });102};103exports.fs.readdir = function(path, callback) {104 var msg = {105 'cmd': 'ReadDir',106 'path': path107 };108 postMessage(msg, function(r) {109 callback(r.error, r.files)110 });111};112exports.fs.writeFile = function(path, data, encoding, callback) {113 var msg = {114 'cmd': 'WriteFile',115 'path': path,116 'data': data,117 'encoding': encoding118 };119 postMessage(msg, function(r) {120 callback(r.error);121 });122};123exports.app.openLiveBrowser = function(url, enableRemoteDebugging, callback) {124 var msg = {125 'cmd': 'OpenLiveBrowser',126 'url': url127 };128 postMessage(msg, function(r) {129 callback(r.error);130 });131};132exports.app.openURLInDefaultBrowser = function(callback, url) {133 var msg = {134 'cmd': 'OpenURLInDefaultBrowser',135 'url': url136 };137 postMessage(msg, function(r) {138 callback(r.error);139 });140};141exports.fs.rename = function(oldPath, newPath, callback) {142 var msg = {143 'cmd': 'Rename',144 'oldPath': oldPath,145 'newPath': newPath146 };147 postMessage(msg, function(r) {148 callback(r.error);149 });150};151exports.app.getApplicationSupportDirectory = function() {152 // FIXME(cmarcelo): Synchronous function. We need to store this153 // value when initializing the plugin.154 return '/tmp/brackets-support';155};156exports.app.getNodeState = function(callback) {157 callback(true, 0);158};159exports.app.quit = function() {160 window.close();161};162exports.fs.makedir = function(path, mode, callback) {163 var msg = {164 'cmd': 'MakeDir',165 'path': path,166 'mode': mode167 };168 postMessage(msg, function(r) {169 callback(r.error);170 });171};172exports.fs.unlink = function(path, callback) {173 var msg = {174 'cmd': 'DeleteFileOrDirectory',175 'path': path176 };177 postMessage(msg, function(r) {178 callback(r.error);179 });180};181exports.fs.moveToTrash = function(path, callback) {182 var msg = {183 'cmd': 'MoveFileOrDirectoryToTrash',184 'path': path185 };186 postMessage(msg, function(r) {187 callback(r.error);188 });189};190exports.fs.isNetworkDrive = function(path, callback) {191 var msg = {192 'cmd': 'IsNetworkDrive',193 'path': path194 };195 postMessage(msg, function(r) {196 callback(r.error, r.is_network_drive);197 });198};199xwalk.menu = xwalk.menu || {};200xwalk.menu.onActivatedMenuItem = function(item) {201 brackets.shellAPI.executeCommand(item);202};203exports.app.addMenu = function(title, id, position, relativeId, callback) {204 xwalk.menu.addMenu(title, id, position, relativeId);205 callback(exports.app.NO_ERROR);206};207exports.app.addMenuItem = function(parentId, title, id, key, displayStr, position, relativeId, callback) {208 xwalk.menu.addMenuItem(parentId, title, id, key, displayStr, position, relativeId);209 callback(exports.app.NO_ERROR);210}211exports.app.setMenuTitle = function(commandid, title, callback) {212 xwalk.menu.setMenuTitle(commandid, title);213 callback(exports.app.NO_ERROR);214}215exports.app.setMenuItemState = function(commandid, enabled, checked, callback) {216 xwalk.menu.setMenuItemState(commandid, enabled, checked);217 callback(exports.app.NO_ERROR);218}219exports.app.setMenuItemShortcut = function(commandid, shortcut, displayStr, callback) {220 xwalk.menu.setMenuItemShortcut(commandid, shortcut, displayStr);221 callback(exports.app.NO_ERROR);222}223exports.app.showOSFolder = function(path, callback) {224 var msg = {225 'cmd': 'ShowOSFolder',226 'path': path227 };228 postMessage(msg, function(r) {229 callback(r.error);230 });231};232exports.app.showExtensionsFolder = function(appURL, callback) {233 return exports.app.showOSFolder(exports.app.getApplicationSupportDirectory() + '/extensions', callback);234};235exports.app.getPendingFilesToOpen = function(callback) {236 var msg = {237 'cmd': 'GetPendingFilesToOpen'238 };239 postMessage(msg, function(r) {240 callback(r.error, r.files);241 });242};243exports.app.getRemoteDebuggingPort = function() {244 return debugging_port;245};246xwalk.experimental = xwalk.experimental || {};247xwalk.experimental.dialog = xwalk.experimental.dialog || {};248exports.fs.showOpenDialog = function (allowMultipleSelection, chooseDirectory, title, initialPath, fileTypes, callback) {249 xwalk.experimental.dialog.showOpenDialog(allowMultipleSelection, chooseDirectory,250 title || 'Open', initialPath || '',251 fileTypes || [], function(err, file) { callback(err, [file]); });252}253exports.fs.showSaveDialog = function (title, initialPath, proposedNewFilename, callback) {254 xwalk.experimental.dialog.showSaveDialog(title || 'Save As', initialPath || '', proposedNewFilename || '', callback);...
rapido.js
Source:rapido.js
...33 else return promisedChromeLaunch()34 }35 }36 getSeleniumPort (driver) {37 return getRemoteDebuggingPort(driver)38 }39 load (url, options) {40 // If Rapido is using Selenium, the first argument a Selenium instance41 if (typeof url !== 'string') this.seleniumDriver = url42 // Launch a headless Chrome instance43 const config = Object.assign({}, { port: null, pid: null }, options)44 return this._resolveChrome(config).then(chrome => {45 // Connect to the newly opened chrome instance46 return Promise.all([chrome.port(), chrome])47 }).then(([port, chrome]) => {48 return Promise.all([chrome, CDP({ port })])49 }).then(([chrome, client]) => {50 const { Page, Tracing, Runtime } = client51 // Collect the data from the timeline tracing and the network and push it to the correct array...
protocol.js
Source:protocol.js
...63 // it seems to leave the browser instance open64 // need to clone connectOpts, CRI modifies it65 return chrome_remote_interface_1.default.List(lodash_1.default.clone(connectOpts)).then(findStartPage);66};67function getRemoteDebuggingPort() {68 return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () {69 const port = Number(process.env.CYPRESS_REMOTE_DEBUGGING_PORT);70 return port || utils_1.default.getPort();71 });72}73exports.getRemoteDebuggingPort = getRemoteDebuggingPort;74/**75 * Waits for the port to respond with connection to Chrome Remote Interface76 * @param {number} port Port number to connect to77 * @param {string} browserName Browser name, for warning/error messages78 */79const getWsTargetFor = (port, browserName) => {80 debug('Getting WS connection to CRI on port %d', port);81 (0, lazy_ass_1.default)(is.port(port), 'expected port number', port);...
browser-appshell.js
Source:browser-appshell.js
1/**2 * Browser shim for Brackets AppShell API. See:3 * https://github.com/adobe/brackets-shell4 * https://github.com/adobe/brackets-shell/blob/adf27a65d501fae71cc6d8905d6dc3d9460208a9/appshell/appshell_extensions.js5 * http://www.hyperlounge.com/blog/hacking-the-brackets-shell/6 */7(function(global, navigator) {8 var startupTime = Date.now();9 function getElapsedMilliseconds() {10 return (Date.now()) - startupTime;11 }12 function functionNotImplemented() {13 throw "Function not (yet) implemented in browser-appshell.";14 }15 // Provide an implementation of appshell.app as expected by src/utils/Global.js16 // and other parts of the code.17 var appshell = global.appshell = global.appshell || {};18 appshell.app = {19 ERR_NODE_FAILED: -3,20 ERR_NODE_NOT_YET_STARTED: -1,21 ERR_NODE_PORT_NOT_YET_SET: -2,22 NO_ERROR: 0,23 // TODO: deal with getter *and* setter24 language: navigator.language,25 abortQuit: function() {26 functionNotImplemented();27 },28 addMenu: function(title, id, position, relativeId, callback) {29 functionNotImplemented();30 },31 addMenuItem: function(parentId, title, id, key, displayStr, position, relativeId, callback) {32 functionNotImplemented();33 },34 closeLiveBrowser: function(callback) {35 functionNotImplemented();36 },37 dragWindow: function() {38 functionNotImplemented();39 },40 getApplicationSupportDirectory: function() {41 return '/ApplicationSupport';42 },43 getDroppedFiles: function(callback) {44 functionNotImplemented();45 },46 getElapsedMilliseconds: getElapsedMilliseconds,47 getMenuItemState: function(commandid, callback) {48 functionNotImplemented();49 },50 getMenuPosition: function(commandId, callback) {51 functionNotImplemented();52 },53 getMenuTitle: function(commandid, callback) {54 functionNotImplemented();55 },56 getPendingFilesToOpen: function(callback) {57 // No files are passed to the app on startup, unless we want to support58 // URL based params with a list. For now return an empty array.59 callback(null, []);60 },61 getRemoteDebuggingPort: function() {62 functionNotImplemented();63 },64 getUserDocumentsDirectory: function() {65 functionNotImplemented();66 },67 openLiveBrowser: function(url, enableRemoteDebugging, callback) {68 functionNotImplemented();69 },70 openURLInDefaultBrowser: function(url, callback) {71 global.open(url);72 callback && callback();73 },74 quit: function() {75 functionNotImplemented();76 },77 removeMenu: function(commandId, callback) {78 functionNotImplemented();79 },80 removeMenuItem: function(commandId, callback) {81 functionNotImplemented();82 },83 setMenuItemShortcut: function(commandId, shortcut, displayStr, callback) {84 functionNotImplemented();85 },86 setMenuItemState: function(commandid, enabled, checked, callback) {87 functionNotImplemented();88 },89 setMenuTitle: function(commandid, title, callback) {90 functionNotImplemented();91 },92 showDeveloperTools: function() {93 functionNotImplemented();94 },95 showExtensionsFolder: function(appURL, callback) {96 functionNotImplemented();97 },98 showOSFolder: function(path, callback) {99 functionNotImplemented();100 },101 // https://github.com/adobe/brackets-shell/blob/959836be7a3097e2ea3298729ebd616247c83dce/appshell/appshell_node_process.h#L30102 getNodeState: function(callback) {103 callback(/* BRACKETS_NODE_FAILED = -3 */ -3);104 }105 };106 global.brackets = appshell;...
utils.js
Source:utils.js
1const { execSync } = require('child_process')2const { parse } = require('url')3const getFileData = fullURL => {4 const pathname = parse(fullURL).pathname.split('/')5 return { path: pathname.slice(0, -1).join('/'), name: pathname[pathname.length - 1] }6}7const shouldRunOn = (obj, utils) => {8 const action = utils.flag(obj, 'rapido.action')9 return action && (10 action === 'load' ||11 action === 'bundle' ||12 utils.flag(obj, 'rapido.timelineName')13 )14}15const timlineFilter = (timelineName, comparisonValue) => {16 return f => {17 const findValue = isUrl(comparisonValue) ? f.fullURL === comparisonValue : f.script === comparisonValue18 return f.name === timelineName && findValue19 }20}21const moduleFilter = mod => {22 const hasPath = mod.includes(require('path').sep)23 return a => {24 if (hasPath) return a === mod25 const [file] = a.split(require('path').sep).reverse()26 return a === file27 }28}29const isUrl = str => !!parse(str).protocol30const killProcess = pid => new Promise((resolve, reject) => {31 if (!pid) return resolve()32 const isWindows = process.platform === 'win32'33 try {34 (isWindows ? execSync(`taskkill /pid ${pid} /T /F`) : process.kill(pid))35 resolve()36 } catch (err) { reject(err) }37})38const getRemoteDebuggingPort = driver => {39 return driver.get('chrome://version').then(() => {40 return driver.findElement({ id: 'command_line' }).getText()41 }).then(text => {42 const remoteDebuggingPort = text43 .split(' ')44 .filter(s => s.includes('--remote-debugging-port'))[0]45 .split('=')[1]46 return +remoteDebuggingPort47 })48}49module.exports = {50 isUrl,51 getFileData,52 shouldRunOn,53 killProcess,54 timlineFilter,55 moduleFilter,56 getRemoteDebuggingPort...
Using AI Code Generation
1describe('My First Test', function() {2 it('Does not do much!', function() {3 cy.get('h1').should('contain', 'Kitchen Sink')4 })5})6describe('My First Test', function() {7 it('Does not do much!', function() {8 cy.get('h1').should('contain', 'Kitchen Sink')9 })10})11describe('My First Test', function() {12 it('Does not do much!', function() {13 cy.get('h1').should('contain', 'Kitchen Sink')14 })15})16describe('My First Test', function() {17 it('Does not do much!', function() {18 cy.get('h1').should('contain', 'Kitchen Sink')19 })20})21describe('My First Test', function() {22 it('Does not do much!', function() {23 cy.get('h1').should('contain', 'Kitchen Sink')24 })25})26describe('My First Test', function() {27 it('Does not do much!', function() {28 cy.get('h1').should('contain', 'Kitchen Sink')29 })30})31describe('My First Test', function() {32 it('Does not do much!', function() {33 cy.get('h1').should('contain', 'Kitchen Sink')34 })35})36describe('My First Test', function() {37 it('Does not do much!', function() {38 cy.get('h1').should('contain', 'Kitchen Sink')39 })40})41describe('My
Using AI Code Generation
1const cypress = require('cypress')2cypress.run({3 config: {4 },5})6 .then((results) => {7 console.log(results)8 process.exit(results.totalFailed)9 })10 .catch((err) => {11 console.error(err)12 process.exit(1)13 })14describe('Remote Debugging', () => {15 it('should work', () => {16 })17})
Using AI Code Generation
1const cypress = require('cypress');2cypress.run({3 config: {4 }5}).then((results) => {6 console.log(results);7 console.log('Done!');8});9{10}11module.exports = (on, config) => {12 on('before:browser:launch', (browser = {}, args) => {13 if (browser.name === 'chrome') {14 args.push('--remote-debugging-port=9222');15 return args;16 }17 });18};19import 'cypress-iframe';20import 'cypress-xpath';21import '@4tw/cypress-drag-drop';22import 'cypress-file-upload';23import 'cypress-iframe';24import 'cypress-axe';25import 'cypress-testing-library/add-commands';26import 'cypress-plugin-tab';27import 'cypress-plugin-snapshots/commands';28import './commands';29import './commands.js';30import './
Using AI Code Generation
1const cypress = require('cypress')2cypress.run({3 config: {4 }5}).then(() => {6 console.log('done')7})
Using AI Code Generation
1var cypress = require('cypress')2cypress.run({3 reporterOptions: {4 },5 config: {6 }7}).then((results) => {8 const port = results.runs[0].getRemoteDebuggingPort()9 console.log('Remote debugging port:', port)10})11{12 "scripts": {13 }14}15var cypress = require('cypress')16cypress.run({17 reporterOptions: {18 },19 config: {20 }21}).then((results) => {22 const port = results.runs[0].getRemoteDebuggingPort()23 console.log('Remote debugging port:', port)24})25{26 "scripts": {27 }28}29var cypress = require('cypress')30cypress.run({31 reporterOptions: {32 },33 config: {34 }35}).then((results) => {36 const port = results.runs[0].getRemoteDebuggingPort()37 console.log('Remote debugging port:', port)38})39{40 "scripts": {41 }42}43var cypress = require('cypress')44cypress.run({45 reporterOptions: {46 },47 config: {
Using AI Code Generation
1const cypress = require('cypress');2cypress.run({3 config: {4 }5}).then((results) => {6 console.log(results);7});8const cypress = require('cypress');9cypress.run({10 config: {11 }12}).then((results) => {13 console.log(results);14});15const cypress = require('cypress');16cypress.run({17 config: {18 }19}).then((results) => {20 console.log(results);21});22const cypress = require('cypress');23cypress.run({24 config: {25 }26}).then((results) => {27 console.log(results);28});29const cypress = require('cypress');30cypress.run({31 config: {
Using AI Code Generation
1const cypress = require('cypress')2const cypressChrome = require('cypress-chrome')3const cypressConfig = require('./cypress.json')4cypressChrome(cypressConfig.chromeWebSecurity)5 .then((cypressChrome) => {6 cypressChrome.getRemoteDebuggingPort()7 .then((port) => {8 console.log(port)9 })10 })11{12}13const cypressChrome = require('cypress-chrome')14module.exports = (on, config) => {15 on('before:browser:launch', (browser = {}, args) => {16 cypressChrome(browser, args)17 })18}19const cypressChrome = require('cypress-chrome')20const cypressConfig = require('../cypress.json')21cypressChrome(cypressConfig.chromeWebSecurity)22 .then((cypressChrome) => {23 cypressChrome.attachToChrome()24 })25describe('Test', () => {26 it('should pass', () => {27 })28})
Using AI Code Generation
1const cypress = require('cypress')2cypress.run({3 config: {4 },5}).then((results) => {6 console.log(results)7 console.log(port)8 const chromeLauncher = require('chrome-launcher');9 const CDP = require('chrome-remote-interface');10 chromeLauncher.launch({11 }).then(chrome => {12 console.log(`Chrome debugging port running on ${port}`);13 });14})15describe('My First Test', function() {16 it('Does not do much!', function() {17 cy.contains('type').click()18 cy.url().should('include', '/commands/actions')19 cy.get('.action-email')20 .type('
Using AI Code Generation
1const { getRemoteDebuggingPort } = require('cypress')2getRemoteDebuggingPort().then((port) => {3})4import { addMatchImageSnapshotCommand } from 'cypress-image-snapshot/command'5addMatchImageSnapshotCommand({6})7Cypress.Commands.add('getRemoteDebuggingPort', () => {8 return cy.task('getRemoteDebuggingPort')9})10module.exports = (on, config) => {11 on('task', {12 getRemoteDebuggingPort () {13 },14 })15}
Cypress is a renowned Javascript-based open-source, easy-to-use end-to-end testing framework primarily used for testing web applications. Cypress is a relatively new player in the automation testing space and has been gaining much traction lately, as evidenced by the number of Forks (2.7K) and Stars (42.1K) for the project. LambdaTest’s Cypress Tutorial covers step-by-step guides that will help you learn from the basics till you run automation tests on LambdaTest.
You can elevate your expertise with end-to-end testing using the Cypress automation framework and stay one step ahead in your career by earning a Cypress certification. Check out our Cypress 101 Certification.
Watch this 3 hours of complete tutorial to learn the basics of Cypress and various Cypress commands with the Cypress testing at LambdaTest.
Get 100 minutes of automation test minutes FREE!!