How to use createBrowser method in stryker-parent

Best JavaScript code snippet using stryker-parent

all-test.js

Source:all-test.js Github

copy

Full Screen

...109 app.get("/foo", function(req, res) {110 req.session.foo = 'foobar';111 res.send("hello");112 });113 var browser = tobi.createBrowser(app);114 browser.get("/foo", function(res, $) {115 self.callback(null, res);116 });117 },118 "includes a set-cookie header": function(err, res) {119 assert.isArray(res.headers['set-cookie']);120 },121 "only one set-cookie header": function(err, res) {122 assert.equal(res.headers['set-cookie'].length, 1);123 },124 "with an expires attribute": function(err, res) {125 assert.match(res.headers['set-cookie'][0], /expires/);126 },127 "with a path attribute": function(err, res) {128 assert.match(res.headers['set-cookie'][0], /path/);129 },130 "with an httpOnly attribute": function(err, res) {131 assert.match(res.headers['set-cookie'][0], /httponly/);132 }133 }134});135suite.addBatch({136 "across two requests" : {137 topic: function() {138 var self = this;139 // simple app140 var app = create_app();141 app.get("/foo", function(req, res) {142 req.session.reset();143 req.session.foo = 'foobar';144 req.session.bar = [1, 2, 3];145 res.send("foo");146 });147 app.get("/bar", function(req, res) {148 self.callback(null, req);149 res.send("bar");150 });151 var browser = tobi.createBrowser(app);152 browser.get("/foo", function(res, $) {153 browser.get("/bar", function(res, $) {154 });155 });156 },157 "session maintains state": function(err, req) {158 assert.equal(req.session.foo, 'foobar');159 assert.equal(req.session.bar.length, 3);160 assert.equal(req.session.bar[0], 1);161 assert.equal(req.session.bar[1], 2);162 assert.equal(req.session.bar[2], 3);163 }164 }165});166suite.addBatch({167 "across two requests" : {168 topic: function() {169 var self = this;170 // simple app171 var app = create_app();172 app.get("/foo", function(req, res) {173 req.session.reset();174 req.session.foo = 'foobar';175 res.send("foo");176 });177 app.get("/bar", function(req, res) {178 self.callback(null, req);179 res.send("bar");180 });181 var browser = tobi.createBrowser(app);182 browser.get("/foo", function(res, $) {183 browser.get("/bar", function(res, $) {184 });185 });186 },187 "resetting a session with an existing cookie value yields no variables": function(err, req) {188 req.session.reset();189 assert.isUndefined(req.session.foo);190 }191 }192});193suite.addBatch({194 "across three requests" : {195 topic: function() {196 var self = this;197 // simple app198 var app = create_app();199 app.get("/foo", function(req, res) {200 req.session.reset();201 req.session.foo = 'foobar';202 req.session.bar = 'foobar2';203 res.send("foo");204 });205 app.get("/bar", function(req, res) {206 delete req.session.bar;207 res.send("bar");208 });209 app.get("/baz", function(req, res) {210 self.callback(null, req);211 res.send("baz");212 });213 var browser = tobi.createBrowser(app);214 browser.get("/foo", function(res, $) {215 browser.get("/bar", function(res, $) {216 browser.get("/baz", function(res, $) {217 });218 });219 });220 },221 "session maintains state": function(err, req) {222 assert.equal(req.session.foo, 'foobar');223 assert.isUndefined(req.session.bar);224 }225 },226 "across three requests with deep objects" : {227 topic: function() {228 var self = this;229 // simple app230 var app = create_app();231 app.get("/foo", function(req, res) {232 req.session.reset();233 req.session.foo = 'foobar';234 req.session.bar = { a: 'b' };235 res.send("foo");236 });237 app.get("/bar", function(req, res) {238 req.session.bar.c = 'd';239 res.send("bar");240 });241 app.get("/baz", function(req, res) {242 self.callback(null, req);243 res.send("baz");244 });245 var browser = tobi.createBrowser(app);246 browser.get("/foo", function(res, $) {247 browser.get("/bar", function(res, $) {248 browser.get("/baz", function(res, $) {249 });250 });251 });252 },253 "session maintains state": function(err, req) {254 assert.equal(req.session.foo, 'foobar');255 assert.equal(req.session.bar.c, 'd');256 }257 }258});259suite.addBatch({260 "reading from an existing session" : {261 topic: function() {262 var self = this;263 // simple app264 var app = create_app();265 app.get("/foo", function(req, res) {266 req.session.foo = 'foobar';267 res.send("foo");268 });269 app.get("/bar", function(req, res) {270 res.send(req.session.foo);271 });272 var browser = tobi.createBrowser(app);273 browser.get("/foo", function(res, $) {274 browser.get("/bar", function(res, $) {275 // observe the response to the second request276 self.callback(null, res);277 });278 });279 },280 "does not set a cookie": function(err, res) {281 assert.isUndefined(res.headers['set-cookie']);282 }283 },284 "reading from a non-existing session" : {285 topic: function() {286 var self = this;287 // simple app288 var app = create_app();289 app.get("/foo", function(req, res) {290 // this should send undefined, not null291 res.send(req.session.foo);292 });293 var browser = tobi.createBrowser(app);294 browser.get("/foo", function(res, $) {295 self.callback(null, res, $);296 });297 },298 "does not set a cookie": function(err, res, body) {299 assert.isUndefined(res.headers['set-cookie']);300 assert.isUndefined(body);301 }302 }303});304suite.addBatch({305 "writing to a session" : {306 topic: function() {307 var self = this;308 // simple app309 var app = create_app();310 app.get("/foo", function(req, res) {311 req.session.foo = 'foobar';312 res.send("foo");313 });314 app.get("/bar", function(req, res) {315 req.session.reset();316 req.session.reset();317 req.session.bar = 'bar';318 req.session.baz = 'baz';319 res.send("bar");320 });321 var browser = tobi.createBrowser(app);322 browser.get("/foo", function(res, $) {323 browser.get("/bar", function(res, $) {324 // observe the response to the second request325 self.callback(null, res);326 });327 });328 },329 "sets a cookie": function(err, res) {330 assert.isArray(res.headers['set-cookie']);331 },332 "and only one cookie": function(err, res) {333 assert.equal(res.headers['set-cookie'].length, 1);334 }335 }336});337function create_app_with_duration() {338 // simple app339 var app = express.createServer();340 app.use(cookieSessions({341 cookieName: 'session',342 secret: 'yo',343 activeDuration: 0,344 duration: 500 // 0.5 seconds345 }));346 app.get("/foo", function(req, res) {347 req.session.reset();348 req.session.foo = 'foobar';349 res.send("foo");350 });351 return app;352}353suite.addBatch({354 "querying within duration" : {355 topic: function() {356 var self = this;357 var app = create_app_with_duration();358 app.get("/bar", function(req, res) {359 self.callback(null, req);360 res.send("bar");361 });362 var browser = tobi.createBrowser(app);363 browser.get("/foo", function(res, $) {364 setTimeout(function () {365 browser.get("/bar", function(res, $) {366 });367 }, 200);368 });369 },370 "session still has state": function(err, req) {371 assert.equal(req.session.foo, 'foobar');372 }373 }374});375suite.addBatch({376 "modifying the session": {377 topic: function() {378 var self = this;379 var app = create_app_with_duration();380 app.get("/bar", function(req, res) {381 self.callback(null, req);382 res.send("bar");383 });384 var browser = tobi.createBrowser(app);385 var firstCreatedAt, secondCreatedAt;386 browser.get("/foo", function(res, $) {387 browser.get("/bar", function(res, $) {388 });389 });390 },391 "doesn't change createdAt": function(err, req) {392 assert.equal(req.session.foo, 'foobar');393 }394 }395});396suite.addBatch({397 "querying outside the duration time": {398 topic: function() {399 var self = this;400 var app = create_app_with_duration();401 app.get("/bar", function(req, res) {402 self.callback(null, req);403 res.send("bar");404 });405 var browser = tobi.createBrowser(app);406 browser.get("/foo", function(res, $) {407 setTimeout(function () {408 browser.get("/bar", function(res, $) {409 });410 }, 800);411 });412 },413 "session no longer has state": function(err, req) {414 assert.isUndefined(req.session.foo);415 }416 }417});418suite.addBatch({419 "querying twice, each at 2/5 duration time": {420 topic: function() {421 var self = this;422 var app = create_app_with_duration();423 app.get("/bar", function(req, res) {424 req.session.baz = Math.random();425 res.send("bar");426 });427 app.get("/bar2", function(req, res) {428 self.callback(null, req);429 res.send("bar2");430 });431 var browser = tobi.createBrowser(app);432 // first query resets the session to full duration433 browser.get("/foo", function(res, $) {434 setTimeout(function () {435 // this query should NOT reset the session436 browser.get("/bar", function(res, $) {437 setTimeout(function () {438 // so the session should still be valid439 browser.get("/bar2", function(res, $) {440 });441 }, 200);442 });443 }, 200);444 });445 },446 "session still has state": function(err, req) {447 assert.isDefined(req.session.baz);448 }449 }450});451suite.addBatch({452 "querying twice, each at 3/5 duration time": {453 topic: function() {454 var self = this;455 var app = create_app_with_duration();456 app.get("/bar", function(req, res) {457 req.session.baz = Math.random();458 res.send("bar");459 });460 app.get("/bar2", function(req, res) {461 self.callback(null, req);462 res.send("bar2");463 });464 var browser = tobi.createBrowser(app);465 // first query resets the session to full duration466 browser.get("/foo", function(res, $) {467 setTimeout(function () {468 // this query should NOT reset the session469 browser.get("/bar", function(res, $) {470 setTimeout(function () {471 // so the session should be dead by now472 browser.get("/bar2", function(res, $) {473 });474 }, 300);475 });476 }, 300);477 });478 },479 "session no longer has state": function(err, req) {480 assert.isUndefined(req.session.baz);481 }482 }483});484function create_app_with_duration_modification() {485 // simple app486 var app = express.createServer();487 app.use(cookieSessions({488 cookieName: 'session',489 secret: 'yobaby',490 activeDuration: 0,491 duration: 5000 // 5.0 seconds492 }));493 app.get("/create", function(req, res) {494 req.session.foo = "foo";495 res.send("created");496 });497 app.get("/augment", function(req, res) {498 req.session.bar = "bar";499 res.send("augmented");500 });501 // invoking this will change the session duration to 500ms502 app.get("/change", function(req, res) {503 req.session.setDuration(500);504 res.send("duration changed");505 });506 return app;507}508suite.addBatch({509 "after changing cookie duration and querying outside the modified duration": {510 topic: function() {511 var self = this;512 var app = create_app_with_duration_modification();513 app.get("/complete", function(req, res) {514 self.callback(null, req);515 res.send("bar");516 });517 var browser = tobi.createBrowser(app);518 browser.get("/create", function(res, $) {519 browser.get("/change", function(res, $) {520 setTimeout(function () {521 browser.get("/complete", function(res, $) { });522 }, 700);523 });524 });525 },526 "session no longer has state": function(err, req) {527 assert.isUndefined(req.session.foo);528 }529 }530});531var initialCookie;532var updatedCookie;533suite.addBatch({534 "changing duration": {535 topic: function() {536 var self = this;537 var app = create_app_with_duration_modification();538 app.get("/complete", function(req, res) {539 self.callback(null, req);540 res.send("bar");541 });542 var browser = tobi.createBrowser(app);543 browser.get("/create", function(res, $) {544 initialCookie = browser.cookieJar.cookies[0].value;545 browser.get("/change", function(res, $) {546 updatedCookie = browser.cookieJar.cookies[0].value;547 browser.get("/complete", function(res, $) { });548 });549 });550 },551 "doesn't affect session variables": function(err, req) {552 assert.equal(req.session.foo, "foo");553 },554 "does update creation time": function(err, req) {555 assert.notEqual(initialCookie.split('.')[2],556 updatedCookie.split('.')[2],557 "after duration update, creation should be updated");558 },559 "does update duration": function(err, req) {560 assert.strictEqual(parseInt(initialCookie.split('.')[3], 10), 5000);561 assert.strictEqual(parseInt(updatedCookie.split('.')[3], 10), 500);562 }563 }564});565suite.addBatch({566 "after changing duration then setting a new session variable": {567 topic: function() {568 var self = this;569 var app = create_app_with_duration_modification();570 app.get("/set_then_duration", function(req, res) {571 req.session.baz = "baz";572 req.session.setDuration(500);573 res.send("did it");574 });575 app.get("/complete", function(req, res) {576 self.callback(null, req);577 res.send("bar");578 });579 var browser = tobi.createBrowser(app);580 browser.get("/create", function(res, $) {581 browser.get("/set_then_duration", function(res, $) {582 browser.get("/complete", function(res, $) { });583 });584 });585 },586 "variable is visible": function(err, req) {587 assert.equal(req.session.foo, "foo");588 assert.equal(req.session.baz, "baz");589 }590 }591});592suite.addBatch({593 "after setting a new session variable then changing duration": {594 topic: function() {595 var self = this;596 var app = create_app_with_duration_modification();597 app.get("/set_then_duration", function(req, res) {598 req.session.setDuration(500);599 req.session.baz = "baz";600 res.send("did it");601 });602 app.get("/complete", function(req, res) {603 self.callback(null, req);604 res.send("bar");605 });606 var browser = tobi.createBrowser(app);607 browser.get("/create", function(res, $) {608 browser.get("/set_then_duration", function(res, $) {609 browser.get("/complete", function(res, $) { });610 });611 });612 },613 "variable is visible": function(err, req) {614 assert.equal(req.session.foo, "foo");615 assert.equal(req.session.baz, "baz");616 }617 }618});619suite.addBatch({620 "setting new variables then invoking setDuration": {621 topic: function() {622 var self = this;623 var app = create_app_with_duration_modification();624 app.get("/complete", function(req, res) {625 self.callback(null, req);626 res.send("bar");627 });628 var browser = tobi.createBrowser(app);629 browser.get("/create", function(res, $) {630 browser.get("/change", function(res, $) {631 browser.get("/augment", function(res, $) {632 browser.get("/complete", function(res, $) { });633 });634 });635 });636 },637 "both variables are visible": function(err, req) {638 assert.equal(req.session.foo, "foo");639 assert.equal(req.session.bar, "bar");640 }641 }642});643function create_app_with_secure(firstMiddleware) {644 // set up the session middleware645 var middleware = cookieSessions({646 cookieName: 'session',647 secret: 'yo',648 activeDuration: 0,649 cookie: {650 maxAge: 5000,651 secure: true652 }653 });654 var app = express.createServer();655 if (firstMiddleware)656 app.use(firstMiddleware);657 app.use(middleware);658 return app;659}660suite.addBatch({661 "across two requests, without proxySecure, secure cookies" : {662 topic: function() {663 var self = this;664 var app = create_app_with_secure();665 app.get("/foo", function(req, res) {666 res.send("foo");667 });668 var browser = tobi.createBrowser(app);669 browser.get("/foo", function(res, $) {670 self.callback(null, res);671 });672 },673 "cannot be set": function(err, res) {674 assert.equal(res.statusCode, 500);675 }676 }677});678suite.addBatch({679 "across two requests, with proxySecure, secure cookies" : {680 topic: function() {681 var self = this;682 var app = create_app_with_secure(function(req, res, next) {683 // say it is proxySecure684 req.connection.proxySecure = true;685 next();686 });687 app.get("/foo", function(req, res) {688 res.send("foo");689 });690 var browser = tobi.createBrowser(app);691 browser.get("/foo", function(res, $) {692 self.callback(null, res);693 });694 },695 "can be set": function(err, res) {696 assert.equal(res.statusCode, 200);697 }698 }699});700suite.addBatch({701 "public encode and decode util methods" : {702 topic: function() {703 var self = this;704 var app = create_app();705 app.get("/foo", function(req, res) {706 self.callback(null, req);707 res.send("hello");708 });709 var browser = tobi.createBrowser(app);710 browser.get("/foo", function(res, $) {});711 },712 "encode " : function(err, req){713 var result = cookieSessions.util.encode({cookieName: 'session', secret: 'yo'}, {foo:'bar'});714 var result_arr = result.split(".");715 assert.equal(result_arr.length, 5);716 },717 "encode and decode - is object" : function(err, req){718 var encoded = cookieSessions.util.encode({cookieName: 'session', secret: 'yo'}, {foo:'bar'});719 var decoded = cookieSessions.util.decode({cookieName: 'session', secret: 'yo'}, encoded);720 assert.isObject(decoded);721 },722 "encode and decode - has all values" : function(err, req){723 var encoded = cookieSessions.util.encode({cookieName: 'session', secret: 'yo'}, {foo:'bar', bar:'foo'});724 var decoded = cookieSessions.util.decode({cookieName: 'session', secret: 'yo'}, encoded);725 assert.equal(decoded.content.foo, 'bar');726 assert.equal(decoded.content.bar, 'foo');727 assert.isNumber(decoded.duration);728 assert.isNumber(decoded.createdAt);729 },730 "encode and decode - override duration and createdAt" : function(err, req){731 var encoded = cookieSessions.util.encode({cookieName: 'session', secret: 'yo'}, {foo:'bar', bar:'foo'}, 5000, 1355408039221);732 var decoded = cookieSessions.util.decode({cookieName: 'session', secret: 'yo'}, encoded);733 assert.equal(decoded.duration, 5000);734 assert.equal(decoded.createdAt, 1355408039221);735 },736 "encode and decode - default duration" : function(err, req){737 var encoded = cookieSessions.util.encode({cookieName: 'session', secret: 'yo'}, {foo:'bar'});738 var decoded = cookieSessions.util.decode({cookieName: 'session', secret: 'yo'}, encoded);739 assert.equal(decoded.duration, 86400000);740 },741 "encode and decode - tampered HMAC" : function(err, req){742 var encodedReal = 'LVB3G2lnPF75RzsT9mz7jQ.RT1Lcq0dOJ_DMRHyWJ4NZPjBXr2WzkFcUC4NO78gbCQ.1371704898483.5000.ILEusgnajT1sqCWLuzaUt-HFn2KPjYNd38DhI7aRCb9';743 var encodedFake = encodedReal.substring(0, encodedReal.length - 1) + 'A';744 var decodedReal = cookieSessions.util.decode({cookieName: 'session', secret: 'yo'}, encodedReal);745 assert.isObject(decodedReal);746 var decodedFake = cookieSessions.util.decode({cookieName: 'session', secret: 'yo'}, encodedFake);747 assert.isUndefined(decodedFake);748 }749 }750});751suite.addBatch({752 "two middlewares": {753 topic: function() {754 var self = this;755 var app = create_app();756 app.get("/foo", function(req, res) {757 self.callback(null, req);758 res.send("hello");759 });760 var browser = tobi.createBrowser(app);761 browser.get("/foo", function(res, $){});762 },763 "We can write to both stores": function(err, req) {764 req.session.foo = 'bar';765 req.securestore.foo = 'buzz';766 req.securestore.widget = 4;767 assert.equal(req.session.foo, 'bar');768 assert.equal(req.securestore.foo, 'buzz');769 assert.equal(req.securestore.widget, 4);770 }771 }772});773suite.addBatch({774 "specifying requestKey different than cookieName": {775 topic: function() {776 var self = this;777 var app = express.createServer();778 app.use(cookieSessions({779 cookieName: 'ooga_booga_momma',780 activeDuration: 0,781 requestKey: 'ses',782 secret: 'yo'783 }));784 app.get('/foo', function(req, res) {785 self.callback(null, req);786 });787 var browser = tobi.createBrowser(app);788 browser.get("/foo", function(res, $){});789 },790 "session is defined as req[requestKey]": function(err, req) {791 assert.isObject(req.ses);792 assert.strictEqual(Object.keys(req.ses).length, 0);793 assert.isUndefined(req.session);794 assert.isUndefined(req.ooga_booga_momma);795 }796 }797});798suite.addBatch({799 "swapping two cookies": {800 topic: function() {801 var self = this;802 var app = create_app(); //important that they use the same secret803 app.get('/foo', function(req, res) {804 req.session.foo = 'bar';805 req.securestore.foo = 'buzz';806 req.securestore.widget = 4;807 res.send('hello');808 });809 app.get('/bar', function(req, res) {810 self.callback(null, req);811 res.send('bye');812 });813 tobi.createBrowser(app).get('/foo', function(res, $){814 var cookies = res.headers['set-cookie'];815 var firstCookie = cookies[0];816 var secondCookie = cookies[1];817 function getCookieName(cookieHeader) {818 return cookieHeader.substring(0, cookieHeader.indexOf('='));819 }820 function getCookieValue(cookieHeader) {821 return cookieHeader.substring(cookieHeader.indexOf('='), cookieHeader.indexOf(';'));822 }823 var firstHijack = getCookieName(firstCookie) + getCookieValue(secondCookie);824 var secondHijack = getCookieName(secondCookie) + getCookieValue(firstCookie);825 // new browser, because tobi overwrites the passed cookies826 // header with its cookie jar, so we need a new jar827 tobi.createBrowser(app).get('/bar', {828 headers: { 'Cookie': firstHijack + '; ' + secondHijack } 829 }, function(res, $){});830 });831 },832 "doesn't keep using cookie": function(err, req) {833 // session.foo should not be what securestore.foo was, or else834 // we swapped cookies!835 assert.notEqual(req.session.foo, 'buzz');836 assert.notEqual(req.session.widget, 4);837 assert.notEqual(req.securestore.foo, 'bar');838 }839 }840});841suite.addBatch({842 "missing cookie maxAge": {843 topic: function() {844 var self = this;845 var app = express.createServer();846 app.use(cookieSessions({847 cookieName: 'session',848 duration: 50000,849 activeDuration: 0,850 secret: 'yo'851 }));852 app.get("/foo", function(req, res) {853 req.session.foo = 'foobar';854 res.send("hello");855 });856 var browser = tobi.createBrowser(app);857 browser.get("/foo", function(res, $) {858 self.callback(null, res);859 });860 },861 "still has an expires attribute": function(err, res) {862 assert.match(res.headers['set-cookie'][0], /expires/, "cookie is a session cookie");863 },864 "which roughly matches the session duration": function(err, res) {865 var expiryValue = res.headers['set-cookie'][0].replace(/^.*expires=([^;]+);.*$/, "$1");866 var expiryDate = new Date(expiryValue);867 var cookieDuration = expiryDate.getTime() - Date.now();868 assert(Math.abs(50000 - cookieDuration) < 1500, "expiry is pretty far from the specified duration");869 }870 },871 "changing the duration": {872 topic: function() {873 var self = this;874 var app = express.createServer();875 app.use(cookieSessions({876 cookieName: 'session',877 duration: 500,878 activeDuration: 0,879 secret: 'yo'880 }));881 app.get("/foo", function(req, res) {882 req.session.foo = 'foobar';883 res.send("hello");884 });885 app.get("/bar", function(req, res) {886 req.session.setDuration(5000);887 res.send("bar");888 });889 var browser = tobi.createBrowser(app);890 browser.get("/foo", function(res, $) {891 setTimeout(function () {892 browser.get("/bar", function(res, $) {893 self.callback(null, res);894 });895 }, 200);896 });897 },898 "updates the cookie expiry": function(err, res) {899 var expiryValue = res.headers['set-cookie'][0].replace(/^.*expires=([^;]+);.*$/, "$1");900 var expiryDate = new Date(expiryValue);901 var cookieDuration = expiryDate.getTime() - Date.now();902 assert(Math.abs(cookieDuration - 5000) < 1000, "expiry is pretty far from the specified duration");903 }904 },905 "active user with session close to expiration": {906 topic: function() {907 var app = express.createServer();908 var self = this;909 app.use(cookieSessions({910 cookieName: 'session',911 duration: 300,912 activeDuration: 500,913 secret: 'yo'914 }));915 app.get("/foo", function(req, res) {916 req.session.foo = 'foobar';917 res.send("hello");918 });919 app.get("/bar", function(req, res) {920 req.session.bar = 'baz';921 res.send('hi');922 });923 app.get("/baz", function(req, res) {924 res.json({ "msg": req.session.foo + req.session.bar });925 });926 var browser = tobi.createBrowser(app);927 browser.get("/foo", function() {928 browser.get("/bar", function() {929 setTimeout(function () {930 browser.get("/baz", function(res, first) {931 setTimeout(function() {932 browser.get('/baz', function(res, second) {933 self.callback(null, first, second);934 });935 }, 1000);936 });937 }, 400);938 });939 });940 },941 "extends session duration": function(err, extended, tooLate) {942 assert.equal(extended.msg, 'foobarbaz');943 assert.equal(tooLate.msg, null);944 }945 }946});947var shared_browser1;948var shared_browser2;949suite.addBatch({950 "non-ephemeral cookie": {951 topic: function() {952 var self = this;953 var app = express.createServer();954 app.use(cookieSessions({955 cookieName: 'session',956 duration: 5000,957 secret: 'yo',958 cookie: {959 ephemeral: false960 }961 }));962 app.get("/foo", function(req, res) {963 req.session.foo = 'foobar';964 res.send("hello");965 });966 app.get("/bar", function(req, res) {967 req.session.setDuration(6000, true);968 res.send("hello");969 });970 shared_browser1 = tobi.createBrowser(app);971 shared_browser1.get("/foo", function(res, $) {972 self.callback(null, res);973 });974 },975 "has an expires attribute": function(err, res) {976 assert.match(res.headers['set-cookie'][0], /expires/, "cookie is a session cookie");977 },978 "changing to an ephemeral one": {979 topic: function() {980 var self = this;981 shared_browser1.get("/bar", function(res, $) {982 self.callback(null, res);983 });984 },985 "removes its expires attribute": function(err, res) {986 assert.strictEqual(res.headers['set-cookie'][0].indexOf('expires='), -1, "cookie is not ephemeral");987 }988 }989 },990 "ephemeral cookie": {991 topic: function() {992 var self = this;993 var app = express.createServer();994 app.use(cookieSessions({995 cookieName: 'session',996 duration: 50000,997 activeDuration: 0,998 secret: 'yo',999 cookie: {1000 ephemeral: true1001 }1002 }));1003 app.get("/foo", function(req, res) {1004 req.session.foo = 'foobar';1005 res.send("hello");1006 });1007 app.get("/bar", function(req, res) {1008 req.session.setDuration(6000, false);1009 res.send("hello");1010 });1011 shared_browser2 = tobi.createBrowser(app);1012 shared_browser2.get("/foo", function(res, $) {1013 self.callback(null, res);1014 });1015 },1016 "doesn't have an expires attribute": function(err, res) {1017 assert.strictEqual(res.headers['set-cookie'][0].indexOf('expires='), -1, "cookie is not ephemeral");1018 },1019 "changing to an non-ephemeral one": {1020 topic: function() {1021 var self = this;1022 shared_browser2.get("/bar", function(res, $) {1023 self.callback(null, res);1024 });1025 },...

Full Screen

Full Screen

main.js

Source:main.js Github

copy

Full Screen

...18}19// 监听页面加载完成,然后创建窗口20// app.on('ready', createBrowser)21app.whenReady().then(() => {22 createBrowser()23 // 当 Linux 和 Windows 应用在没有窗口打开时退出了,macOS 应用通常即使在没有打开任何窗口的情况下也继续运行,并且在没有窗口可用的情况下激活应用时会打开新的窗口。24 app.on('activate', function () {25 if (BrowserWindow.getAllWindows().length === 0) createBrowser()26 })27})28app.on('window-all-closed', () => {29 // 如果不是macos平台,则退出应用30 if (process.platform !== 'darwin') {31 app.quit()32 }33})34// 如果被选中激活,且窗口没有激活的窗口,则创建一个35// app.on('activate', () => {36// if (BrowserWindow.getAllWindows().length === 0) {37// createBrowser()38// }...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var browser = createBrowser();2browser.findElement(by.name('q')).sendKeys('webdriver');3browser.findElement(by.name('btnG')).click();4browser.wait(until.titleIs('webdriver - Google Search'), 1000);5var webdriver = require('selenium-webdriver');6var chrome = require('selenium-webdriver/chrome');7var service = new chrome.ServiceBuilder(chromeDriverPath).build();8chrome.setDefaultService(service);9var driver = new webdriver.Builder()10 .withCapabilities(webdriver.Capabilities.chrome())11 .build();12module.exports = {13 createBrowser: function () {14 return driver;15 }16};17var webdriver = require('selenium-webdriver');18var chrome = require('selenium-webdriver/chrome');19var service = new chrome.ServiceBuilder(chromeDriverPath).build();20chrome.setDefaultService(service);21var driver = new webdriver.Builder()22 .withCapabilities(webdriver.Capabilities.chrome())23 .build();24module.exports = {25 createBrowser: function () {26 return driver;27 }28};29module.exports = function(config) {30 config.set({

Full Screen

Using AI Code Generation

copy

Full Screen

1const strykerParent = require('stryker-parent');2const browser = strykerParent.createBrowser();3const strykerParent = require('stryker-parent');4const browser = strykerParent.createBrowser();5const strykerParent = require('stryker-parent');6const browser = strykerParent.createBrowser();7const strykerParent = require('stryker-parent');8const browser = strykerParent.createBrowser();9const strykerParent = require('stryker-parent');10const browser = strykerParent.createBrowser();11const strykerParent = require('stryker-parent');12const browser = strykerParent.createBrowser();13const strykerParent = require('stryker-parent');14const browser = strykerParent.createBrowser();15const strykerParent = require('stryker-parent');16const browser = strykerParent.createBrowser();17const strykerParent = require('stryker-parent');18const browser = strykerParent.createBrowser();19const strykerParent = require('stryker-parent');20const browser = strykerParent.createBrowser();21const strykerParent = require('stryker-parent');22const browser = strykerParent.createBrowser();23const strykerParent = require('stryker-parent');24const browser = strykerParent.createBrowser();25const strykerParent = require('stryker-parent');

Full Screen

Using AI Code Generation

copy

Full Screen

1const createBrowser = require('stryker-parent').createBrowser;2const browser = createBrowser('Chrome');3const createBrowser = require('stryker-parent').createBrowser;4const browser = createBrowser('Chrome');5const createBrowser = require('stryker-parent').createBrowser;6const browser = createBrowser('Chrome');7const createBrowser = require('stryker-parent').createBrowser;8const browser = createBrowser('Chrome');9const createBrowser = require('stryker-parent').createBrowser;10const browser = createBrowser('Chrome');11const createBrowser = require('stryker-parent').createBrowser;12const browser = createBrowser('Chrome');13const createBrowser = require('stryker-parent').createBrowser;14const browser = createBrowser('Chrome');15const createBrowser = require('stryker-parent').createBrowser;16const browser = createBrowser('Chrome');17const createBrowser = require('stryker-parent').createBrowser;18const browser = createBrowser('Chrome');19const createBrowser = require('stryker-parent').createBrowser;20const browser = createBrowser('Chrome');21const createBrowser = require('stryker-parent').createBrowser;22const browser = createBrowser('Chrome');23const createBrowser = require('stryker-parent').createBrowser;24const browser = createBrowser('Chrome');25const createBrowser = require('stryker-parent').createBrowser;26const browser = createBrowser('Chrome');

Full Screen

Using AI Code Generation

copy

Full Screen

1const createBrowser = require('stryker-parent').createBrowser;2const createBrowser2 = require('stryker-parent').createBrowser;3const createBrowser3 = require('stryker-parent').createBrowser;4const createBrowser4 = require('stryker-parent').createBrowser;5const createBrowser5 = require('stryker-parent').createBrowser;6const createBrowser6 = require('stryker-parent').createBrowser;7const createBrowser7 = require('stryker-parent').createBrowser;8const createBrowser8 = require('stryker-parent').createBrowser;9const createBrowser9 = require('stryker-parent').createBrowser;10const createBrowser10 = require('stryker-parent').createBrowser;11const createBrowser11 = require('stryker-parent').createBrowser;12const createBrowser12 = require('stryker-parent').createBrowser;13const createBrowser13 = require('stryker-parent').createBrowser;14const createBrowser14 = require('stryker-parent').createBrowser;15const createBrowser15 = require('stryker-parent').createBrowser;16const createBrowser16 = require('stryker-parent').createBrowser;17const createBrowser17 = require('stryker-parent').createBrowser;18const createBrowser18 = require('stryker-parent').createBrowser;19const createBrowser19 = require('stryker-parent').createBrowser;

Full Screen

Using AI Code Generation

copy

Full Screen

1const { createBrowser } = require('stryker-parent');2const browser = createBrowser({ headless: false });3console.log(browser);4const { createBrowser } = require('stryker-parent');5const browser = createBrowser({ headless: false });6console.log(browser);7const { createBrowser } = require('stryker-parent');8const browser = createBrowser({ headless: false });9console.log(browser);10module.exports = function (config) {11 config.set({12 jest: {13 }14 });15}16module.exports = {17 transform: {18 }19};20module.exports = function (api) {21 api.cache(true);22 {23 targets: {24 }25 }26 ];27 const plugins = [];28 return {29 };30};31{32 {33 "targets": {

Full Screen

Using AI Code Generation

copy

Full Screen

1var createBrowser = require('stryker-parent').createBrowser;2var browser = createBrowser();3browser.quit();4var browser = createBrowser({5 chromeOptions: {6 }7});

Full Screen

Using AI Code Generation

copy

Full Screen

1const { createBrowser } = require('stryker-parent');2const browser = await createBrowser();3await browser.close();4### createBrowser(options?: BrowserOptions): Promise<Browser>5#### browser.get(url: string): Promise<void>6#### browser.close(): Promise<void>7The [Puppeteer Page](

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 stryker-parent 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