How to use createRunners method in qawolf

Best JavaScript code snippet using qawolf

run.js

Source:run.js Github

copy

Full Screen

1// enum2let RunType = {3 Unknown: 0,4 WeeklyMenu: 1,5 TodayMenu: 26};7Object.freeze(RunType);8///////////////////9/// [전역 변수 선언]10//var _menuArray = null;11//let _menuMap = null;12var _run01 = null;13var _run02 = null;14var _tracks = null;15var _timer = null;16var _dayOfWeekInfo = null;17var _dayRankTable = null;18let _currentRunType = RunType.Unknown;19// run 실행20function OnRun(menuArray)21{22 try23 {24 25 /*var msg = "";26 for (var idx = 0; idx < menuArray.length; idx++)27 {28 msg += "" + idx + ". " + menuArray[idx] + "\r\n";29 }30 alert(msg); */31 if (menuArray.length < 5)32 {33 alert ("메뉴는 5개 이상 입력되어야 합니다.");34 return;35 }36 // local storage clear37 for (var idx = 0; idx < 20; idx++)38 {39 SaveMenu(idx + 1, "");40 }41 // save42 for (var idx = 0; idx < menuArray.length; idx++)43 {44 SaveMenu(idx + 1, menuArray[idx]);45 }46 // 전역 복사47 _menuArray = menuArray;48 //49 SetTitle("달립니다.");50 51 //52 CreateBaseTrack();53 //54 CreateRunners();55 //56 _dayOfWeekInfo = new DayOfWeekInfo();57 _dayRankTable = new DayRankTable();58 //59 _timer = new RunnerTimer();60 _timer.Run();61 }62 catch (e)63 {64 alert("OnRun error: " + e);65 _tracks = null;66 _timer = null;67 }68 finally69 {70 }71}72// run01 start73function OnRun01(menuMap)74{75 try76 {77 //78 if (menuMap.size < 5)79 {80 alert ("메뉴는 5개 이상 입력되어야 합니다.");81 return;82 }83 //84 var ls = new LocalStorageSave(menuMap);85 //86 _run01 = new Run01(menuMap);87 }88 catch (e)89 {90 alert("OnRun01 error: " + e);91 _currentRunType = RunType.Unknown;92 }93 finally94 {95 }96}97// run02 start98function OnRun02(menuArray)99{100 try101 {102 //103 if (menuArray.length < 2)104 {105 alert ("메뉴는 2개 이상 입력되어야 합니다.");106 return;107 }108 //109 let menuMap = new Map();110 for (var i = 0; i < menuArray.length; i++)111 {112 menuMap.set(i, new KeyValue(menuArray[i], ""));113 }114 //115 var ls = new LocalStorageSave(menuMap);116 //117 _run02 = new Run02(menuMap);118 }119 catch (e)120 {121 alert("OnRun02 error: " + e);122 _currentRunType = RunType.Unknown;123 }124 finally125 {126 }127}128// 기본 트랙 Div 만들기129function CreateBaseTrack(menuMap)130{131 try132 {133 var mainObj = GetMainObj();134 var html = "";135 136 _tracks = new Array();137 for (var i = 0; i < menuMap.size; i++)138 {139 //html += "<div id='track" + i + "' style='background: #FF00FF; width: 200px; height: 100px; position: absolute; left: 10; top: 10'></div>";140 var kv = menuMap.get(i);141 var track = new Track(i + 1, kv._key);142 html += track.Div();143 _tracks[i] = track;144 }145 mainObj.innerHTML = html;146 //147 for (var i = 0; i < _tracks.length; i++)148 {149 _tracks[i].MakeTrackLine();150 }151 }152 catch (e)153 {154 alert("CreateBaseTrack error: " + e);155 }156 finally157 {158 }159}160var Run01 = function(menuMap)161{162 this._menuMap = menuMap;163 this._runners = null;164 this._dayRankTable = null;165 this.Ctor = function()166 {167 try168 {169 SetTitle("Run01 - 달립니다.");170 CreateBaseTrack(this._menuMap);171 this.CreateRunners();172 //173 _dayOfWeekInfo = new DayOfWeekInfo();174 _dayRankTable = new DayRankTable();175 CreateReservedDayOfWeeks(this._menuMap);176 _dayRankTable.DisplayReservedDOW(this._menuMap);177 //178 _currentRunType = RunType.WeeklyMenu;179 _timer = new RunnerTimer();180 _timer.Run();181 }182 catch (e)183 {184 alert("Run01.Ctor error: " + e);185 this._menuMap = null;186 _tracks = null;187 _timer = null;188 }189 };190 this.CreateRunners = function()191 {192 try193 {194 this._runners = new Array();195 for (var i = 0; i < _tracks.length; i++)196 {197 this._runners[i] = new Runner(_tracks[i]);198 this._runners[i].MakeRunner();199 200 if (this._menuMap.has(i) == true)201 {202 var kv = this._menuMap.get(i);203 if (kv._value.length > 0)204 {205 //alert(kv._value.length + " , ??");206 this._runners[i].SetReservedDOW(kv._value);207 }208 }209 }210 }211 catch (e)212 {213 alert("CreateRunners error: " + e);214 this._runners = null;215 }216 finally217 {218 }219 };220 //221 this.Ctor();222}223// 오늘의 메뉴224var Run02 = function(menuMap)225{226 this._menuMap = menuMap;227 this._runners = null;228 this._dayRankTable = null;229 this.Ctor = function()230 {231 try232 {233 //234 SetTitle("Run02 - 달립니다.");235 CreateBaseTrack(this._menuMap);236 this.CreateRunners();237 //238 //239 _currentRunType = RunType.TodayMenu;240 _timer = new RunnerTimer();241 _timer.Run();242 }243 catch (e)244 {245 alert("Run01.Ctor error: " + e);246 this._menuMap = null;247 _tracks = null;248 _timer = null;249 }250 };251 this.CreateRunners = function()252 {253 try254 {255 this._runners = new Array();256 for (var i = 0; i < _tracks.length; i++)257 {258 this._runners[i] = new Runner(_tracks[i]);259 this._runners[i].MakeRunner();260 }261 }262 catch (e)263 {264 alert("CreateRunners error: " + e);265 this._runners = null;266 }267 finally268 {269 }270 };271 //272 this.Ctor();273}274// timer275var RunnerTimer = function()276{277 this._timer = null;278 this.Run = function()279 {280 try281 {282 this.Stop();283 this._timer = setInterval(this.OnTimer, 100);284 }285 catch (e)286 {287 this.Stop();288 alert("this.Run error: " + e);289 }290 finally291 {292 }293 };294 this.Stop = function()295 {296 try297 {298 //console.log("1");299 if (this._timer != null)300 {301 // console.log("2");302 clearInterval(this._timer);303 }304 }305 catch (e)306 {307 alert("this.Stop error: " + e);308 }309 finally310 {311 this._timer = null;312 }313 };314 this.OnTimer = function()315 {316 try317 {318 //319 if (_currentRunType == RunType.WeeklyMenu)320 {321 var moveCount = 0;322 for (var i = 0; i < _run01._runners.length; i++)323 {324 if (_run01._runners[i].Move() == true)325 {326 moveCount++;327 }328 //console.log(runnerObj._left);329 //console.log(runnerObj.style.left);330 }331 332 //333 if (moveCount == 0)334 {335 _timer.Stop();336 SetTitle("주간 메뉴 결정이 끝났습니다.");337 //alert("주간 메뉴 결정이 끝났습니다.");338 }339 }340 else if (_currentRunType == RunType.TodayMenu)341 {342 let isFinished = false;343 for (var i = 0; i < _run02._runners.length; i++)344 {345 if (_run02._runners[i].Move() == false)346 {347 isFinished = true;348 break;349 }350 //console.log(runnerObj._left);351 //console.log(runnerObj.style.left);352 }353 354 //355 if (isFinished == true)356 {357 _timer.Stop();358 SetTitle("오늘의 메뉴가 결정되었습니다.");359 }360 }361 else362 { throw "Invalid run type"; }363 364 }365 catch (e)366 {367 _timer.Stop();368 console.log("this.OnTimer error: " + e);369 }370 finally371 {372 }373 374 }375}376// 377var Runner = function(track)378{379 this._track = track;380 this._frameIndex = 0;381 this._id = "runner" + this._track._no;382 this._imgId = "runnerImg" + this._track._no;383 this._dayOfWeekId = "dow" + this._track._no;384 this._menu = this._track._menu;385 this._left = 5;386 this.GetNewLeft = function() // auto increase387 {388 try389 {390 this._left += Math.floor(Math.random() * 8) + 2;391 }392 catch (e)393 {394 alert("this.GetLeft error: " + e);395 }396 finally397 {398 }399 return this._left;400 }401 this._frameArray = new Array();402 for (var i = 1; i <= 4; i++)403 {404 this._frameArray[i - 1] = "./res/run0" + i + ".png";405 }406 this.Img = function()407 {408 return "<img id='" + this._imgId + "' src='" + this._frameArray[0] + "'>";409 };410 this._imgObj = null;411 this.GetImgObj = function()412 {413 try414 {415 if (this._imgObj == null)416 {417 this._imgObj = document.getElementById(this._imgId);418 }419 }420 catch (e)421 {422 this._imgObj = null;423 console.log("this.GetImgObj error: " + e);424 }425 finally426 {427 }428 return this._imgObj;429 };430 this.ChangeImgSrc = function()431 {432 try433 {434 if (this._imgObj == null) { this.GetImgObj(); }435 this._frameIndex++;436 if (this._frameIndex >= 4) { this._frameIndex = 0; }437 this._imgObj.src = this._frameArray[this._frameIndex];438 }439 catch (e)440 {441 console.log("this.ChangeImgSrc error: " + e);442 }443 finally444 {445 }446 };447 this.SetImgSrc = function(idx)448 {449 try450 {451 if (this._imgObj == null) { this.GetImgObj(); }452 this._imgObj.src = this._frameArray[idx];453 }454 catch (e)455 {456 console.log("this.SetImgSrc error: " + e);457 }458 finally459 {460 }461 };462 this.MakeRunner = function()463 {464 try465 {466 var trackObj = this._track.GetTrackObj();467 // menu text468 var htmlMenu = "<div>" + this._menu + "</div>";469 // day470 var htmlDay = "<div id='" + this._dayOfWeekId + "'>?</div>";471 // character472 var htmlImg = "<div>" + this.Img() + "</div>";473 // div474 var htmlDiv = "<div id='" + this._id + "' style='position: relative; left: " + this._left + "px; top: 15px;'>" 475 + htmlMenu + htmlDay + htmlImg + "</div>";476 //477 trackObj.innerHTML += htmlDiv;478 }479 catch (e)480 {481 alert("this.MakeTrackLine error: " + e);482 }483 finally484 {485 }486 };487 this._runnerObj = null;488 this.GetRunnerObj = function()489 {490 try491 {492 if (this._runnerObj == null)493 {494 this._runnerObj = document.getElementById(this._id);495 }496 }497 catch (e)498 {499 this._runnerObj = null;500 alert("this.GetRunnerObj error: " + e);501 }502 finally503 {504 }505 return this._runnerObj;506 };507 this.SetDayOfWeek = function()508 {509 try510 {511 var dowObj = document.getElementById(this._dayOfWeekId);512 dowObj.innerHTML = _dayOfWeekInfo.GetDayOfWeek();513 }514 catch (e)515 {516 alert("this.SetDayOfWeek error: " + e);517 }518 finally519 {520 }521 };522 this.SetToday = function()523 {524 try525 {526 var dowObj = document.getElementById(this._dayOfWeekId);527 dowObj.innerHTML = "오늘의 선택 메뉴";528 }529 catch (e)530 {531 alert("this.SetToday error: " + e);532 }533 finally534 {535 }536 };537 this._moveLimit = 800;538 this._isFinished = false;539 this.Move = function()540 {541 try542 {543 if (this._isFinished == true) { return false; }544 if (this._left > this._moveLimit)545 {546 this.SetImgSrc(0);547 this._isFinished = true;548 if (_currentRunType == RunType.WeeklyMenu)549 {550 this.SetDayOfWeek();551 _dayRankTable.SetMenu(this._menu);552 }553 else if (_currentRunType == RunType.TodayMenu)554 {555 this.SetToday();556 }557 return false;558 }559 this.GetNewLeft();560 if (this._runnerObj == null) { this.GetRunnerObj(); }561 this._runnerObj.style.left = this._left + "px";562 563 //564 this.ChangeImgSrc();565 return true;566 }567 catch (e)568 {569 console.log("this.Move error: " + e);570 }571 finally572 {573 }574 return false;575 };576 this.SetReservedDOW = function(dow)577 {578 try579 {580 this._left = this._moveLimit + 1;581 //582 var dowObj = document.getElementById(this._dayOfWeekId);583 dowObj.innerHTML = dow;584 //585 this.SetImgSrc(0);586 this._isFinished = true;587 //588 if (this._runnerObj == null) { this.GetRunnerObj(); }589 this._runnerObj.style.left = this._left + "px";590 }591 catch (e)592 {593 console.log("this.SetReservedDOW error: " + e);594 }595 };596}597// 트랙 클래스598var Track = function(no, menu)599{600 this._menu = menu;601 this._no = no;602 this._left = 10;603 this._width = 800;604 this._height = 100;605 this.Id = function()606 {607 return "track" + this._no;608 };609 this.Top = function()610 {611 var top = (this._height * this._no) + ((this._no >= 1) ? this._no : 0);612 //alert(top);613 return top;614 };615 /*this._Right = function()616 {617 return this._width;618 };*/619 this.Div = function()620 {621 return "<div id='" + this.Id() + "' style='background: ; width: " + this._width + "px; height: " + this._height + "px; position: absolute; left: " + this._left + "px; top: " + this.Top() + "px'></div>";622 };623 this.GetTrackObj = function()624 {625 return document.getElementById(this.Id());626 }627 this.MakeTrackLine = function()628 {629 try630 {631 var trackObj = this.GetTrackObj();632 // lefts633 var htmlLeft = "<div style='background: #252525; position: absolute; left: 0px; top: 0px; width: 3px; height: " + this._height + "px'></div>";634 // right635 var htmlRight = "<div style='background: #252525; position: absolute; left: " + (this._width - 3) + "px; top: 0px; width: 3px; height: " + this._height + "px'></div>";636 // bottom637 var htmlBottom = "<div style='background: #252525; position: absolute; left: 0px; top: " + (this._height - 3) + "px; width: " + this._width + "px; height: 3px'></div>";638 //639 trackObj.innerHTML = htmlLeft + htmlRight + htmlBottom;640 }641 catch (e)642 {643 alert("this.MakeTrackLine error: " + e);644 }645 finally646 {647 }648 };649};650// 요일 반환 클래스651var DayOfWeekInfo = function()652{653 this._idx = 0;654 this.GetDayOfWeek = function()655 {656 let dow = "";657 switch (this._idx)658 {659 case 0:660 this._idx++;661 dow = "월요일";662 break;663 case 1:664 this._idx++;665 dow = "화요일";666 break;667 case 2:668 this._idx++;669 dow = "수요일";670 break;671 672 case 3:673 this._idx++;674 dow = "목요일";675 break;676 case 4:677 this._idx++;678 dow = "금요일";679 break;680 default:681 return "제외";682 }683 if (_reservedDayOfWeeks.IsReserved(dow) == true) { dow = this.GetDayOfWeek(); }684 return dow;685 }686};687// 요일 테이블 클래스688var DayRankTable = function()689{690 this.Ctor = function()691 {692 try693 {694 var mainObj = GetMainObj();695 // title696 var htmlTitle = "<div style='background: #FF2222; width: 120px'><p style='text-align: center;'>결과</p></div>";697 //698 var htmlDivs = "";699 var dayOfWeek = "";700 for (var i = 0; i < 5; i++)701 {702 if (i == 0) { dayOfWeek = "월요일"; }703 else if (i == 1) { dayOfWeek = "화요일"; }704 else if (i == 2) { dayOfWeek = "수요일"; }705 else if (i == 3) { dayOfWeek = "목요일"; }706 else if (i == 4) { dayOfWeek = "금요일"; }707 htmlDivs += "<div id='dayRank" + i + "'>" + dayOfWeek + ": ??</div>";708 }709 mainObj.innerHTML += "<div style='position: absolute; top: 101px; left: 888px;'>" + htmlTitle + htmlDivs + "</div>";710 }711 catch (e)712 {713 console.log("DayRandTable.Ctor error: " + e);714 }715 };716 this.Ctor();717 this.GetDayOfWeek = function(idx)718 {719 switch (idx)720 {721 case 0:722 return "월요일";723 case 1:724 return "화요일";725 case 2:726 return "수요일";727 728 case 3:729 return "목요일";730 case 4:731 return "금요일";732 default:733 break;734 }735 return "";736 };737 this._currentIdx = 0;738 this.SetMenu = function(menu)739 {740 try741 {742 this.GetEnableCurrnetIdx();743 if (this._currentIdx > 4) {return;}744 this.SetRankMenu(this._currentIdx, menu);745 this._currentIdx++;746 }747 catch (e)748 {749 console.log("DayRandTable.Ctor error: " + e);750 }751 };752 this.SetRankMenu = function(idx, menu)753 {754 var dayRankObj = document.getElementById("dayRank" + idx);755 dayRankObj.innerHTML = this.GetDayOfWeek(idx) + ": " + menu;756 }757 this.GetEnableCurrnetIdx = function()758 {759 try760 {761 let dow = this.GetDayOfWeek(this._currentIdx);762 //console.log(dow + ", " + this._currentIdx);763 if (_reservedDayOfWeeks.IsReserved(dow) == true)764 {765 //console.log("retry");766 this._currentIdx++;767 this.GetEnableCurrnetIdx();768 }769 }770 catch (e)771 {772 console.log("this.GetEnableCurrnetIdx error: " + e);773 }774 };775 this.DisplayReservedDOW = function(menuMap)776 {777 try778 {779 for (var i = 0; i < menuMap.size; i++)780 {781 var kv = menuMap.get(i);782 if (kv._value.length <= 0) { continue; }783 var idx = -1;784 switch (kv._value)785 {786 case "월요일":787 idx = 0;788 break;789 case "화요일":790 idx = 1;791 break;792 case "수요일":793 idx = 2;794 break;795 case "목요일":796 idx = 3;797 break;798 case "금요일":799 idx = 4;800 break;801 }802 if (idx >= 0)803 {804 this.SetRankMenu(idx, kv._key);805 }806 }807 }808 catch (e)809 {810 alert("this.DisplayReservedDOW error: " + e);811 } 812 };813};814// local storage 저장815var LocalStorageSave = function(menuMap)816{817 this._menuMap = menuMap;818 this.Ctor = function()819 {820 // local storage clear821 for (var idx = 0; idx < 20; idx++)822 {823 SaveMenu(idx + 1, "");824 }825 // save826 let saveIndex = 1;827 for (var idx = 0; idx < this._menuMap.size; idx++)828 {829 var kv = this._menuMap.get(idx);830 if (kv._key == "아무거나") { continue; }831 SaveMenu(saveIndex++, kv._key);832 }833 };834 this.Ctor();835}836// 예약 된 요일837let _reservedDayOfWeeks = null;838let ReservedDayOfWeeks = function(menuMap)839{840 this._dows = null;841 this.Ctor = function(menuMap)842 {843 try844 {845 this._dows = new Map();846 for (var i = 0; i < menuMap.size; i++)847 {848 var kv = menuMap.get(i);849 if (kv._value.length > 0)850 {851 this._dows.set(kv._value, kv._value);852 }853 }854 }855 catch (e)856 {857 alert("ReservedDayOfWeeks.Ctor error: " + e);858 this._dows = null;859 }860 };861 this.IsReserved = function(dayOfWeeks)862 {863 try864 {865 //console.log("IsReserved: " + dayOfWeeks + ", res: " + this._dows.has(dayOfWeeks));866 return this._dows.has(dayOfWeeks);867 }868 catch (e)869 {870 alert("this.IsReserved error: " + e);871 } 872 return false;873 };874 //875 this.Ctor(menuMap);876}877function CreateReservedDayOfWeeks(menuMap)878{879 try880 {881 _reservedDayOfWeeks = null;882 _reservedDayOfWeeks = new ReservedDayOfWeeks(menuMap);883 }884 catch (e)885 {886 alert("CreateReservedDayOfWeeks error: " + e);887 _reservedDayOfWeeks = null;888 }...

Full Screen

Full Screen

pool.test.ts

Source:pool.test.ts Github

copy

Full Screen

1import { Octokit } from '@octokit/rest';2import { mocked } from 'jest-mock';3import nock from 'nock';4import { listEC2Runners } from '../aws/runners';5import * as ghAuth from '../gh-auth/gh-auth';6import * as scale from '../scale-runners/scale-up';7import { adjust } from './pool';8const mockOctokit = {9 paginate: jest.fn(),10 checks: { get: jest.fn() },11 actions: {12 createRegistrationTokenForOrg: jest.fn(),13 },14 apps: {15 getOrgInstallation: jest.fn(),16 },17};18jest.mock('@octokit/rest', () => ({19 Octokit: jest.fn().mockImplementation(() => mockOctokit),20}));21jest.mock('./../aws/runners');22jest.mock('./../gh-auth/gh-auth');23const mocktokit = Octokit as jest.MockedClass<typeof Octokit>;24const mockedAppAuth = mocked(ghAuth.createGithubAppAuth, true);25const mockedInstallationAuth = mocked(ghAuth.createGithubInstallationAuth, true);26const mockCreateClient = mocked(ghAuth.createOctoClient, true);27const mockListRunners = mocked(listEC2Runners);28const cleanEnv = process.env;29const ORG = 'my-org';30beforeEach(() => {31 nock.disableNetConnect();32 jest.resetModules();33 jest.clearAllMocks();34 process.env = { ...cleanEnv };35 process.env.GITHUB_APP_KEY_BASE64 = 'TEST_CERTIFICATE_DATA';36 process.env.GITHUB_APP_ID = '1337';37 process.env.GITHUB_APP_CLIENT_ID = 'TEST_CLIENT_ID';38 process.env.GITHUB_APP_CLIENT_SECRET = 'TEST_CLIENT_SECRET';39 process.env.RUNNERS_MAXIMUM_COUNT = '3';40 process.env.ENVIRONMENT = 'unit-test-environment';41 process.env.ENABLE_ORGANIZATION_RUNNERS = 'true';42 process.env.LAUNCH_TEMPLATE_NAME = 'lt-1';43 process.env.SUBNET_IDS = 'subnet-123';44 process.env.INSTANCE_TYPES = 'm5.large';45 process.env.INSTANCE_TARGET_CAPACITY_TYPE = 'spot';46 process.env.RUNNER_OWNER = ORG;47 const mockTokenReturnValue = {48 data: {49 token: '1234abcd',50 },51 };52 mockOctokit.actions.createRegistrationTokenForOrg.mockImplementation(() => mockTokenReturnValue);53 mockOctokit.paginate.mockImplementation(() => [54 {55 id: 1,56 name: 'i-1',57 os: 'linux',58 status: 'online',59 busy: false,60 labels: [],61 },62 {63 id: 2,64 name: 'i-2',65 os: 'linux',66 status: 'online',67 busy: true,68 labels: [],69 },70 {71 id: 3,72 name: 'i-3',73 os: 'linux',74 status: 'offline',75 busy: false,76 labels: [],77 },78 {79 id: 11,80 name: 'j-1', // some runner of another env81 os: 'linux',82 status: 'online',83 busy: false,84 labels: [],85 },86 {87 id: 12,88 name: 'j-2', // some runner of another env89 os: 'linux',90 status: 'online',91 busy: true,92 labels: [],93 },94 ]);95 mockListRunners.mockImplementation(async () => [96 {97 instanceId: 'i-1',98 launchTime: new Date(),99 type: 'Org',100 owner: ORG,101 },102 {103 instanceId: 'i-2',104 launchTime: new Date(),105 type: 'Org',106 owner: ORG,107 },108 {109 instanceId: 'i-3',110 launchTime: new Date(),111 type: 'Org',112 owner: ORG,113 },114 ]);115 const mockInstallationIdReturnValueOrgs = {116 data: {117 id: 1,118 },119 };120 mockOctokit.apps.getOrgInstallation.mockImplementation(() => mockInstallationIdReturnValueOrgs);121 mockedAppAuth.mockResolvedValue({122 type: 'app',123 token: 'token',124 appId: 1,125 expiresAt: 'some-date',126 });127 mockedInstallationAuth.mockResolvedValue({128 type: 'token',129 tokenType: 'installation',130 token: 'token',131 createdAt: 'some-date',132 expiresAt: 'some-date',133 permissions: {},134 repositorySelection: 'all',135 installationId: 0,136 });137 mockCreateClient.mockResolvedValue(new mocktokit());138});139describe('Test simple pool.', () => {140 describe('With GitHub Cloud', () => {141 it('Top up pool with pool size 2.', async () => {142 const spy = jest.spyOn(scale, 'createRunners');143 await expect(adjust({ poolSize: 2 })).resolves;144 expect(spy).toBeCalled;145 });146 it('Should not top up if pool size is reached.', async () => {147 const spy = jest.spyOn(scale, 'createRunners');148 await expect(adjust({ poolSize: 1 })).resolves;149 expect(spy).not.toHaveBeenCalled;150 });151 });152 describe('With GHES', () => {153 beforeEach(() => {154 process.env.GHES_URL = 'https://github.enterprise.something';155 });156 it('Top up if the pool size is set to 5', async () => {157 const spy = jest.spyOn(scale, 'createRunners');158 await expect(adjust({ poolSize: 5 })).resolves;159 expect(spy).toBeCalled;160 });161 });...

Full Screen

Full Screen

runner.js

Source:runner.js Github

copy

Full Screen

1import {endRun} from '../middleware/codeRunMiddleware'2import {fetch} from 'redux-effects-fetch'3import isIterator from '@f/is-iterator'4import sequenceToCode from './sequenceToCode'5import flattenGen from '@f/flatten-gen'6import animalApis from 'animalApis'7import sleep from '@f/sleep'8function getInterval (animals, id, speed) {9 return getTimeout(animals, id) * 1 / speed10}11function createIterator (animal, id) {12 const api = animalApis[animal.type].default(id)13 return fetch('https://us-central1-artbot-dev.cloudfunctions.net/autoYield', {14 method: 'POST',15 body: {16 code: sequenceToCode(animal, api, id),17 api: Object.keys(api)18 }19 }).then(({value}) => {20 if (value.error) {21 return reject({message: value.error.name, lineNum: (value.error.loc.line) - 1})22 }23 return resolve(value())24 })25}26function createRunners (animals) {27 return new Promise((resolve, reject) => {28 Promise.all(animals.map((animal, id) => createIterator(animal, id)))29 .then(resolve)30 .catch(reject)31 })32}33export {34 createRunners,35 getInterval36}37const getTimeout = (animals, id) => {38 return !isNaN(id)39 ? animalApis[animals[id].type].speed + 5040 : undefined...

Full Screen

Full Screen

CreateRunners.js

Source:CreateRunners.js Github

copy

Full Screen

1const CreateRunners = data => {2 const runners = {};3 for (let i = 0; i < data.length; i++) {4 let selectionId = data[i].selectionId;5 runners[selectionId] = data[i];6 if (runners[selectionId].metadata.CLOTH_NUMBER) {7 runners[selectionId].runnerName = runners[selectionId].runnerName.replace(/[0-9.]*[.,\s]/g, ' ').trim();8 }9 // The Stake/Liability buttons for the GridView10 runners[selectionId].order = {11 visible: false,12 backLay: 0,13 stakeLiability: 0,14 stake: 2,15 price: 016 };17 }18 return runners;19 };20 ...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1const { createRunners } = require("qawolf");2const { create } = require("qawolf");3const { launch } = require("qawolf");4const { create } = require("qawolf");5const { launch } = require("qawolf");6const { create } = require("qawolf");7const { launch } = require("qawolf");8const { create } = require("qawolf");9const { launch } = require("qawolf");10const { create } = require("qawolf");11const { launch } = require("qawolf");12const { create } = require("qawolf");13const { launch } = require("qawolf");14const { create } = require("qawolf");15const { launch } = require("qawolf");16const { create } = require("qawolf");17const { launch } = require("qawolf");18const { create } = require("qawolf");19const { launch } = require("qawolf");20const { create } = require("qawolf");21const { launch } = require("qawolf");22const { create } = require("qawolf");23const { launch } = require("qawolf");

Full Screen

Using AI Code Generation

copy

Full Screen

1const { createRunners } = require("qawolf");2const { chromium } = require("playwright");3(async () => {4 const browser = await chromium.launch();5 const runners = await createRunners(browser);6 const runner = runners[0];7 const context = await runner.newContext();8 const page = await context.newPage();9 await page.goto("ht

Full Screen

Using AI Code Generation

copy

Full Screen

1const { createRunners } = require("qawolf");2const { chromium } = require("playwright");3const { createRunners } = require("qawolf");4const { chromium } = require("playwright");5const { createRunners } = require("qawolf");6const { chromium } = require("playwright");7const { createRunners } = require("qawolf");8const { chromium } = require("playwright");9const { createRunners } = require("qawolf");10const { chromium } = require("playwright");11const { createRunners } = require("qawolf");12const { chromium } = require("playwright");13const { createRunners } = require("qawolf");14const { chromium } = require("playwright");15const { createRunners } = require("qawolf");16const { chromium } = require("playwright");17const { createRunners } = require("qawolf");18const { chromium } = require("playwright");19const { createRunners } = require("qawolf");20const { chromium } = require("playwright");21const { createRunners } = require("qawolf");22const { chromium } = require("playwright");23const { createRunners } = require("qawolf");24const { chromium } = require("playwright");25const { createRunners } = require("qawolf");26const { chromium } = require("playwright");27const { createRunners } = require("qawolf");28const { chromium } = require("playwright");

Full Screen

Using AI Code Generation

copy

Full Screen

1const { createRunners } = require('qawolf');2const runners = createRunners();3(async () => {4 await runners[0].start();5 await runners[0].run();6 await runners[0].stop();7})();8const { launch } = require('qawolf');9const browser = await launch();10const { createRunners } = require('qawolf');11const runners = createRunners();12(async () => {13 await runners[0].start();14 await runners[0].run();15 await runners[0].stop();16})();17const { launch } = require('qawolf');18const browser = await launch();19const { createRunners } = require('qawolf');20const runners = createRunners();21(async () => {22 await runners[0].start();23 await runners[0].run();24 await runners[0].stop();25})();26const { launch } = require('qawolf');27const browser = await launch();28const { createRunners } = require('qawolf');29const runners = createRunners();30(async () => {31 await runners[0].start();32 await runners[0].run();33 await runners[0].stop();34})();35const { launch } = require('qawolf');36const browser = await launch();37const { createRunners } = require('qawolf');38const runners = createRunners();39(async () => {40 await runners[0].start();41 await runners[0].run();42 await runners[0].stop();43})();44const { launch } = require('qawolf');45const browser = await launch();46const { createRunners } = require('qawolf');47const runners = createRunners();48(async () => {49 await runners[0].start();50 await runners[0].run();51 await runners[0].stop();52})();53const { launch } = require('qawolf');

Full Screen

Using AI Code Generation

copy

Full Screen

1const { createRunners } = require('qawolf');2const { chromium } = require('playwright');3const { join } = require('path');4const { createRunners } = require('qawolf');5const { chromium } = require('playwright');6const { join } = require('path');7const { createRunners } = require('qawolf');8const { chromium } = require('playwright');9const { join } = require('path');10const { createRunners } = require('qawolf');11const { chromium } = require('playwright');12const { join } = require('path');13const { createRunners } = require('qawolf');14const { chromium } = require('playwright');15const { join } = require('path');16const { createRunners } = require('qawolf');17const { chromium } = require('playwright');18const { join } = require('path');19const { createRunners } = require('qawolf');20const { chromium } = require('playwright');21const { join } = require('path');22const { createRunners } = require('qawolf');23const { chromium } = require('playwright');24const { join } = require('path');25const { createRunners } = require('qawolf');26const { chromium } = require('playwright');27const { join } = require('path');28const { createRunners } = require('qawolf');29const { chromium } = require('playwright');30const { join } = require('path');31const { createRunners } = require('qawolf');32const { chromium } = require('playwright');33const { join } = require('path');34const { createRun

Full Screen

Using AI Code Generation

copy

Full Screen

1const { createRunners } = require("qawolf");2const { chromium } = require("playwright");3(async () => {4 const browser = await chromium.launch();5 const context = await browser.newContext();6 const page = await context.newPage();7 const runners = createRunners(browser, context, page);8 const test1 = await runners.create("test1");9 const test2 = await runners.create("test2");10 await test1.run(async () => {11 await test1.page.fill("input[name=q]", "qawolf");12 await test1.page.press("input[name=q]", "Enter");13 });14 await test2.run(async () => {15 await test2.page.fill("input[name=q]", "playwright");16 await test2.page.press("input[name=q]", "Enter");17 });18 await browser.close();19})();

Full Screen

Using AI Code Generation

copy

Full Screen

1const { createRunners } = require("qawolf");2const config = {3 chrome: {4 }5};6const test = async () => {7 const runners = createRunners(config);8 const browser = await runners[0].launch();9 const context = await browser.newContext();10 const page = await context.newPage();11 await page.type("#lst-ib", "qawolf");12 await page.press("#lst-i

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run qawolf automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful