How to use waitForOutput method in Playwright Internal

Best JavaScript code snippet using playwright-internal

run_test.js

Source:run_test.js Github

copy

Full Screen

...134 + count + " of " + expected);135 }136 137 var maxTries = 15, retries = 0;138 function waitForOutput(match, callback) {139 setTimeout(function() {140 var value = tabs.focussedTab.editor.ace.session.getValue();141 142 if (retries < maxTries && !value.match(match)) {143 retries++;144 return waitForOutput(match, callback);145 }146 147 expect(value, "Output Mismatch").match(match);148 149 callback();150 }, 500);151 }152 153 describe('run', function() {154 before(function(done) {155 bar.$ext.style.background = "rgba(220, 220, 220, 0.93)";156 bar.$ext.style.position = "fixed";157 bar.$ext.style.left = "20px";158 bar.$ext.style.right = "20px";159 bar.$ext.style.bottom = "20px";160 bar.$ext.style.height = "150px";161 162 document.body.style.marginBottom = "150px";163 164 document.querySelector(".console").style.height = "100%";165 166 done();167 });168 169 describe("listRunners()", function() {170 it('should list all runners', function(done) {171 run.listRunners(function(err, runners) {172 if (err) throw err.message;173 174 expect(runners).length.gt(0);175 done();176 });177 });178 });179 180 describe("getRunner()", function() {181 it('should retrieve the runner of a certain type', function(done) {182 run.getRunner("node", false, function(err, runner) {183 if (err) throw err.message;184 185 expect(runner).to.ok;186 done();187 });188 });189 });190 191 describe("run()", function() {192 this.timeout(10000);193 194 it('should run a file with a runner', function(done) {195 var foundPid, count = 0;196 197 run.getRunner("node", false, function(err, runner) {198 if (err) throw err.message;199 200 expect(runner).to.ok;201 202 var c = "console.log('Hello World', new Date());";203 204 fs.writeFile("/helloworld.js", c, "utf8", function(err) {205 if (err) throw err.message;206 207 var process = run.run(runner, {208 path: "helloworld.js"209 }, "testoutput1", function(err, pid) {210 if (err) throw err.message;211 expect(parseInt(pid, 10)).to.ok;212 expect(process.running).to.not.equal(run.STARTING);213 foundPid = true;214 });215 216 expect(process.running).to.equal(run.STARTING);217 218 function c2() { count++; }219 process.on("started", c2);220 process.on("stopping", c2);221 222 process.on("stopped", function c1() {223 waitForOutput(/Hello\sWorld/, function() {224 expect(process.running).is.equal(run.STOPPED);225 expect(foundPid, "found-pid").to.ok;226 227 process.off("started", c2);228 process.off("stopping", c2);229 process.off("stopped", c1);230 count++;231 232 fs.rmfile("/helloworld.js", function() {233 countEvents(count, 3, done);234 });235 });236 });237 238 //expect(process.running).to.equal(run.STOPPED);239 });240 });241 });242 243 it('should run a file with a runner and stop it with stop()', function(done) {244 var count = 0;245 246 run.getRunner("node", false, function(err, runner) {247 if (err) throw err.message;248 249 expect(runner).to.ok;250 251 var c = "setInterval(function(){console.log('Hello World', new Date());}, 500)";252 253 fs.writeFile("/helloworld.js", c, "utf8", function(err) {254 if (err) throw err.message;255 256 var process = run.run(runner, {257 path: "helloworld.js"258 }, "testoutput1", function(err, pid) {259 if (err) throw err.message;260 261 expect(parseInt(pid, 10), "Invalid PID").to.ok.to.gt(0);262 expect(process.running).to.equal(run.STARTED);263 264 // setTimeout(function(){265 waitForOutput(/Hello\sWorld[\s\S]*Hello\sWorld/, function() {266 count++;267 process.stop(function(err, e) {268 if (err) throw err.message;269 });270 });271 // }, 4000);272 });273 274 expect(process.running).to.equal(run.STARTING);275 276 function c2() { count++; }277 process.on("started", c2);278 process.on("stopping", c2);279 280 process.on("stopped", function c1() {281 expect(process.running).is.equal(run.STOPPED);282 283 process.off("started", c2);284 process.off("stopping", c2);285 process.off("stopped", c1);286 count++;287 288 fs.rmfile("/helloworld.js", function() {289 countEvents(count, 4, done);290 });291 });292 });293 });294 });295 296 it('should run an interactive proces in the second output window', function(done) {297 var count = 0;298 299 var outputTab2 = tabs.getTabs()[1];300 tabs.focusTab(outputTab2);301 302 run.getRunner("pythoni", false, function(err, runner) {303 if (err) throw err.message;304 305 expect(runner).to.ok;306 307 var process = run.run(runner, {}, "testoutput2", function(err, pid) {308 if (err) throw err.message;309 310 expect(parseInt(pid, 10)).to.ok.to.gt(0);311 expect(process.running).to.equal(run.STARTED);312 313 waitForOutput(/copyright/, function() {314 var output = outputTab2.editor;315 316 output.write("print 1\n");317 318 setTimeout(function() {319 output.write(String.fromCharCode(4));320 }, 1000);321 });322 });323 324 function c2() { count++; }325 process.on("started", c2);326 process.on("stopping", c2);327 328 process.on("stopped", function c1() {329 expect(process.running).is.equal(run.STOPPED);330 331 process.off("started", c2);332 process.off("stopping", c2);333 process.off("stopped", c1);334 335 count++;336 countEvents(count, 3, done);337 });338 339 expect(process.running).to.equal(run.STARTING);340 });341 });342 343 it('should run a file with a runner automatically selected in the second output window', function(done) {344 var foundPid, count = 0;345 346 var outputTab2 = tabs.getTabs()[1];347 tabs.focusTab(outputTab2);348 349 run.getRunner("node", false, function(err, runner) {350 if (err) throw err.message;351 352 expect(runner).to.ok;353 354 var c = "console.log('Hello World', new Date());";355 356 fs.writeFile("/helloworld.js", c, "utf8", function(err) {357 if (err) throw err.message;358 var process = run.run("auto", {359 path: "helloworld.js"360 }, "testoutput2", function(err, pid) {361 if (err) throw err.message;362 expect(parseInt(pid, 10)).to.ok;363 expect(process.running).to.not.equal(run.STARTING);364 foundPid = true;365 });366 367 expect(process.running).to.equal(run.STARTING);368 369 function c2() { count++; }370 process.on("started", c2);371 process.on("stopping", c2);372 373 process.on("stopped", function c1() {374 waitForOutput(/Hello\sWorld/, function() {375 expect(process.running).is.equal(run.STOPPED);376 expect(foundPid, "found-pid").to.ok;377 378 process.off("started", c2);379 process.off("stopping", c2);380 process.off("stopped", c1);381 count++;382 383 fs.rmfile("/helloworld.js", function() {384 countEvents(count, 3, done);385 });386 });387 });388 });...

Full Screen

Full Screen

Process.test.js

Source:Process.test.js Github

copy

Full Screen

1'use strict';2/* eslint-env node */3const Promise = require('bluebird');4const path = require('path');5require('chai').use(require('chai-as-promised'));6const {assert: {isNaN, lengthOf, strictEqual: eq, match, deepEqual: deq, isRejected, approximately, isAbove, instanceOf}} = require('chai');7const {describe, it, beforeEach, afterEach} = require('mocha-sugar-free');8const Process = require('../../../lib/node/Process');9const Wait = require('../../utilities/Wait');10const IS_WINDOWS = process.platform === 'win32';11const {env: testRunnerEnv} = process;12const PROCESS_STUB_PATH = IS_WINDOWS13 ? require.resolve('../../utilities/process.js.cmd')14 : require.resolve('../../utilities/process.js');15describe('node/Process', {timeout: 10000, slow: 5000}, () => {16 let process;17 let output;18 let waitForOutput;19 beforeEach(() => {20 output = [];21 waitForOutput = new Wait();22 });23 afterEach(async () => {24 if (process) {25 await process.stop();26 process = null;27 }28 });29 const attachOutputListeners = () => {30 process.on('STDOUT', line => {31 output.push({line, type: 'STDOUT'});32 waitForOutput.advance();33 });34 process.on('STDERR', line => {35 output.push({line, type: 'STDERR'});36 waitForOutput.advance();37 });38 process.on('FD3', line => {39 output.push({line, type: 'FD3'});40 waitForOutput.advance();41 });42 };43 describe('#start()', () => {44 it('Should start the process, update statistics and raise events', async () => {45 const events = [];46 process = new Process({executablePath: PROCESS_STUB_PATH});47 eq(process.isRunning, false);48 isNaN(process.lastProcessStart);49 isNaN(process.lastProcessExit);50 eq(process.processExitCount, 0);51 process.on('beforeStart', wait => { events.push('beforeStart'); wait(Promise.delay(1)); });52 process.on('afterStart', wait => { events.push('afterStart'); wait(() => Promise.delay(1)); });53 process.on('stopped', (reason, wait) => { events.push('stopped'); wait(Promise.delay(1)); });54 process.on('afterStopped', () => { events.push('afterStopped'); });55 const expectedStartTime1 = Date.now();56 await process.start();57 deq(events, ['beforeStart', 'afterStart']);58 eq(process.isRunning, true);59 const startTime1 = process.lastProcessStart;60 approximately(startTime1, expectedStartTime1, 250);61 isNaN(process.lastProcessExit);62 eq(process.processExitCount, 0);63 await Promise.delay(500);64 const expectedExitTime1 = Date.now();65 await process.stop();66 deq(events, ['beforeStart', 'afterStart', 'stopped', 'afterStopped']);67 eq(process.isRunning, false);68 eq(process.lastProcessStart, startTime1);69 const exitTime1 = process.lastProcessExit;70 isAbove(exitTime1, startTime1);71 approximately(exitTime1, expectedExitTime1, 250);72 eq(process.processExitCount, 1);73 const expectedStartTime2 = Date.now();74 await process.start();75 deq(events, ['beforeStart', 'afterStart', 'stopped', 'afterStopped', 'beforeStart', 'afterStart']);76 eq(process.isRunning, true);77 approximately(process.lastProcessStart, expectedStartTime2, 250);78 eq(process.lastProcessExit, exitTime1);79 eq(process.processExitCount, 1);80 const expectedExitTime2 = Date.now();81 await process.stop();82 deq(events, ['beforeStart', 'afterStart', 'stopped', 'afterStopped', 'beforeStart', 'afterStart', 'stopped', 'afterStopped']);83 eq(process.isRunning, false);84 isAbove(process.lastProcessExit, startTime1);85 approximately(process.lastProcessExit, expectedExitTime2, 250);86 eq(process.processExitCount, 2);87 });88 it('Should emit stop events if the child fails to start', async () => {89 const events = [];90 process = new Process({executablePath: path.join(__dirname, `A FILE THAT DOES NOT EXIST ${Math.random()}`)});91 process.on('beforeStart', () => { events.push(['beforeStart']); });92 process.on('afterStart', () => { events.push(['afterStart']); });93 process.on('stopped', (reason) => { events.push(['stopped', reason]); });94 process.on('afterStopped', (reason) => { events.push(['afterStopped', reason]); });95 await process.start();96 await process.waitForChildStop();97 eq(process.isRunning, false);98 lengthOf(events, 4);99 deq(events[0], ['beforeStart']);100 deq(events[1], ['afterStart']);101 eq(events[2][0], 'stopped');102 eq(events[3][0], 'afterStopped');103 instanceOf(events[2][1].error, Error);104 eq(events[3][1].error, events[2][1].error);105 match(events[2][1].error.message, /spawn.*ENOENT/);106 });107 it('Should not allow starting the same process multi times', async () => {108 process = new Process({executablePath: PROCESS_STUB_PATH});109 const firstStart = process.start();110 await isRejected(process.start(), Error, /process.*already.*start/i);111 await firstStart;112 await isRejected(process.start(), Error, /process.*already.*start/i);113 });114 it('Should emit events for each line received on STDOUT and STDERR', async t => {115 process = new Process({116 executablePath: PROCESS_STUB_PATH,117 args: ['321', 'an argument with spaces'],118 env: {119 FOO: '123',120 BAR: 'env with spaces',121 },122 });123 attachOutputListeners();124 await process.start();125 await waitForOutput.waitUntil(6);126 deq(output[0], {line: 'HELLO!', type: 'STDOUT'});127 const argv = JSON.parse(output[1].line);128 lengthOf(argv, 4);129 match(argv[0], /node(?:\.exe)?$/);130 match(argv[1], /process\.js$/);131 eq(argv[2], '321');132 eq(argv[3], 'an argument with spaces');133 const env = JSON.parse(output[2].line);134 eq(env.FOO, '123');135 eq(env.BAR, 'env with spaces');136 eq(env.HOME, testRunnerEnv.HOME, 'should inherit environment variables');137 deq(output.slice(3), [138 {139 line: 'SOMETHING TO STDOUT',140 type: 'STDOUT',141 },142 {143 line: 'SOMETHING ELSE TO STDOUT',144 type: 'STDOUT',145 },146 {147 line: 'SOMETHING TO STDERR',148 type: 'STDERR',149 },150 ]);151 });152 it('Should emit events for each line received on STDOUT, STDERR and FD3', async t => {153 if (IS_WINDOWS) {154 t.skip(); // FD3 is not supported on windows155 }156 process = new Process({157 executablePath: PROCESS_STUB_PATH,158 args: ['FD3', 'an argument with spaces'],159 env: {160 FOO: '123',161 BAR: 'env with spaces',162 },163 enableExtraFd: true,164 });165 attachOutputListeners();166 await process.start();167 await waitForOutput.waitUntil(7);168 deq(output[0], {line: 'HELLO!', type: 'STDOUT'});169 const argv = JSON.parse(output[1].line);170 lengthOf(argv, 4);171 match(argv[0], /node(?:\.exe)?$/);172 match(argv[1], /process\.js$/);173 eq(argv[2], 'FD3');174 eq(argv[3], 'an argument with spaces');175 const env = JSON.parse(output[2].line);176 eq(env.FOO, '123');177 eq(env.BAR, 'env with spaces');178 eq(env.HOME, testRunnerEnv.HOME, 'should inherit environment variables');179 deq(output.slice(3), [180 {181 line: 'SOMETHING TO STDOUT',182 type: 'STDOUT',183 },184 {185 line: 'SOMETHING ELSE TO STDOUT',186 type: 'STDOUT',187 },188 {189 line: 'SOMETHING TO STDERR',190 type: 'STDERR',191 },192 {193 line: 'SOMETHING TO FILE DESCRIPTOR 3',194 type: 'FD3',195 },196 ]);197 });198 });199 describe('#stop()', () => {200 it('Should kill the process if running', async () => {201 process = new Process({202 executablePath: PROCESS_STUB_PATH,203 args: [],204 });205 const stopEvents = [];206 process.on('stopped', (reason) => stopEvents.push(reason));207 attachOutputListeners();208 await process.start();209 await waitForOutput.waitUntil(1);210 await process.stop();211 lengthOf(stopEvents, 1);212 deq(stopEvents[0], {error: null, code: null, signal: 'SIGTERM'});213 });214 it('Should kill the process if running using SIGTERM on linux', async t => {215 if (IS_WINDOWS) {216 t.skip();217 }218 process = new Process({219 executablePath: PROCESS_STUB_PATH,220 args: ['LOG_EXIT_SIGNALS'],221 });222 const stopEvents = [];223 process.on('stopped', (reason) => stopEvents.push(reason));224 attachOutputListeners();225 await process.start();226 await waitForOutput.waitUntil(1);227 await process.stop();228 const sigtermLines = output.filter(({line}) => line === 'RECEIVED SIGTERM');229 lengthOf(sigtermLines, 1);230 lengthOf(stopEvents, 1);231 deq(stopEvents[0], {error: null, code: 143, signal: null});232 });233 it('Should do nothing if the process is already being stopped', async t => {234 if (IS_WINDOWS) {235 t.skip();236 }237 process = new Process({238 executablePath: PROCESS_STUB_PATH,239 args: ['LOG_EXIT_SIGNALS'],240 });241 const stopEvents = [];242 process.on('stopped', (reason) => stopEvents.push(reason));243 attachOutputListeners();244 await process.start();245 await waitForOutput.waitUntil(1);246 await Promise.all([247 process.stop(),248 process.stop(),249 process.stop(),250 ]);251 const sigtermLines = output.filter(({line}) => line === 'RECEIVED SIGTERM');252 lengthOf(sigtermLines, 1);253 lengthOf(stopEvents, 1);254 deq(stopEvents[0], {error: null, code: 143, signal: null});255 });256 it('Should do nothing if the process is already being stopped, but still wait for the termination', async t => {257 if (IS_WINDOWS) {258 t.skip();259 }260 process = new Process({261 executablePath: PROCESS_STUB_PATH,262 args: ['LOG_EXIT_SIGNALS'],263 });264 const stopEvents = [];265 process.on('stopped', (reason) => stopEvents.push(reason));266 attachOutputListeners();267 await process.start();268 await waitForOutput.waitUntil(1);269 await Promise.race([270 process.stop(),271 process.stop(),272 process.stop(),273 ]);274 const sigtermLines = output.filter(({line}) => line === 'RECEIVED SIGTERM');275 lengthOf(sigtermLines, 1);276 lengthOf(stopEvents, 1);277 deq(stopEvents[0], {error: null, code: 143, signal: null});278 });279 it('Should do nothing if the process is not running', async () => {280 process = new Process({281 executablePath: PROCESS_STUB_PATH,282 args: [],283 });284 const stopEvents = [];285 process.on('stopped', (reason) => stopEvents.push(reason));286 await process.stop();287 lengthOf(stopEvents, 0);288 });289 it('Should forcefully terminate the process if if does not quit cleanly within a timeout', async t => {290 if (IS_WINDOWS) {291 t.skip();292 }293 process = new Process({294 executablePath: [PROCESS_STUB_PATH, 'IGNORE_EXIT_SIGNALS'],295 args: [],296 killTimeout: 2000,297 });298 attachOutputListeners();299 const waitForSigTerm = new Wait();300 process.on('STDERR', line => line === 'IGNORED SIGTERM' && waitForSigTerm.advance());301 const stopEvents = [];302 process.on('stopped', (reason) => stopEvents.push(reason));303 await process.start();304 await waitForOutput.waitUntil(1);305 const stopPromise = process.stop();306 await waitForSigTerm.waitUntil(1);307 lengthOf(stopEvents, 0);308 await Promise.delay(100);309 lengthOf(stopEvents, 0);310 await stopPromise;311 lengthOf(stopEvents, 1);312 deq(stopEvents[0], {error: null, code: null, signal: 'SIGKILL'});313 });314 });315 describe('#ensureStarted()', () => {316 it('Should start the process if not running, but also do nothing if the process is already running', async () => {317 process = new Process({executablePath: PROCESS_STUB_PATH});318 await Promise.all([319 process.ensureStarted(),320 process.ensureStarted(),321 process.ensureStarted(),322 ]);323 eq(process.isRunning, true);324 attachOutputListeners();325 await waitForOutput.waitUntil(1);326 });327 it('Should wait for the old process to exit if we are currently stopping it', async () => {328 process = new Process({executablePath: PROCESS_STUB_PATH});329 const waitForHello = new Wait();330 process.on('STDOUT', line => line === 'HELLO!' && waitForHello.advance());331 await process.start();332 await waitForHello.waitUntil(1);333 await Promise.all([334 process.stop(),335 process.ensureStarted(),336 ]);337 eq(process.processExitCount, 1);338 eq(process.isRunning, true);339 await waitForHello.waitUntil(2);340 });341 });342 describe('#waitForChildStop', () => {343 it('Should wait for the child process to quit on its own', async () => {344 process = new Process({345 executablePath: PROCESS_STUB_PATH,346 args: ['EARLY_EXIT'],347 });348 attachOutputListeners();349 const stopEvents = [];350 process.on('stopped', (reason) => stopEvents.push(reason));351 await process.start();352 await waitForOutput.waitUntil(1);353 await process.waitForChildStop();354 lengthOf(stopEvents, 1);355 deq(stopEvents[0], {error: null, code: 99, signal: null});356 });357 it('Should immediately resolve if the child has already stopped', async () => {358 process = new Process({executablePath: PROCESS_STUB_PATH});359 await process.waitForChildStop();360 });361 });...

Full Screen

Full Screen

run_spec.js

Source:run_spec.js Github

copy

Full Screen

1var runner = require('../lib/runner.js');2describe('invoking `mrt run`', function() {3 describe('in a non-meteor project directory', function() {4 it("should display a message about not being in a meteor project dir", function(done) {5 runner.invokeMrt('', ['run'], {6 waitForOutput: "You're not in a Meteor project directory"7 }, done);8 });9 });10 11 describe('in a meteor project without a smart.json', function() {12 it("should run the app without installing anything", function(done) {13 runner.invokeMrtInApp('app-without-smart-json', ['run'], {14 waitForOutput: "Meteor server running on: http://localhost:"15 }, done);16 });17 });18 describe('in a meteor project with a smart.json', function() {19 20 describe('and the smart.json specifies a simple smart package dependency', function() {21 it("should install the smart package", function(done) {22 runner.invokeMrtInApp('app-with-smart-pkg', ['run'], {23 waitForOutput: "Test package 1 installed (branch/master)"24 }, done);25 });26 });27 28 describe("and the smart.json specifies a smart package pinned to a branch", function() {29 it("should install the smart package pinned to a specified branch", function(done) {30 runner.invokeMrtInApp('app-with-smart-pkg-pinned-to-branch', ['run'], {31 waitForOutput: "Test package 1 installed (branch/test-branch)"32 }, done);33 });34 });35 36 describe("and the smart.json specifies a smart package repo pinned to a tag", function() {37 it("should install the smart package pinned to a specified tag", function(done) {38 runner.invokeMrtInApp('app-with-smart-pkg-pinned-to-tag', ['run'], {39 waitForOutput: "Test package 1 installed (tag/test-tag-1)"40 }, done);41 });42 });43 44 describe("and the smart.json specifies a smart package repo pinned to a git sha ref", function() {45 it("should install the smart package pinned to a specified ref", function(done) {46 runner.invokeMrtInApp('app-with-smart-pkg-pinned-to-ref', ['run'], {47 waitForOutput: "Test package 1 installed (ref)"48 }, done);49 });50 });51 52 describe("and the smart.json specifies a smart package from a path", function() {53 it("should install the smart package linked to the path", function(done) {54 runner.invokeMrtInApp('app-with-smart-pkg-specified-by-path', ['run'], {55 waitForOutput: "Test package 1 installed (from a fixed path)"56 }, done);57 });58 });59 60 describe("and the smart.json specifies a smart package repo with it's own smart package dependency", function() {61 it("should discover and install smart packages recursively", function(done) {62 runner.invokeMrtInApp('app-with-nested-smart-pkg-deps', ['run'], {63 waitForOutput: [64 "Test package 1 installed (branch/master)",65 "Test package 2 installed (branch/master)"66 ]67 }, done);68 });69 });70 71 describe("and the smart.json specifies a smart package from a path with it's own smart package dependency from a path", function() {72 it("should discover and install smart packages recursively", function(done) {73 runner.invokeMrtInApp('app-with-nested-smart-pkg-deps-specified-by-paths', ['run'], {74 waitForOutput: [75 "Test package 1 installed (from a fixed path)",76 "Test package 2 installed (from a fixed path)"77 ]78 }, done);79 });80 });81 82 describe("and the smart.json specifies two packages that clash in dependencies", function() {83 it("should not run and output an error message", function(done) {84 runner.invokeMrtInApp('app-with-nested-smart-pkg-deps-that-clash', ['run'], {85 waitForOutput: ["Can't resolve dependencies!"]86 }, done);87 });88 it("should run (with an warning message) if forced", function(done) {89 runner.invokeMrtInApp('app-with-nested-smart-pkg-deps-that-clash', ['run', '--force'], {90 waitForOutput: [91 "Problem installing",92 "mrt-test-pkg1",93 "[branch: https://github.com/possibilities/mrt-test-pkg1.git#master] " +94 "conflicts with " +95 "[branch: https://github.com/tmeasday/mrt-test-pkg1.git#master]; " +96 "keeping [branch: https://github.com/tmeasday/mrt-test-pkg1.git#master]"97 ]98 }, done);99 });100 });101 102 describe('and the smart.json specifies a meteor fork pinned to a branch', function() {103 it("should run the forked meteor checked out to the branch", function(done) {104 runner.invokeMrtInApp('app-with-meteor-pinned-to-branch', ['run'], {105 waitForOutput: "Meteor is instrumented for meteorite test (branch/mrt-branch-test)"106 }, done);107 });108 });109 describe('and the smart.json specifies a meteor fork pinned to a tag', function() {110 it("should run the forked meteor checked out to the branch", function(done) {111 runner.invokeMrtInApp('app-with-meteor-pinned-to-tag', ['run'], {112 waitForOutput: "Meteor is instrumented for meteorite test (tag/mrt-test-tag)"113 }, done);114 });115 });116 describe('and the smart.json specifies a meteor fork pinned to a ref', function() {117 it("should run the forked meteor checked out to the branch", function(done) {118 runner.invokeMrtInApp('app-with-meteor-pinned-to-ref', ['run'], {119 waitForOutput: "Meteor is instrumented for meteorite test (ref)"120 }, done);121 });122 });123 });...

Full Screen

Full Screen

motorBoard.js

Source:motorBoard.js Github

copy

Full Screen

...64 y: revs * 10 * (direction === 'right' ? -1 : (direction === 'forward' ? 1 : 0)),65 });66 };6768 await waitForOutput(GRBL_INITIALIZED);6970 sendRaw('$3=1'); // Invert X axis71 await waitForOutput('ok');7273 sendRaw('$100=70'); // X steps per cm74 await waitForOutput('ok');75 sendRaw('$101=70'); // Y steps per cm76 await waitForOutput('ok');7778 sendRaw('$110=5000'); // X max feed rate79 await waitForOutput('ok');80 sendRaw('$111=5000'); // Y max feed rate81 await waitForOutput('ok');8283 sendRaw('$120=90.0'); // Max X acceleration84 await waitForOutput('ok');85 sendRaw('$121=90.0'); // Max Y acceleration86 await waitForOutput('ok');8788 return {89 addListener: callb => comParser.on('data', callb),90 sendRaw,91 cstop: async () => {92 sendRaw('\x18'); // soft reset93 await waitForOutput(GRBL_INITIALIZED);94 sendRaw('$X'); // clear alarm95 await waitForOutput('ok');96 },97 doBasicMove,98 rawMoveXY,99 //doDirectMove: ({ timeMs, frequency, dir }) => sendRaw(`DR ${timeMs} ${frequency} ${dir} ;`)100 };101 } ...

Full Screen

Full Screen

website.txt.js

Source:website.txt.js Github

copy

Full Screen

1/**2 input: [ 'data' ]3 output: [ 'data', 'html' ]4 params:5 - name: site6 label: Website URL7 value:8 - control: textbox9 lazy: true10 value: https://hal9ai.github.io/hal9ai/examples/website.html11**/12data = typeof(data) != 'undefined' ? JSON.parse(JSON.stringify(data)) : null;13const iframe = document.createElement('iframe');14var waitForOutput = false;15const inputListener = event => {16 if (!event.data || !event.data.hal9) return;17 18 if (event.data.hal9 == 'input') {19 iframe.contentWindow.postMessage({ hal9: 'input', input: { data: data } }, '*');20 if (event.data.options && event.data.options.wait) {21 waitForOutput = !!event.data.options.wait; 22 }23 }24}25window.addEventListener('message', inputListener);26var outputListener = null27const outputWaiter = new Promise((accept, reject) => {28 outputListener = event => {29 if (!event.data || !event.data.hal9) return;30 if (event.data.hal9 == 'output' && event.data.output) {31 accept(event.data.output);32 }33 }34 window.addEventListener('message', outputListener);35})36iframe.style.border = 0;37iframe.style.width = '100%';38iframe.style.height = '100%';39iframe.src = site;40const loadWaiter = new Promise((accept, reject) => {41 iframe.addEventListener("load", function() {42 accept()43 });44 iframe.addEventListener("error", function(e) {45 reject(e)46 });47})48html.appendChild(iframe);49await loadWaiter50// wait for input messages since they are async51const sleep = (ms) => new Promise(resolve => setTimeout(resolve, ms));52await sleep(100)53if (waitForOutput) {54 const output = await outputWaiter;55 if (output.data) data = output.data;56}57const interactiveListener = event => {58 if (!event.data || !event.data.hal9) return;59 60 if (event.data.hal9 == 'output' && event.data.output) {61 var state = hal9.getState();62 state = Object.assign(state, event.data.output);63 hal9.setState(state);64 hal9.invalidate();65 }66}67window.addEventListener('message', interactiveListener);68var observer = new MutationObserver(function (e) {69 if (e.filter(e => e.removedNodes && e.removedNodes[0] == html).length > 0) {70 window.removeEventListener('message', inputListener);71 window.removeEventListener('message', outputListener);72 window.removeEventListener('message', interactiveListener);73 }74});...

Full Screen

Full Screen

shell.js

Source:shell.js Github

copy

Full Screen

...27 } else {28 setImmediate(waitForInput);29 }30}31function waitForOutput() {32 connection.on('data', data => {33 try {34 data = data.toString();35 const resp = JSON.parse(data);36 switch (resp.code) {37 case MESSAGES.OK:38 console.log("Command executed successfully");39 break;40 case MESSAGES.DATA:41 console.log("Command executed successfully with data");42 console.log(resp.data);43 break;44 case MESSAGES.NO_SUCH_COMMAND: console.log("Command not found"); break;45 case MESSAGES.INVALID_ARGS: console.log("Command failed due to invalid args"); break;46 case MESSAGES.CONTENT_NOT_FOUND: console.log("Command failed due to missing entity / content"); break;47 case MESSAGES.INVALID_CONTEXT: console.log("The provided context is invalid"); break;48 case MESSAGES.HELLO: console.log("Connection established"); break;49 }50 } catch (err) {51 console.log('Invalid response from Lilium');52 console.log(err);53 console.log(data);54 }55 console.log("");56 setImmediate(waitForInput);57 });58}59console.log('Lilium CMS - Interactive Shell');60const connection = connectToLilium();61if (connection) {62 waitForOutput();63 connection.write('hello');...

Full Screen

Full Screen

startServer.js

Source:startServer.js Github

copy

Full Screen

1const execa = require('execa');2/**3 * Starts create-frontend server in the selected path. Resolves once the server has started4 */5module.exports = function startServer(cwd, command = 'start', waitForOutput) {6 return new Promise((resolve, reject) => {7 const subprocess = execa('npm', ['run', command], { cwd, env: { DONT_WATCH_DOTENV: true } });8 const output = {};9 const cleanup = () => {10 return new Promise(res => {11 subprocess.on('close', () => {12 res();13 });14 subprocess.stdout.removeAllListeners('data');15 subprocess.stderr.removeAllListeners('data');16 subprocess.kill();17 });18 };19 global.cleanupFunctions.push(cleanup);20 subprocess.stdout.on('data', chunk => {21 const data = chunk.toString();22 Object.entries(waitForOutput).forEach(([name, regex]) => {23 if (data.match(regex)) output[name] = data;24 });25 if (Object.keys(output).length === Object.keys(waitForOutput).length) {26 resolve({27 output,28 cleanup,29 });30 }31 });32 subprocess.stderr.on('data', chunk => {33 const data = chunk.toString();34 console.error('Error while starting server:', data);35 });36 // If the process ended without the correct stdout, it means something went wrong37 subprocess38 .then(() => {39 if (!subprocess.killed) {40 reject({41 error: 'Finished npm script without successfully starting server',42 stdout: subprocess.stdout,43 });44 }45 })46 .catch(error => {47 reject({48 error,49 });50 });51 });...

Full Screen

Full Screen

test.js

Source:test.js Github

copy

Full Screen

...4 waitForOutput5} = require('test-ipfs-example/utils')6async function runTest () {7 console.info('Testing put.js')8 await waitForOutput('bafyreigsccjrxlioppkkzv27se4gxh2aygbxfnsobkaxxqiuni544uk66a', path.resolve(__dirname, 'put.js'))9 console.info('Testing get.js')10 await waitForOutput('{"name":"David","likes":["js-ipfs","icecream","steak"]}', path.resolve(__dirname, 'get.js'))11 console.info('Testing get-path.js')12 await waitForOutput('js-ipfs', path.resolve(__dirname, 'get-path.js'))13 console.info('Testing get-path-accross-formats.js')14 await waitForOutput('capoeira', path.resolve(__dirname, 'get-path-accross-formats.js'))15 console.info('Testing tree.js')16 await waitForOutput("hobbies/0/Links", path.resolve(__dirname, 'tree.js'))17 console.info('Testing eth.js')18 await waitForOutput('302516', path.resolve(__dirname, 'eth.js'))19 console.info('Testing git.js')20 await waitForOutput("'hello world!'", path.resolve(__dirname, 'git.js'))21 console.info('Done!')22}...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1const { chromium } = require('playwright');2(async () => {3 const browser = await chromium.launch();4 const context = await browser.newContext();5 const page = await context.newPage();6 await page.waitForLoadState('networkidle');7 await page.fill('input[name="q"]', 'Playwright');8 await page.click('input[type="submit"]');9 await page.waitForSelector('text=Playwright is a Node library to automate');10 await page.click('text=Playwright is a Node library to automate');11 await page.waitForSelector('text=Playwright is a Node library to automate');12 await page.screenshot({ path: `example.png` });13 await browser.close();14})();15const { chromium } = require('playwright');16(async () => {17 const browser = await chromium.launch();18 const context = await browser.newContext();19 const page = await context.newPage();20 await page.waitForLoadState('networkidle');21 await page.fill('input[name="q"]', 'Playwright');22 await page.click('input[type="submit"]');23 await page.waitForSelector('text=Playwright is a Node library to automate');24 await page.click('text=Playwright is a Node library to automate');25 await page.waitForSelector('text=Playwright is a Node library to automate');26 await page.screenshot({ path: `example.png` });27 await browser.close();28})();29const { chromium } = require('playwright');30(async () => {31 const browser = await chromium.launch();32 const context = await browser.newContext();33 const page = await context.newPage();

Full Screen

Using AI Code Generation

copy

Full Screen

1const { chromium } = require('playwright');2(async () => {3 const browser = await chromium.launch();4 const context = await browser.newContext();5 const page = await context.newPage();6 await page.waitForOutput('text=Example Domain', { timeout: 10000 });7 await browser.close();8})();9const { chromium } = require('playwright');10(async () => {11 const browser = await chromium.launch();12 const context = await browser.newContext();13 const page = await context.newPage();14 const output = await page.waitForOutput('text=Hello World', { timeout: 10000 });15 console.log(output);16 await browser.close();17})();18const { chromium } = require('playwright');19(async () => {20 const browser = await chromium.launch();21 const context = await browser.newContext();

Full Screen

Using AI Code Generation

copy

Full Screen

1const { chromium } = require('playwright');2(async () => {3 const browser = await chromium.launch();4 const context = await browser.newContext();5 const page = await context.newPage();6 const [request] = await Promise.all([7 page.waitForRequest(/.*\.css/),8 page.waitForEvent('request'),9 page.waitForEvent('response'),10 page.waitForEvent('close'),11 page.waitForEvent('console'),12 page.waitForEvent('dialog'),13 page.waitForEvent('download'),14 page.waitForEvent('filechooser'),15 page.waitForEvent('frameattached'),16 page.waitForEvent('framedetached'),17 page.waitForEvent('framenavigated'),18 page.waitForEvent('load'),19 page.waitForEvent('pageerror'),20 page.waitForEvent('popup'),21 page.waitForEvent('requestfailed'),22 page.waitForEvent('requestfinished'),23 page.waitForEvent('response'),24 page.waitForEvent('route'),25 page.waitForEvent('video'),26 page.waitForEvent('websocket'),27 page.waitForEvent('worker'),28 page.waitForTimeout(5000),29 page.waitForURL(/.*\/docs\/.*/),

Full Screen

Using AI Code Generation

copy

Full Screen

1const playwright = require('playwright');2(async () => {3 const browser = await playwright.chromium.launch();4 const context = await browser.newContext();5 const page = await context.newPage();6 await page.fill('input[name="q"]', 'playwright');7 await page.click('button[type="submit"]');8 await page.waitForOutput(() => {9 return document.querySelector('div').textContent.includes('Playwright');10 });11 await browser.close();12})();

Full Screen

Using AI Code Generation

copy

Full Screen

1const { chromium } = require('playwright');2(async () => {3 const browser = await chromium.launch();4 const context = await browser.newContext();5 const page = await context.newPage();6 const [request] = await Promise.all([7 page.waitForRequest(/.*\/fonts\/.*/),8 page.waitForLoadState('networkidle')9 ]);10 console.log(request.url());11 await browser.close();12})();13const { chromium } = require('playwright');14(async () => {15 const browser = await chromium.launch();16 const context = await browser.newContext();17 const page = await context.newPage();18 const [response] = await Promise.all([19 page.waitForResponse(/.*\/fonts\/.*/),20 page.waitForLoadState('networkidle')21 ]);22 console.log(response.url());23 await browser.close();24})();25const { chromium } = require('playwright');26(async () => {27 const browser = await chromium.launch();28 const context = await browser.newContext();29 const page = await context.newPage();30 const [request] = await Promise.all([31 page.waitForRequest(/.*\/fonts\/.*/),32 page.waitForLoadState('networkidle')33 ]);34 console.log(request.url());35 await browser.close();36})();37const { chromium } = require('playwright');38(async () => {39 const browser = await chromium.launch();40 const context = await browser.newContext();41 const page = await context.newPage();42 const [response] = await Promise.all([43 page.waitForResponse(/.*\/fonts\/.*/),44 page.waitForLoadState('networkidle')45 ]);46 console.log(response.url());47 await browser.close();48})();49const { chromium } = require('playwright');50(async () => {51 const browser = await chromium.launch();52 const context = await browser.newContext();

Full Screen

Using AI Code Generation

copy

Full Screen

1const { waitForOutput } = require('playwright');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 [consoleMessage] = await Promise.all([8 page.waitForEvent('console'),9 page.evaluate(() => console.log('hello, world!')),10 ]);11 console.log(consoleMessage.text());12 await browser.close();13})();14const { waitForOutput } = require('playwright');15const { chromium } = require('playwright');16(async () => {17 const browser = await chromium.launch();18 const context = await browser.newContext();19 const page = await context.newPage();20 const [consoleMessage] = await Promise.all([21 page.waitForEvent('console'),22 page.evaluate(() => console.log('hello, world!')),23 ]);24 console.log(consoleMessage.text());25 await browser.close();26})();27const { waitForOutput } = require('playwright');28const { chromium } = require('playwright');29(async () => {30 const browser = await chromium.launch();31 const context = await browser.newContext();32 const page = await context.newPage();33 const [consoleMessage] = await Promise.all([34 page.waitForEvent('console'),35 page.evaluate(() => console.log('hello, world!')),36 ]);37 console.log(consoleMessage.text());38 await browser.close();39})();40const { waitForOutput } = require('playwright');41const { chromium } = require('playwright');42(async () => {43 const browser = await chromium.launch();44 const context = await browser.newContext();45 const page = await context.newPage();46 const [consoleMessage] = await Promise.all([

Full Screen

Using AI Code Generation

copy

Full Screen

1const playwright = require('playwright');2async function main() {3 const browser = await playwright.webkit.launch();4 const context = await browser.newContext();5 const page = await context.newPage();6 await page.waitForSelector('text=Get started');7 await page.click('text=Get started');8 await page.waitForSelector('text=Playwright is a Node library to automate');9 await page.click('text=Playwright is a Node library to automate');10 await page.waitForSelector('text=Playwright is a Node library to automate');11 await page.click('text=Playwright is a Node library to automate');12 await page.waitForSelector('text=Playwright is a Node library to automate');13 await page.click('text=Playwright is a Node library to automate');14 await page.waitForSelector('text=Playwright is a Node library to automate');15 await page.click('text=Playwright is a Node library to automate');16 await page.waitForSelector('text=Playwright is a Node library to automate');17 await page.click('text=Playwright is a Node library to automate');18 await page.waitForSelector('text=Playwright is a Node library to automate');19 await page.click('text=Playwright is a Node library to automate');20 await page.waitForSelector('text=Playwright is a Node library to automate');21 await page.click('text=Playwright is a Node library to automate');22 await page.waitForSelector('text=Playwright is a Node library to automate');23 await page.click('text=Playwright is a Node library to automate');24 await page.waitForSelector('text=Playwright is a Node library to automate');25 await page.click('text=Playwright is a Node library to automate');26 await page.waitForSelector('text=Playwright is a Node library to automate');27 await page.click('text=Playwright is a Node library to automate');28 await page.waitForSelector('text=Playwright is a Node library to automate');29 await page.click('text=Playwright is a Node library to automate');30 await page.waitForSelector('text=Playwright is a Node library to automate');31 await page.click('text=Playwright is a Node library to automate');32 await page.waitForSelector('text=Playwright is a Node library to automate');33 await page.click('text=Playwright is a Node library

Full Screen

Using AI Code Generation

copy

Full Screen

1const playwright = require('playwright');2const { waitForOutput } = require('playwright/lib/server/stdio');3(async () => {4 const browser = await playwright.chromium.launch();5 const context = await browser.newContext();6 const page = await context.newPage();7 await page.click('text=Get started');8 await page.waitForSelector('text=Playwright is a Node library to automate Chromium, Firefox and WebKit with a single API.');9 await page.screenshot({ path: `example.png` });10 await browser.close();11})();12const { EventEmitter } = require('events');13const { helper } = require('./helper');14const { debugLogger } = require('./debugLogger');15const { ProgressController } = require('./progress');16const { TimeoutError } = require('./errors');17class Stdio extends EventEmitter {18 constructor() {19 super();20 this._progress = new ProgressController();21 this._debugLogger = debugLogger();22 this._stdout = '';23 this._stderr = '';24 this._closed = false;25 this._lastMessageId = 0;26 this._pendingMessages = new Map();27 this._lastError = null;28 this._lastErrorStack = null;29 this._debugLogger.on('message', message => {30 this._dispatch({31 params: { message }32 });33 });34 }35 _dispatch(message) {36 if (this._closed)37 return;38 if (message.id) {39 const callback = this._pendingMessages.get(message.id);40 if (callback) {41 this._pendingMessages.delete(message.id);42 callback(message.error, message.result);43 }44 } else {45 this.emit(message.method, message.params);46 }47 }48 _send(method, params) {49 const message = { method, params };50 if (this._closed)51 return Promise.reject(new Error('Protocol error (Target closed)'));52 if (this._lastError)53 return Promise.reject(new Error(this._lastError + '\n' + this._lastErrorStack));54 return new Promise((fulfill, reject) => {55 this._lastMessageId++;56 message.id = this._lastMessageId;57 this._pendingMessages.set(message.id, (error

Full Screen

Using AI Code Generation

copy

Full Screen

1const { waitForOutput } = require('@playwright/test/lib/utils/stdio');2const { waitForOutput } = require('@playwright/test/lib/utils/stdio');3(async () => {4 const { stdout } = await waitForOutput('npm', ['run', 'test'], {5 cwd: path.resolve(__dirname, 'my-app'),6 env: {7 },8 });9 console.log(stdout);10})();11const { waitForOutput } = require('@playwright/test/lib/utils/stdio');12(async () => {13 const { stdout } = await waitForOutput('npm', ['run', 'test'], {14 cwd: path.resolve(__dirname, 'my-app'),15 env: {16 },17 });18 console.log(stdout);19})();20const { waitForOutput } = require('@playwright/test/lib/utils/stdio');21(async () => {22 const { stdout } = await waitForOutput('npm', ['run', 'test'], {23 cwd: path.resolve(__dirname, 'my-app'),24 env: {25 },26 });27 console.log(stdout);28})();29const { waitForOutput } = require('@playwright/test/lib/utils/stdio');30(async () => {31 const { stdout } = await waitForOutput('npm', ['run', 'test'], {32 cwd: path.resolve(__dirname, 'my-app'),33 env: {34 },35 });36 console.log(stdout);37})();38const { waitForOutput } = require('@playwright/test/lib/utils/stdio');39(async () => {40 const { stdout } = await waitForOutput('npm', ['run', 'test'], {41 cwd: path.resolve(__dirname, 'my-app'),42 env: {43 },44 });45 console.log(stdout);46})();47const { waitForOutput } = require('@playwright/test/lib/utils/stdio');

Full Screen

Using AI Code Generation

copy

Full Screen

1const { waitForOutput } = require('playwright/lib/server/supplements/recorder/recorderSupplement');2await waitForOutput('Hello world');3const { waitForOutput } = require('playwright/lib/server/supplements/recorder/recorderSupplement');4await waitForOutput('Hello world');5const { waitForOutput } = require('playwright/lib/server/supplements/recorder/recorderSupplement');6await waitForOutput('Hello world');7const { waitForOutput } = require('playwright/lib/server/supplements/recorder/recorderSupplement');8await waitForOutput('Hello world');9const { waitForOutput } = require('playwright/lib/server/supplements/recorder/recorderSupplement');10await waitForOutput('Hello world');11const { waitForOutput } = require('playwright/lib/server/supplements/recorder/recorderSupplement');12await waitForOutput('Hello world');13const { waitForOutput } = require('playwright/lib/server/supplements/recorder/recorderSupplement');14await waitForOutput('Hello world');15const { waitForOutput } = require('playwright/lib/server/supplements/recorder/recorderSupplement');16await waitForOutput('Hello world');17const { waitForOutput } = require('playwright/lib/server/supplements/recorder/recorderSupplement');18await waitForOutput('Hello world');19const { waitForOutput } = require('playwright/lib/server/supplements/recorder/recorderSupplement');20await waitForOutput('Hello world');21const { waitForOutput } = require('playwright/lib/server/supplements/recorder/recorderSupplement');22await waitForOutput('Hello world');23const { waitForOutput } = require('playwright/lib/server/supplements/recorder/recorderSupplement');24await waitForOutput('Hello world');

Full Screen

Playwright tutorial

LambdaTest’s Playwright tutorial will give you a broader idea about the Playwright automation framework, its unique features, and use cases with examples to exceed your understanding of Playwright testing. This tutorial will give A to Z guidance, from installing the Playwright framework to some best practices and advanced concepts.

Chapters:

  1. What is Playwright : Playwright is comparatively new but has gained good popularity. Get to know some history of the Playwright with some interesting facts connected with it.
  2. How To Install Playwright : Learn in detail about what basic configuration and dependencies are required for installing Playwright and run a test. Get a step-by-step direction for installing the Playwright automation framework.
  3. Playwright Futuristic Features: Launched in 2020, Playwright gained huge popularity quickly because of some obliging features such as Playwright Test Generator and Inspector, Playwright Reporter, Playwright auto-waiting mechanism and etc. Read up on those features to master Playwright testing.
  4. What is Component Testing: Component testing in Playwright is a unique feature that allows a tester to test a single component of a web application without integrating them with other elements. Learn how to perform Component testing on the Playwright automation framework.
  5. Inputs And Buttons In Playwright: Every website has Input boxes and buttons; learn about testing inputs and buttons with different scenarios and examples.
  6. Functions and Selectors in Playwright: Learn how to launch the Chromium browser with Playwright. Also, gain a better understanding of some important functions like “BrowserContext,” which allows you to run multiple browser sessions, and “newPage” which interacts with a page.
  7. Handling Alerts and Dropdowns in Playwright : Playwright interact with different types of alerts and pop-ups, such as simple, confirmation, and prompt, and different types of dropdowns, such as single selector and multi-selector get your hands-on with handling alerts and dropdown in Playright testing.
  8. Playwright vs Puppeteer: Get to know about the difference between two testing frameworks and how they are different than one another, which browsers they support, and what features they provide.
  9. Run Playwright Tests on LambdaTest: Playwright testing with LambdaTest leverages test performance to the utmost. You can run multiple Playwright tests in Parallel with the LammbdaTest test cloud. Get a step-by-step guide to run your Playwright test on the LambdaTest platform.
  10. Playwright Python Tutorial: Playwright automation framework support all major languages such as Python, JavaScript, TypeScript, .NET and etc. However, there are various advantages to Python end-to-end testing with Playwright because of its versatile utility. Get the hang of Playwright python testing with this chapter.
  11. Playwright End To End Testing Tutorial: Get your hands on with Playwright end-to-end testing and learn to use some exciting features such as TraceViewer, Debugging, Networking, Component testing, Visual testing, and many more.
  12. Playwright Video Tutorial: Watch the video tutorials on Playwright testing from experts and get a consecutive in-depth explanation of Playwright automation testing.

Run Playwright Internal 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