How to use smoke.test method in Cypress

Best JavaScript code snippet using cypress

User.js

Source:User.js Github

copy

Full Screen

1var mock = require("../../mock");2var utils = require("../../utils");3var defaultHeaders = mock.defaultHeaders;4var simpleResponse = mock.simpleResponse;5var client = utils.createClient();6var createArray = utils.createArray;7describe("lib/graph/User.js", function() {8 describe("User", function() {9 var user = client.user("abc");10 var id = "123";11 describe("#base", function() {12 it("should be specific to the users entity type", function() {13 expect(user.base).to.equal("users");14 });15 });16 describe("#get(callback)", function() {17 it("should pass a smoke test", function(done) {18 server.respondWith("/users/abc", simpleResponse);19 user.get(done);20 });21 });22 describe("#submissions([query], callback)", function() {23 it("should pass a smoke test", function(done) {24 server.respondWith("/users/abc/submissions", simpleResponse);25 user.submissions(done);26 });27 it("should pass additional querystring arguments", function(done) {28 server.respondWith("/users/abc/submissions?limit=5", [29 200,30 defaultHeaders,31 JSON.stringify(createArray(5, function() {32 return {33 id: chance.guid()34 };35 }))]);36 user.submissions({37 limit: 538 }, function(err, results) {39 if (err) return done(err);40 expect(results.length).to.equal(5);41 done();42 });43 });44 });45 describe("#incomingSubmissions([query], callback)", function() {46 it("should pass a smoke test", function(done) {47 server.respondWith("/users/abc/submissions/incoming", simpleResponse);48 user.incomingSubmissions(done);49 });50 });51 describe("#incomingRoleSubmissions([query], callback)", function() {52 it("should pass a smoke test", function(done) {53 server.respondWith("/users/abc/submissions/incoming_roles", simpleResponse);54 user.incomingRoleSubmissions(done);55 });56 });57 describe("#receivedInvites([query], callback)", function() {58 it("should pass a smoke test", function(done) {59 server.respondWith("/users/abc/invites/received", simpleResponse);60 user.receivedInvites(done);61 });62 });63 describe("#sentInvites([query], callback)", function() {64 it("should pass a smoke test", function(done) {65 server.respondWith("/users/abc/invites/sent", simpleResponse);66 user.sentInvites(done);67 });68 });69 describe("#relationships([query], callback)", function() {70 it("should pass a smoke test", function(done) {71 server.respondWith("/users/abc/relationships", simpleResponse);72 user.relationships(done);73 });74 it("should pass additional query string arguments", function(done) {75 server.respondWith("/users/abc/relationships?limit=5", [76 200,77 defaultHeaders,78 JSON.stringify(createArray(5, function() {79 return {80 id: chance.guid()81 };82 }))]);83 user.relationships({84 limit: 585 }, function(err, results) {86 if (err) return done(err);87 expect(results.length).to.equal(5);88 done();89 });90 });91 });92 describe("#submission([id])", function() {93 it("should create a Submission with User as it's owner", function() {94 var sub = user.submission();95 expect(sub).to.be.a(client.Submission);96 expect(sub.owner).to.equal(user);97 });98 });99 describe("#moderations([query], callback)", function() {100 it("should pass a smoke test", function(done) {101 server.respondWith("/users/abc/moderations", simpleResponse);102 user.moderations(done);103 });104 it("should pass additional querystring arguments", function(done) {105 server.respondWith("/users/abc/moderations?limit=5", [106 200,107 defaultHeaders,108 JSON.stringify(createArray(5, function() {109 return {110 id: chance.guid()111 };112 }))]);113 user.moderations({114 limit: 5115 }, function(err, results) {116 if (err) return done(err);117 expect(results.length).to.equal(5);118 done();119 });120 });121 });122 describe("#moderationsSummary(query, callback)", function() {123 it("should pass a smoke test", function(done) {124 server.respondWith("/users/abc/moderations/summary", simpleResponse);125 user.moderationsSummary(done);126 });127 });128 describe("#moderation([id])", function() {129 it("should create a Moderation with User as it's owner", function() {130 var sub = user.moderation();131 expect(sub).to.be.a(client.Moderation);132 expect(sub.owner).to.equal(user);133 });134 });135 describe("#authored([query], callback)", function() {136 it("should pass a smoke test", function(done) {137 server.respondWith("/users/abc/authored", simpleResponse);138 user.authored(done);139 });140 it("should pass additional querystring arguments", function(done) {141 server.respondWith("/users/abc/authored?limit=5", [142 200,143 defaultHeaders,144 JSON.stringify(createArray(5, function() {145 return {146 id: chance.guid()147 };148 }))]);149 user.authored({150 limit: 5151 }, function(err, results) {152 if (err) return done(err);153 expect(results.length).to.equal(5);154 done();155 });156 });157 });158 describe("#content([query], callback)", function() {159 it("should pass a smoke test", function(done) {160 server.respondWith("/users/abc/content", simpleResponse);161 user.content(done);162 });163 it("should pass additional querystring arguments", function(done) {164 server.respondWith("/users/abc/content?limit=5", [165 200,166 defaultHeaders,167 JSON.stringify(createArray(5, function() {168 return {169 id: chance.guid()170 };171 }))]);172 user.content({173 limit: 5174 }, function(err, results) {175 if (err) return done(err);176 expect(results.length).to.equal(5);177 done();178 });179 });180 });181 describe("#feed([query], callback)", function() {182 it("should pass a smoke test", function(done) {183 server.respondWith("/users/abc/feed", simpleResponse);184 user.feed(done);185 });186 it("should pass additional querystring arguments", function(done) {187 server.respondWith("/users/abc/feed?limit=5", [188 200,189 defaultHeaders,190 JSON.stringify(createArray(5, function() {191 return {192 id: chance.guid()193 };194 }))]);195 user.feed({196 limit: 5197 }, function(err, results) {198 if (err) return done(err);199 expect(results.length).to.equal(5);200 done();201 });202 });203 });204 describe("#network([query], callback)", function() {205 it("should pass a smoke test", function(done) {206 server.respondWith("/users/abc/network", simpleResponse);207 user.network(done);208 });209 it("should pass additional querystring arguments", function(done) {210 server.respondWith("/users/abc/network?limit=5", [211 200,212 defaultHeaders,213 JSON.stringify(createArray(5, function() {214 return {215 id: chance.guid()216 };217 }))]);218 user.network({219 limit: 5220 }, function(err, results) {221 if (err) return done(err);222 expect(results.length).to.equal(5);223 done();224 });225 });226 });227 describe("#roleUpdate(params, callback)", function() {228 it("should pass a smoke test", function(done) {229 server.respondWith("/users/abc/submissions", simpleResponse);230 user.roleUpdate({}, done);231 });232 });233 describe("#roleDelete(obj, callback)", function() {234 it("should pass a smoke test", function(done) {235 server.respondWith("/users/abc/network/obj", simpleResponse);236 user.roleDelete("obj", done);237 });238 });239 describe("#role([entity], callback)", function() {240 it("should pass a smoke test (no entity)", function(done) {241 server.respondWith("/users/abc/role", simpleResponse);242 user.role(done);243 });244 it("should pass a smoke test (with entity)", function(done) {245 server.respondWith("/users/abc/role?for=def", simpleResponse);246 user.role("def", done);247 });248 });249 describe("#alert(id)", function() {250 it("should return an Alert object", function() {251 expect(user.alert("abc")).to.be.a(client.Alert);252 });253 it("should set the owner as the user", function() {254 expect(user.alert("abc").owner).to.equal(user);255 });256 });257 describe("#alerts([query], callback)", function() {258 it("should pass a smoke test", function(done) {259 server.respondWith("/users/abc/alerts", simpleResponse);260 user.alerts(done);261 });262 });263 describe("#emailList(callback)", function() {264 it("should pass a smoke test", function(done) {265 server.respondWith("/users/abc/emails", simpleResponse);266 user.emailList(done);267 });268 });269 describe("#emailAdd(params, callback)", function() {270 it("should pass a smoke test", function(done) {271 server.respondWith("/users/abc/emails", simpleResponse);272 user.emailAdd({}, done);273 });274 });275 describe("#emailUpdate(params, email, callback)", function() {276 it("should pass a smoke test", function(done) {277 server.respondWith("/users/abc/emails/email", simpleResponse);278 user.emailUpdate({}, "email", done);279 });280 });281 describe("#passwordUpdate(params, callback)", function() {282 it("should pass a smoke test", function(done) {283 server.respondWith("/users/abc", simpleResponse);284 user.passwordUpdate({}, done);285 });286 });287 describe("#emailDelete(obj, callback)", function() {288 it("should pass a smoke test", function(done) {289 server.respondWith("/users/abc/emails/obj", simpleResponse);290 user.emailDelete("obj", done);291 });292 });293 describe("#alertsStats(callback)", function() {294 it("should pass a smoke test", function(done) {295 server.respondWith("/users/abc/alerts/stats", simpleResponse);296 user.alertsStats(done);297 });298 });299 describe("#preferences([query], callback)", function() {300 it("should pass a smoke test", function(done) {301 server.respondWith("/users/abc/preferences", simpleResponse);302 user.preferences(done);303 });304 it("should pass additional querystring arguments", function(done) {305 server.respondWith("/users/abc/preferences?weekly_email_digest=true", [306 200,307 defaultHeaders,308 JSON.stringify(createArray(5, function() {309 return {310 id: chance.guid()311 };312 }))]);313 user.preferences({314 weekly_email_digest: true315 }, function(err, results) {316 if (err) return done(err);317 expect(results.length);318 done();319 });320 });321 });322 describe("#participation([key], [entity], callback)", function() {323 it("should pass a smoke test", function(done) {324 server.respondWith("/users/abc/participation", simpleResponse);325 user.participation(done);326 });327 it("should pass a smoke test (with key)", function(done) {328 server.respondWith("/users/abc/participation/impact", simpleResponse);329 user.participation("impact", done);330 });331 it("should pass a smoke test (with entity)", function(done) {332 server.respondWith("/users/abc/participation?for=def", simpleResponse);333 user.participation(null, "def", done);334 });335 it("should pass a smoke test (with key and entity)", function(done) {336 server.respondWith("/users/abc/participation/impact?for=def", simpleResponse);337 user.participation("impact", "def", done);338 });339 });340 describe("#author(type, params, callback)", function() {341 it("should pass a smoke test", function(done) {342 server.respondWith("/users/abc/hours", simpleResponse);343 user.author("hours", {}, done);344 });345 it("should automatically turn Date objects into ISO strings", function(done) {346 server.respondWith("/users/abc/hours", simpleResponse);347 var params = {348 start_ts: new Date(),349 end_ts: new Date()350 };351 user.author("hours", params, done);352 expect(params.start_ts).to.be.a("string");353 expect(params.end_ts).to.be.a("string");354 });355 });356 describe("#add(type, id, params, callback)", function() {357 it("should pass a smoke test", function(done) {358 server.respondWith("/users/abc/hours", simpleResponse);359 user.add("hours", {}, done);360 });361 });362 describe("#authorModify(type, id, params, callback)", function() {363 it("should pass a smoke test", function(done) {364 server.respondWith("/users/abc/hours/123", simpleResponse);365 user.authorModify("hours", id, {}, done);366 });367 it("should automatically turn Date objects into ISO strings", function(done) {368 server.respondWith("/users/abc/hours/123", simpleResponse);369 var params = {370 start_ts: new Date(),371 end_ts: new Date()372 };373 user.authorModify("hours", id, params, done);374 expect(params.start_ts).to.be.a("string");375 expect(params.end_ts).to.be.a("string");376 });377 });378 describe("#contribute(params, callback)", function() {379 it("should pass a smoke test", function(done) {380 server.respondWith("/users/abc/submissions", simpleResponse);381 user.contribute({}, done);382 });383 });384 describe("#favorite(entity, callback)", function() {385 it("should pass a smoke test", function(done) {386 server.respondWith("/users/abc/favorites/test", simpleResponse);387 user.favorite("test", done);388 });389 });390 describe("#unfavorite(entity, callback)", function() {391 it("should pass a smoke test", function(done) {392 server.respondWith("/users/abc/favorites/test", simpleResponse);393 user.unfavorite("test", done);394 });395 });396 describe("#activity([query], callback)", function() {397 it("should pass a smoke test", function(done) {398 server.respondWith("/users/abc/activity", simpleResponse);399 user.activity(done);400 });401 });402 describe("#oppHoursSummary(params, callback)", function() {403 it("should pass a smoke test", function(done) {404 server.respondWith("/users/abc/opportunities/123/hours/summary", simpleResponse);405 user.oppHoursSummary(id, {}, done);406 });407 });408 describe("#oppHoursByStatus(params, callback)", function() {409 it("should pass a smoke test", function(done) {410 server.respondWith("/users/abc/opportunities/123/hours/by_status", simpleResponse);411 user.oppHoursByStatus(id, {}, done);412 });413 });414 describe("#oppsWorked(params, callback)", function() {415 it("should pass a smoke test", function(done) {416 server.respondWith("/users/abc/opportunities/worked", simpleResponse);417 user.oppsWorked({}, done);418 });419 });420 });...

Full Screen

Full Screen

harness.js

Source:harness.js Github

copy

Full Screen

1/*2 Copyright (c) 2014, Oracle and/or its affiliates. All rights3 reserved.4 5 This program is free software; you can redistribute it and/or6 modify it under the terms of the GNU General Public License7 as published by the Free Software Foundation; version 2 of8 the License.9 10 This program is distributed in the hope that it will be useful,11 but WITHOUT ANY WARRANTY; without even the implied warranty of12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the13 GNU General Public License for more details.14 15 You should have received a copy of the GNU General Public License16 along with this program; if not, write to the Free Software17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA18 02110-1301 USA19 */20"use strict";21/* This test harness is documented in the README file.22*/23var path = require("path"),24 fs = require("fs"),25 assert = require("assert"),26 util = require("util");27var udebug = unified_debug.getLogger("harness.js");28var re_matching_test_case = /Test\.js$/;29var disabledTests = {};30try {31 disabledTests = require("../disabled-tests.conf").disabledTests;32}33catch(e) {}34/* Test 35*/36function Test(name, phase) {37 this.filename = "";38 this.name = name;39 this.phase = (typeof(phase) === 'number') ? phase : 2;40 this.errorMessages = '';41 this.index = 0;42 this.failed = null;43 this.skipped = false;44}45function SmokeTest(name) {46 this.name = name;47 this.phase = 0;48}49SmokeTest.prototype = new Test();50function ConcurrentTest(name) {51 this.name = name;52 this.phase = 1;53}54ConcurrentTest.prototype = new Test();55function SerialTest(name) {56 this.name = name;57 this.phase = 2;58}59SerialTest.prototype = new Test();60function ClearSmokeTest(name) {61 this.name = name;62 this.phase = 3;63}64ClearSmokeTest.prototype = new Test();65Test.prototype.test = function(result) {66 udebug.log_detail('test starting:', this.suite.name, this.name);67 this.result = result;68 result.listener.startTest(this);69 var runReturnCode;70 udebug.log_detail('test.run:', this.suite.name, this.name);71 try {72 runReturnCode = this.run();73 }74 catch(e) {75 console.log(this.name, 'threw exception & failed\n', e.stack);76 this.failed = true;77 result.fail(this, e);78 return;79 }80 if(! runReturnCode) {81 // async test must call Test.pass or Test.fail when done82 udebug.log(this.name, 'started.');83 return;84 }85 // Test ran synchronously. Fail if any error messages have been reported.86 if(! this.skipped) {87 if (this.errorMessages === '') {88 udebug.log_detail(this.name, 'passed');89 result.pass(this);90 } else {91 this.failed = true;92 udebug.log_detail(this.name, 'failed');93 result.fail(this, this.errorMessages);94 }95 }96};97Test.prototype.pass = function() {98 if (this.failed !== null) {99 console.log('Error: pass called with status already ' + (this.failed?'failed':'passed'));100 assert(this.failed === null);101 } else {102 if (this.session && !this.session.isClosed()) {103 // if session is open, close it104 if (this.session.currentTransaction().isActive()) {105 console.log('Test.pass found active transaction');106 }107 this.session.close();108 }109 this.failed = false;110 this.result.pass(this);111 }112};113Test.prototype.fail = function(message) {114 if (this.failed !== null) {115 console.log('Error: pass called with status already ' + (this.failed?'failed':'passed'));116 assert(this.failed === null);117 } else {118 if (this.session && !this.session.isClosed()) {119 // if session is open, close it120 this.session.close();121 }122 this.failed = true;123 if (message) {124 this.appendErrorMessage(message);125 this.stack = message.stack;126 }127 this.result.fail(this, { 'message' : this.errorMessages, 'stack': this.stack});128 }129};130Test.prototype.appendErrorMessage = function(message) {131 this.errorMessages += message;132 this.errorMessages += '\n';133};134Test.prototype.error = Test.prototype.appendErrorMessage;135Test.prototype.failOnError = function() {136 if (this.errorMessages !== '') {137 this.fail();138 } else {139 this.pass();140 }141};142Test.prototype.skip = function(message) {143 this.skipped = true;144 this.result.skip(this, message);145 return true;146};147Test.prototype.isTest = function() { return true; };148Test.prototype.fullName = function() {149 var n = "";150 if(this.suite) { n = n + this.suite.name + " "; }151 if(this.filename) { n = n + path.basename(this.filename) + " "; }152 return n + this.name;153};154Test.prototype.run = function() {155 throw {156 "name" : "unimplementedTest",157 "message" : "this test does not have a run() method"158 };159};160function getType(obj) {161 var type = typeof(obj);162 if (type === 'object') return obj.constructor.name;163 return type;164}165function compare(o1, o2) {166 if (o1 == o2) return true;167 if (o1 == null && o2 == null) return true;168 if (typeof(o1) === 'undefined' && typeof(o2) === 'undefined') return true;169 if (typeof(o1) !== typeof(o2)) return false;170 if (o1.toString() === o2.toString()) return true;171 return false;172}173Test.prototype.errorIfNotEqual = function(message, o1, o2) {174 if (!compare(o1, o2)) {175 var o1type = getType(o1);176 var o2type = getType(o2);177 message += ': expected (' + o1type + ') ' + o1 + '; actual (' + o2type + ') ' + o2 + '\n';178 this.errorMessages += message;179 }180};181Test.prototype.errorIfNotStrictEqual = function(message, o1, o2) {182 if(o1 !== o2) {183 var o1type = getType(o1);184 var o2type = getType(o2);185 message += ': expected (' + o1type + ') ' + o1 + '; actual (' + o2type + ') ' + o2 + '\n';186 this.errorMessages += message;187 }188};189Test.prototype.errorIfTrue = function(message, o1) {190 if (o1) {191 message += ': expected not true; actual ' + o1 + '\n';192 this.errorMessages += message;193 }194};195Test.prototype.errorIfNotTrue = function(message, o1) {196 if (o1 !== true) {197 message += ': expected true; actual ' + o1 + '\n';198 this.errorMessages += message;199 }200};201Test.prototype.errorIfNotError = function(message, o1) {202 if (!o1) {203 message += ' did not occur.\n';204 this.errorMessages += message;205 }206};207Test.prototype.errorIfNull = function(message, val) {208 if(val === null) {209 this.errorMessages += message;210 }211};212Test.prototype.errorIfNotNull = function(message, val) {213 if(val !== null) {214 this.errorMessages += message;215 }216};217/* Use this with the error argument in a callback */218Test.prototype.errorIfError = function(val) {219 if(typeof val !== 'undefined' && val !== null) {220 this.errorMessages += util.inspect(val);221 }222};223/* Value must be defined and not-null 224 Function returns true if there was no error; false on error 225*/226Test.prototype.errorIfUnset = function(message, value) {227 var r = (typeof value === 'undefined' || value === null); 228 if(r) {229 this.errorMessages += message;230 }231 return ! r;232};233Test.prototype.hasNoErrors = function() {234 return this.errorMessages.length === 0;235};236/** Suite237 * A suite consists of all tests in all test programs in a directory 238 *239 */240function Suite(name, path) {241 this.name = name;242 this.path = path;243 this.tests = [];244 this.currentTest = 0;245 this.smokeTest = {};246 this.concurrentTests = [];247 this.numberOfConcurrentTests = 0;248 this.numberOfConcurrentTestsCompleted = 0;249 this.numberOfConcurrentTestsStarted = 0;250 this.firstConcurrentTestIndex = -1;251 this.serialTests = [];252 this.numberOfSerialTests = 0;253 this.firstSerialTestIndex = -1;254 this.nextSerialTestIndex = -1;255 this.clearSmokeTest = {};256 this.testInFile = null;257 this.suite = {};258 this.numberOfRunningConcurrentTests = 0;259 this.skipSmokeTest = false;260 this.skipClearSmokeTest = false;261 udebug.log_detail('Creating Suite for', name, path);262}263Suite.prototype.addTest = function(filename, test) {264 this.filename = path.relative(mynode.fs.suites_dir, filename);265 udebug.log_detail('Suite', this.name, 'adding test', test.name, 'from', this.filename);266 test.filename = filename;267 test.suite = this;268 if(disabledTests && disabledTests[this.filename]) {269 udebug.log("Skipping ", this.filename, "[DISABLED]");270 }271 else {272 this.tests.push(test);273 }274 return test;275};276Suite.prototype.addTestsFromFile = function(f, onlyTests) {277 var t, i, j, k, testList, testHash;278 if(onlyTests) {279 onlyTests = String(onlyTests);280 testList = onlyTests.split(",");281 testHash = [];282 for(i = 0 ; i < testList.length ; i ++) {283 k = Number(testList[i]) - 1;284 testHash[k] = 1;285 }286 }287 if(re_matching_test_case.test(f)) {288 t = require(f);289 if(typeof(t.tests) === 'object' && t.tests instanceof Array) {290 for(j = 0 ; j < t.tests.length ; j++) {291 if(onlyTests === null || testHash[j] === 1) {292 this.addTest(f, t.tests[j]);293 }294 }295 } 296 else if(typeof(t.isTest) === 'function' && t.isTest()) {297 this.addTest(f, t);298 }299 else { 300 console.log("Warning: " + f + " does not export a Test.");301 }302 }303};304Suite.prototype.createTests = function() { 305 var stat = fs.statSync(this.path);306 var suite, i;307 308 if(stat.isFile()) {309 var testFile = this.path;310 this.path = path.dirname(testFile);311 try {312 this.addTestsFromFile(path.join(this.path, "SmokeTest.js"), null);313 } catch(e1) {}314 this.addTestsFromFile(testFile, this.testInFile);315 try {316 this.addTestsFromFile(path.join(this.path, "ClearSmokeTest.js"), null);317 } catch(e2) {}318 }319 else if(stat.isDirectory()) {320 var files = fs.readdirSync(this.path);321 for(i = 0; i < files.length ; i++) {322 this.addTestsFromFile(path.join(this.path, files[i]), null);323 }324 }325 udebug.log_detail('Suite', this.name, 'found', this.tests.length, 'tests.');326 this.tests.forEach(function(t, index) {327 t.original = index;328 });329 this.tests.sort(function(a,b) {330 // sort the tests by phase, preserving the original order within each phase331 if(a.phase < b.phase) { return -1; }332 if(a.phase === b.phase) { return (a.original < b.original)?-1:1; }333 return 1;334 });335 suite = this;336 this.tests.forEach(function(t, index) {337 t.index = index;338 t.suite = suite;339 switch(t.phase) {340 case 0:341 suite.smokeTest = t;342 break;343 case 1:344 suite.concurrentTests.push(t);345 if (suite.firstConcurrentTestIndex === -1) {346 suite.firstConcurrentTestIndex = t.index;347 udebug.log_detail('Suite.createTests firstConcurrentTestIndex:', suite.firstConcurrentTestIndex);348 }349 break;350 case 2:351 suite.serialTests.push(t);352 if (suite.firstSerialTestIndex === -1) {353 suite.firstSerialTestIndex = t.index;354 udebug.log_detail('Suite.createTests firstSerialTestIndex:', suite.firstSerialTestIndex);355 }356 break;357 case 3:358 suite.clearSmokeTest = t;359 break;360 }361 udebug.log_detail('createTests sorted test case', t.name, ' ', t.phase, ' ', t.index);362 });363 suite.numberOfConcurrentTests = suite.concurrentTests.length;364 udebug.log_detail('numberOfConcurrentTests for', suite.name, 'is', suite.numberOfConcurrentTests);365 suite.numberOfSerialTests = suite.serialTests.length;366 udebug.log_detail('numberOfSerialTests for', suite.name, 'is', suite.numberOfSerialTests);367};368Suite.prototype.runTests = function(result) {369 var tc;370 if (this.tests.length === 0) { 371 return false;372 }373 this.currentTest = 0;374 tc = this.tests[this.currentTest];375 switch (tc.phase) {376 case 0:377 // smoke test378 // start the smoke test379 if(this.skipSmokeTest) {380 tc.result = result;381 tc.skip("skipping SmokeTest");382 }383 else {384 tc.test(result);385 }386 break;387 case 1:388 // concurrent test is the first test389 // start all concurrent tests390 this.startConcurrentTests(result);391 break;392 case 2:393 // serial test is the first test394 this.startSerialTests(result);395 break;396 case 3:397 // clear smoke test is the first test398 if(this.skipClearSmokeTest) {399 tc.result = result;400 tc.skip("skipping ClearSmokeTest");401 }402 else {403 tc.test(result);404 }405 break;406 }407 return true;408};409Suite.prototype.startConcurrentTests = function(result) {410 var self = this;411 udebug.log_detail('Suite.startConcurrentTests');412 if (this.firstConcurrentTestIndex !== -1) {413 this.concurrentTests.forEach(function(testCase) {414 udebug.log_detail('Suite.startConcurrentTests starting ', self.name, testCase.name);415 testCase.test(result);416 self.numberOfConcurrentTestsStarted++;417 });418 return false; 419 } 420 // else:421 return this.startSerialTests(result);422};423Suite.prototype.startSerialTests = function(result) {424 assert(result);425 udebug.log_detail('Suite.startSerialTests');426 if (this.firstSerialTestIndex !== -1) {427 this.startNextSerialTest(this.firstSerialTestIndex, result);428 return false;429 } 430 // else:431 return this.startClearSmokeTest(result);432};433Suite.prototype.startClearSmokeTest = function(result) {434 assert(result);435 udebug.log_detail('Suite.startClearSmokeTest');436 if (this.skipClearSmokeTest) {437 this.clearSmokeTest.result = result;438 this.clearSmokeTest.skip("skipping ClearSmokeTest");439 }440 else if (this.clearSmokeTest && this.clearSmokeTest.test) {441 this.clearSmokeTest.test(result);442 return false;443 } 444 return true;445};446Suite.prototype.startNextSerialTest = function(index, result) {447 assert(result);448 var testCase = this.tests[index];449 testCase.test(result);450};451/* Notify the suite that a test has completed.452 Returns false if there are more tests to be run,453 true if suite is complete.454 */455Suite.prototype.testCompleted = function(testCase) {456 var tc, index;457 udebug.log_detail('Suite.testCompleted for', this.name, testCase.name, 'phase', 458 testCase.phase);459 var result = testCase.result;460 switch (testCase.phase) {461 case 0: // the smoke test completed462 if (testCase.failed) { // if the smoke test failed, we are done463 return true; 464 } 465 udebug.log_detail('Suite.testCompleted; starting concurrent tests');466 return this.startConcurrentTests(result);467 case 1: // one of the concurrent tests completed468 udebug.log_detail('Completed ', this.numberOfConcurrentTestsCompleted, 469 ' out of ', this.numberOfConcurrentTests);470 if (++this.numberOfConcurrentTestsCompleted === this.numberOfConcurrentTests) {471 return this.startSerialTests(result); // go on to the serial tests472 }473 return false;474 case 2: // one of the serial tests completed475 index = testCase.index + 1;476 if (index < this.tests.length) {477 tc = this.tests[index];478 if (tc.phase === 2) { // start another serial test479 tc.test(result);480 } 481 else if (tc.phase === 3) { // start the clear smoke test482 this.startClearSmokeTest(result);483 }484 return false;485 }486 /* Done */487 udebug.log_detail('Suite.testCompleted there is no ClearSmokeTest so we are done with ' + testCase.suite.name);488 return true;489 case 3: // the clear smoke test completed490 udebug.log_detail('Suite.testCompleted completed ClearSmokeTest.');491 return true;492 }493};494/* Listener495*/496function Listener() {497 this.started = 0;498 this.ended = 0;499 this.printStackTraces = false;500 this.runningTests = {};501}502Listener.prototype.startTest = function(t) { 503 this.started++;504 this.runningTests[t.fullName()] = 1;505};506Listener.prototype.pass = function(t) {507 this.ended++;508 delete this.runningTests[t.fullName()];509 console.log("[pass]", t.fullName() );510};511Listener.prototype.skip = function(t, message) {512 this.skipped++;513 delete this.runningTests[t.fullName()];514 console.log("[skipped]", t.fullName(), "\t", message);515};516Listener.prototype.fail = function(t, e) {517 var message = "";518 this.ended++;519 delete this.runningTests[t.fullName()];520 if (e) {521 if (typeof(e.stack) !== 'undefined') {522 t.stack = e.stack;523 }524 if (typeof(e.message) !== 'undefined') {525 message = e.message;526 } else {527 message = e.toString();528 }529 }530 if ((this.printStackTraces) && typeof(t.stack) !== 'undefined') {531 message = t.stack;532 }533 if(t.phase === 0) {534 console.log("[FailSmokeTest]", t.fullName(), "\t", message);535 }536 else {537 console.log("[FAIL]", t.fullName(), "\t", message);538 }539};540Listener.prototype.listRunningTests = function() {541 console.log(this.runningTests);542};543/* QuietListener */544function QuietListener() {545 this.started = 0;546 this.ended = 0;547 this.runningTests = {};548}549QuietListener.prototype.startTest = Listener.prototype.startTest;550QuietListener.prototype.pass = function(t) {551 this.ended++;552 delete this.runningTests[t.fullName()];553};554QuietListener.prototype.skip = QuietListener.prototype.pass;555QuietListener.prototype.fail = QuietListener.prototype.pass;556QuietListener.prototype.listRunningTests = Listener.prototype.listRunningTests;557/* FailOnlyListener */558function FailOnlyListener() {559 this.fail = Listener.prototype.fail;560}561FailOnlyListener.prototype = new QuietListener();562 563/* Result 564*/565function Result(driver) {566 this.driver = driver;567 this.passed = [];568 this.failed = [];569 this.skipped = [];570}571Result.prototype.pass = function(t) {572 this.passed.push(t.name);573 this.listener.pass(t);574 this.driver.testCompleted(t);575};576Result.prototype.fail = function(t, e) {577 this.failed.push(t.name);578 this.listener.fail(t, e);579 this.driver.testCompleted(t);580};581Result.prototype.skip = function(t, reason) {582 this.skipped.push(t.name);583 this.listener.skip(t, reason);584 this.driver.testCompleted(t);585};586/* Exports from this module */587exports.Test = Test;588exports.Suite = Suite;589exports.Listener = Listener;590exports.QuietListener = QuietListener;591exports.FailOnlyListener = FailOnlyListener;592exports.Result = Result;593exports.SmokeTest = SmokeTest;594exports.ConcurrentTest = ConcurrentTest;595exports.SerialTest = SerialTest;...

Full Screen

Full Screen

verify.js

Source:verify.js Github

copy

Full Screen

1const _ = require('lodash')2const chalk = require('chalk')3const Listr = require('listr')4const debug = require('debug')('cypress:cli')5const verbose = require('@cypress/listr-verbose-renderer')6const { stripIndent } = require('common-tags')7const Promise = require('bluebird')8const logSymbols = require('log-symbols')9const path = require('path')10const os = require('os')11const { throwFormErrorText, errors } = require('../errors')12const util = require('../util')13const logger = require('../logger')14const xvfb = require('../exec/xvfb')15const state = require('./state')16const VERIFY_TEST_RUNNER_TIMEOUT_MS = 3000017const checkExecutable = (binaryDir) => {18 const executable = state.getPathToExecutable(binaryDir)19 debug('checking if executable exists', executable)20 return util.isExecutableAsync(executable)21 .then((isExecutable) => {22 debug('Binary is executable? :', isExecutable)23 if (!isExecutable) {24 return throwFormErrorText(errors.binaryNotExecutable(executable))()25 }26 })27 .catch({ code: 'ENOENT' }, () => {28 if (util.isCi()) {29 return throwFormErrorText(errors.notInstalledCI(executable))()30 }31 return throwFormErrorText(errors.missingApp(binaryDir))(stripIndent`32 Cypress executable not found at: ${chalk.cyan(executable)}33 `)34 })35}36const runSmokeTest = (binaryDir, options) => {37 let executable = state.getPathToExecutable(binaryDir)38 const onSmokeTestError = (smokeTestCommand, linuxWithDisplayEnv) => {39 return (err) => {40 debug('Smoke test failed:', err)41 let errMessage = err.stderr || err.message42 debug('error message:', errMessage)43 if (err.timedOut) {44 debug('error timedOut is true')45 return throwFormErrorText(46 errors.smokeTestFailure(smokeTestCommand, true),47 )(errMessage)48 }49 if (linuxWithDisplayEnv && util.isBrokenGtkDisplay(errMessage)) {50 util.logBrokenGtkDisplayWarning()51 return throwFormErrorText(errors.invalidSmokeTestDisplayError)(errMessage)52 }53 return throwFormErrorText(errors.missingDependency)(errMessage)54 }55 }56 const needsXvfb = xvfb.isNeeded()57 debug('needs Xvfb?', needsXvfb)58 /**59 * Spawn Cypress running smoke test to check if all operating system60 * dependencies are good.61 */62 const spawn = (linuxWithDisplayEnv) => {63 const random = _.random(0, 1000)64 const args = ['--smoke-test', `--ping=${random}`]65 if (needsSandbox()) {66 // electron requires --no-sandbox to run as root67 debug('disabling Electron sandbox')68 args.unshift('--no-sandbox')69 }70 if (options.dev) {71 executable = 'node'72 args.unshift(73 path.resolve(__dirname, '..', '..', '..', 'scripts', 'start.js'),74 )75 }76 const smokeTestCommand = `${executable} ${args.join(' ')}`77 debug('running smoke test')78 debug('using Cypress executable %s', executable)79 debug('smoke test command:', smokeTestCommand)80 debug('smoke test timeout %d ms', options.smokeTestTimeout)81 const env = _.extend({}, process.env, {82 ELECTRON_ENABLE_LOGGING: true,83 })84 const stdioOptions = _.extend({}, {85 env,86 timeout: options.smokeTestTimeout,87 })88 return Promise.resolve(util.exec(89 executable,90 args,91 stdioOptions,92 ))93 .catch(onSmokeTestError(smokeTestCommand, linuxWithDisplayEnv))94 .then((result) => {95 // TODO: when execa > 1.1 is released96 // change this to `result.all` for both stderr and stdout97 // use lodash to be robust during tests against null result or missing stdout98 const smokeTestStdout = _.get(result, 'stdout', '')99 debug('smoke test stdout "%s"', smokeTestStdout)100 if (!util.stdoutLineMatches(String(random), smokeTestStdout)) {101 debug('Smoke test failed because could not find %d in:', random, result)102 const smokeTestStderr = _.get(result, 'stderr', '')103 const errorText = smokeTestStderr || smokeTestStdout104 return throwFormErrorText(errors.smokeTestFailure(smokeTestCommand, false))(errorText)105 }106 })107 }108 const spawnInXvfb = (linuxWithDisplayEnv) => {109 return xvfb110 .start()111 .then(() => {112 return spawn(linuxWithDisplayEnv)113 })114 .finally(xvfb.stop)115 }116 const userFriendlySpawn = (linuxWithDisplayEnv) => {117 debug('spawning, should retry on display problem?', Boolean(linuxWithDisplayEnv))118 return spawn(linuxWithDisplayEnv)119 .catch({ code: 'INVALID_SMOKE_TEST_DISPLAY_ERROR' }, () => {120 return spawnInXvfb(linuxWithDisplayEnv)121 })122 }123 if (needsXvfb) {124 return spawnInXvfb()125 }126 // if we are on linux and there's already a DISPLAY127 // set, then we may need to rerun cypress after128 // spawning our own Xvfb server129 const linuxWithDisplayEnv = util.isPossibleLinuxWithIncorrectDisplay()130 return userFriendlySpawn(linuxWithDisplayEnv)131}132function testBinary (version, binaryDir, options) {133 debug('running binary verification check', version)134 // if running from 'cypress verify', don't print this message135 if (!options.force) {136 logger.log(stripIndent`137 It looks like this is your first time using Cypress: ${chalk.cyan(version)}138 `)139 }140 logger.log()141 // if we are running in CI then use142 // the verbose renderer else use143 // the default144 let renderer = util.isCi() ? verbose : 'default'145 if (logger.logLevel() === 'silent') renderer = 'silent'146 const rendererOptions = {147 renderer,148 }149 const tasks = new Listr([150 {151 title: util.titleize('Verifying Cypress can run', chalk.gray(binaryDir)),152 task: (ctx, task) => {153 debug('clearing out the verified version')154 return state.clearBinaryStateAsync(binaryDir)155 .then(() => {156 return Promise.all([157 runSmokeTest(binaryDir, options),158 Promise.resolve().delay(1500), // good user experience159 ])160 })161 .then(() => {162 debug('write verified: true')163 return state.writeBinaryVerifiedAsync(true, binaryDir)164 })165 .then(() => {166 util.setTaskTitle(167 task,168 util.titleize(169 chalk.green('Verified Cypress!'),170 chalk.gray(binaryDir),171 ),172 rendererOptions.renderer,173 )174 })175 },176 },177 ], rendererOptions)178 return tasks.run()179}180const maybeVerify = (installedVersion, binaryDir, options) => {181 return state.getBinaryVerifiedAsync(binaryDir)182 .then((isVerified) => {183 debug('is Verified ?', isVerified)184 let shouldVerify = !isVerified185 // force verify if options.force186 if (options.force) {187 debug('force verify')188 shouldVerify = true189 }190 if (shouldVerify) {191 return testBinary(installedVersion, binaryDir, options)192 .then(() => {193 if (options.welcomeMessage) {194 logger.log()195 logger.log('Opening Cypress...')196 }197 })198 }199 })200}201const start = (options = {}) => {202 debug('verifying Cypress app')203 const packageVersion = util.pkgVersion()204 let binaryDir = state.getBinaryDir(packageVersion)205 _.defaults(options, {206 dev: false,207 force: false,208 welcomeMessage: true,209 smokeTestTimeout: VERIFY_TEST_RUNNER_TIMEOUT_MS,210 })211 if (options.dev) {212 return runSmokeTest('', options)213 }214 const parseBinaryEnvVar = () => {215 const envBinaryPath = util.getEnv('CYPRESS_RUN_BINARY')216 debug('CYPRESS_RUN_BINARY exists, =', envBinaryPath)217 logger.log(stripIndent`218 ${chalk.yellow('Note:')} You have set the environment variable:219 ${chalk.white('CYPRESS_RUN_BINARY=')}${chalk.cyan(envBinaryPath)}220 This overrides the default Cypress binary path used.221 `)222 logger.log()223 return util.isExecutableAsync(envBinaryPath)224 .then((isExecutable) => {225 debug('CYPRESS_RUN_BINARY is executable? :', isExecutable)226 if (!isExecutable) {227 return throwFormErrorText(errors.CYPRESS_RUN_BINARY.notValid(envBinaryPath))(stripIndent`228 The supplied binary path is not executable229 `)230 }231 })232 .then(() => {233 return state.parseRealPlatformBinaryFolderAsync(envBinaryPath)234 })235 .then((envBinaryDir) => {236 if (!envBinaryDir) {237 return throwFormErrorText(errors.CYPRESS_RUN_BINARY.notValid(envBinaryPath))()238 }239 debug('CYPRESS_RUN_BINARY has binaryDir:', envBinaryDir)240 binaryDir = envBinaryDir241 })242 .catch({ code: 'ENOENT' }, (err) => {243 return throwFormErrorText(errors.CYPRESS_RUN_BINARY.notValid(envBinaryPath))(err.message)244 })245 }246 return Promise.try(() => {247 debug('checking environment variables')248 if (util.getEnv('CYPRESS_RUN_BINARY')) {249 return parseBinaryEnvVar()250 }251 })252 .then(() => {253 return checkExecutable(binaryDir)254 })255 .tap(() => {256 return debug('binaryDir is ', binaryDir)257 })258 .then(() => {259 return state.getBinaryPkgAsync(binaryDir)260 })261 .then((pkg) => {262 return state.getBinaryPkgVersion(pkg)263 })264 .then((binaryVersion) => {265 if (!binaryVersion) {266 debug('no Cypress binary found for cli version ', packageVersion)267 return throwFormErrorText(errors.missingApp(binaryDir))(`268 Cannot read binary version from: ${chalk.cyan(state.getBinaryPkgPath(binaryDir))}269 `)270 }271 debug(`Found binary version ${chalk.green(binaryVersion)} installed in: ${chalk.cyan(binaryDir)}`)272 if (binaryVersion !== packageVersion) {273 // warn if we installed with CYPRESS_INSTALL_BINARY or changed version274 // in the package.json275 logger.log(`Found binary version ${chalk.green(binaryVersion)} installed in: ${chalk.cyan(binaryDir)}`)276 logger.log()277 logger.warn(stripIndent`278 ${logSymbols.warning} Warning: Binary version ${chalk.green(binaryVersion)} does not match the expected package version ${chalk.green(packageVersion)}279 These versions may not work properly together.280 `)281 logger.log()282 }283 return maybeVerify(binaryVersion, binaryDir, options)284 })285 .catch((err) => {286 if (err.known) {287 throw err288 }289 return throwFormErrorText(errors.unexpected)(err.stack)290 })291}292const isLinuxLike = () => os.platform() !== 'win32'293/**294 * Returns true if running on a system where Electron needs "--no-sandbox" flag.295 * @see https://crbug.com/638180296 *297 * On Debian we had problems running in sandbox even for non-root users.298 * @see https://github.com/cypress-io/cypress/issues/5434299 * Seems there is a lot of discussion around this issue among Electron users300 * @see https://github.com/electron/electron/issues/17972301*/302const needsSandbox = () => isLinuxLike()303module.exports = {304 start,305 VERIFY_TEST_RUNNER_TIMEOUT_MS,306 needsSandbox,...

Full Screen

Full Screen

HealthCheckControllerTests.js

Source:HealthCheckControllerTests.js Github

copy

Full Screen

1const { expect } = require('chai')2const Settings = require('settings-sharelatex')3const User = require('./helpers/User').promises4describe('HealthCheckController', function() {5 describe('SmokeTests', function() {6 let user, projectId7 beforeEach(async function() {8 user = new User()9 await user.login()10 projectId = await user.createProject('SmokeTest')11 // HACK: Inject the details into the app12 Settings.smokeTest.userId = user.id13 Settings.smokeTest.user = user.email14 Settings.smokeTest.password = user.password15 Settings.smokeTest.projectId = projectId16 })17 async function performSmokeTestRequest() {18 const start = Date.now()19 const { response, body } = await user.doRequest('GET', {20 url: '/health_check/full',21 json: true22 })23 const end = Date.now()24 expect(body).to.exist25 expect(body.stats).to.exist26 expect(Date.parse(body.stats.start)).to.be.within(start, start + 1000)27 expect(Date.parse(body.stats.end)).to.be.within(end - 1000, end)28 expect(body.stats.duration).to.be.within(0, 10000)29 expect(body.stats.steps).to.be.instanceof(Array)30 return { response, body }31 }32 describe('happy path', function() {33 it('should respond with a 200 and stats', async function() {34 const { response, body } = await performSmokeTestRequest()35 expect(body.error).to.not.exist36 expect(response.statusCode).to.equal(200)37 })38 })39 describe('when the request is aborted', function() {40 it('should not crash', async function() {41 try {42 await user.doRequest('GET', {43 timeout: 1,44 url: '/health_check/full',45 json: true46 })47 } catch (err) {48 expect(err.code).to.be.oneOf(['ETIMEDOUT', 'ESOCKETTIMEDOUT'])49 return50 }51 expect.fail('expected request to fail with timeout error')52 })53 })54 describe('when the project does not exist', function() {55 beforeEach(function() {56 Settings.smokeTest.projectId = '404'57 })58 it('should respond with a 500 ', async function() {59 const { response, body } = await performSmokeTestRequest()60 expect(body.error).to.equal('run.101_loadEditor failed')61 expect(response.statusCode).to.equal(500)62 })63 })64 describe('when the password mismatches', function() {65 beforeEach(function() {66 Settings.smokeTest.password = 'foo-bar'67 })68 it('should respond with a 500 with mismatching password', async function() {69 const { response, body } = await performSmokeTestRequest()70 expect(body.error).to.equal('run.002_login failed')71 expect(response.statusCode).to.equal(500)72 })73 })74 })...

Full Screen

Full Screen

check-workflow-run.js

Source:check-workflow-run.js Github

copy

Full Screen

1/*2 * Copyright 2021 New Relic Corporation. All rights reserved.3 * SPDX-License-Identifier: Apache-2.04 */5'use strict'6const Github = require('./github')7const SUCCESS_MSG = '*** [OK] ***'8const formatRun = (run) => {9 return {10 name: run.name,11 repository: run.repository.name,12 repoOwner: run.repository.owner.login,13 branch: run.head_branch,14 status: run.status,15 url: run.url,16 workflow_id: run.workflow_id,17 event: run.event18 }19}20async function checkWorkflowRun(repoOwner, branch) {21 const github = new Github(repoOwner)22 try {23 const results = {24 ci: false,25 smokeTest: false26 }27 const latestRun = await github.getLatestWorkflowRun('ci-workflow.yml', branch)28 if (latestRun === undefined) {29 console.log('No ci workflow run found.')30 } else {31 console.log('CI workflow run details: ', JSON.stringify(formatRun(latestRun)))32 if (latestRun.status === 'completed' && latestRun.conclusion === 'success') {33 results.ci = true34 }35 }36 const latestSmokeTestRun = await github.getLatestWorkflowRun('smoke-test-workflow.yml', branch)37 if (latestSmokeTestRun === undefined) {38 console.log('No smoke test workflow run found.')39 } else {40 console.log(41 'Smoke-test workflow run details: ',42 JSON.stringify(formatRun(latestSmokeTestRun))43 )44 if (45 latestSmokeTestRun.status === 'completed' &&46 latestSmokeTestRun.conclusion === 'success'47 ) {48 results.smokeTest = true49 }50 }51 if (results.ci && results.smokeTest) {52 console.log(SUCCESS_MSG)53 console.log('Latest ci and smoke-test runs were successful!')54 return true55 }56 if (!results.ci) {57 console.log('Latest ci workflow run result was not \'completed\' and \'success\'.')58 }59 if (!results.smokeTest) {60 console.log('Latest smoke-test workflow run result was not \'completed\' and \'success\'.')61 }62 return false63 } catch (err) {64 console.error(err)65 return false66 }67}...

Full Screen

Full Screen

AnalyticsManager.js

Source:AnalyticsManager.js Github

copy

Full Screen

1const Settings = require('settings-sharelatex')2const Metrics = require('../../infrastructure/Metrics')3const Queues = require('../../infrastructure/Queues')4function identifyUser(userId, oldUserId) {5 if (isAnalyticsDisabled() || isSmokeTestUser(userId)) {6 return7 }8 Metrics.analyticsQueue.inc({ status: 'adding', event_type: 'identify' })9 Queues.analytics.events10 .add('identify', { userId, oldUserId })11 .then(() => {12 Metrics.analyticsQueue.inc({ status: 'added', event_type: 'identify' })13 })14 .catch(() => {15 Metrics.analyticsQueue.inc({ status: 'error', event_type: 'identify' })16 })17}18function recordEvent(userId, event, segmentation) {19 if (isAnalyticsDisabled() || isSmokeTestUser(userId)) {20 return21 }22 Metrics.analyticsQueue.inc({ status: 'adding', event_type: 'event' })23 Queues.analytics.events24 .add('event', { userId, event, segmentation })25 .then(() => {26 Metrics.analyticsQueue.inc({ status: 'added', event_type: 'event' })27 })28 .catch(() => {29 Metrics.analyticsQueue.inc({ status: 'error', event_type: 'event' })30 })31}32function updateEditingSession(userId, projectId, countryCode) {33 if (isAnalyticsDisabled() || isSmokeTestUser(userId)) {34 return35 }36 Metrics.analyticsQueue.inc({37 status: 'adding',38 event_type: 'editing-session'39 })40 Queues.analytics.editingSessions41 .add({ userId, projectId, countryCode })42 .then(() => {43 Metrics.analyticsQueue.inc({44 status: 'added',45 event_type: 'editing-session'46 })47 })48 .catch(() => {49 Metrics.analyticsQueue.inc({50 status: 'error',51 event_type: 'editing-session'52 })53 })54}55function isSmokeTestUser(userId) {56 const smokeTestUserId = Settings.smokeTest && Settings.smokeTest.userId57 return smokeTestUserId != null && userId.toString() === smokeTestUserId58}59function isAnalyticsDisabled() {60 return !(Settings.analytics && Settings.analytics.enabled)61}62module.exports = {63 identifyUser,64 recordEvent,65 updateEditingSession...

Full Screen

Full Screen

dir_79bb74e2ba89dcccae6feb005da3c12b.js

Source:dir_79bb74e2ba89dcccae6feb005da3c12b.js Github

copy

Full Screen

1var dir_79bb74e2ba89dcccae6feb005da3c12b =2[3 [ "AttachmentSmokeTest.php", "_attachment_smoke_test_8php.html", [4 [ "Swift_Smoke_AttachmentSmokeTest", "class_swift___smoke___attachment_smoke_test.html", "class_swift___smoke___attachment_smoke_test" ]5 ] ],6 [ "BasicSmokeTest.php", "_basic_smoke_test_8php.html", [7 [ "Swift_Smoke_BasicSmokeTest", "class_swift___smoke___basic_smoke_test.html", "class_swift___smoke___basic_smoke_test" ]8 ] ],9 [ "HtmlWithAttachmentSmokeTest.php", "_html_with_attachment_smoke_test_8php.html", [10 [ "Swift_Smoke_HtmlWithAttachmentSmokeTest", "class_swift___smoke___html_with_attachment_smoke_test.html", "class_swift___smoke___html_with_attachment_smoke_test" ]11 ] ],12 [ "InternationalSmokeTest.php", "_international_smoke_test_8php.html", [13 [ "Swift_Smoke_InternationalSmokeTest", "class_swift___smoke___international_smoke_test.html", "class_swift___smoke___international_smoke_test" ]14 ] ]...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1describe('My First Test', function() {2 it('Does not do much!', function() {3 cy.contains('type').click()4 cy.url().should('include', '/commands/actions')5 cy.get('.action-email')6 .type('

Full Screen

Using AI Code Generation

copy

Full Screen

1describe('My First Test', () => {2 it('Does not do much!', () => {3 expect(true).to.equal(true)4 })5})6describe('My First Test', () => {7 it('Does not do much!', () => {8 smoke.test('login')9 })10})11describe('My First Test', () => {12 it('Does not do much!', () => {13 smoke.test('login')14 smoke.test('header')15 smoke.test('footer')16 })17})18describe('My First Test', () => {19 it('Does not do much!', () => {20 smoke.test('login')21 smoke.test('header')22 smoke.test('footer')23 smoke.test('contact')24 })25})26describe('My First Test', () => {27 it('Does not do much!', () => {28 smoke.test('login')29 smoke.test('header')30 smoke.test('footer')31 smoke.test('contact')32 smoke.test('about')33 })34})35describe('My First Test', () => {36 it('Does not do much!', () => {37 smoke.test('login')38 smoke.test('header')39 smoke.test('footer')40 smoke.test('contact')41 smoke.test('about')42 smoke.test('home')43 })44})45describe('My First Test', () => {46 it('Does not do much!', () => {47 smoke.test('login')48 smoke.test('header')49 smoke.test('footer')50 smoke.test('contact')51 smoke.test('about')52 smoke.test('home')53 smoke.test('login')54 smoke.test('header')55 smoke.test('footer')56 smoke.test('contact')57 smoke.test('about')58 smoke.test('home')59 })60})61describe('My First Test', () => {62 it('Does not do much!', () => {63 smoke.test('login')64 smoke.test('header')65 smoke.test('footer')66 smoke.test('contact')67 smoke.test('about')68 smoke.test('home')69 smoke.test('login')70 smoke.test('header')71 smoke.test('footer')

Full Screen

Using AI Code Generation

copy

Full Screen

1describe('Smoke Test', function() {2 it('Visits the Kitchen Sink', function() {3 cy.contains('type').click()4 cy.url().should('include', '/commands/actions')5 cy.get('.action-email')6 .type('

Full Screen

Using AI Code Generation

copy

Full Screen

1import { smoke } from "@cypress/code-coverage/task";2describe("Smoke Tests", () => {3 before(() => {4 });5 it("should have a title", () => {6 smoke.test("title", () => {7 cy.title().should("include", "Kitchen Sink");8 });9 });10 it("should have a button", () => {11 smoke.test("button", () => {12 cy.get("button").should("be.visible");13 });14 });15});16import { smoke } from "@cypress/code-coverage/task";17describe("Smoke Tests", () => {18 before(() => {19 });20 it("should have a title", () => {21 smoke.run("title", () => {22 cy.title().should("include", "Kitchen Sink");23 });24 });25 it("should have a button", () => {26 smoke.run("button", () => {27 cy.get("button").should("be.visible");28 });29 });30});31import { smoke } from "@cypress/code-coverage/task";32describe("Smoke Tests", () => {33 before(() => {34 });35 it("should have a title

Full Screen

Using AI Code Generation

copy

Full Screen

1describe("Smoke Test", () => {2 it("should have a title", () => {3 cy.title().should("eq", "React App");4 });5});6describe("Smoke Test", () => {7 it("should have a title", () => {8 cy.title().should("eq", "React App");9 });10});11describe("Smoke Test", () => {12 it("should have a title", () => {13 cy.title().should("eq", "React App");14 });15});16describe("Smoke Test", () => {17 it("should have a title", () => {18 cy.title().should("eq", "React App");19 });20});21describe("Smoke Test", () => {22 it("should have a title", () => {23 cy.title().should("eq", "React App");24 });25});26describe("Smoke Test", () => {27 it("should have a title", () => {28 cy.title().should("eq", "React App");29 });30});31describe("Smoke Test", () => {32 it("should have a title", () => {33 cy.title().should("eq", "React App");34 });35});36describe("Smoke Test", () => {37 it("should have a title", () => {38 cy.title().should("eq", "React App");39 });40});41describe("Smoke Test", () => {42 it("should have a title", () => {43 cy.title().should("eq", "React App");44 });45});46describe("Smoke Test

Full Screen

Using AI Code Generation

copy

Full Screen

1describe('Smoke Test', () => {2 it('should run smoke test', () => {3 cy.smokeTest();4 });5});6Cypress.Commands.add('smokeTest', () => {7 cy.visit('/login');8 cy.get('input[type=email]').type('

Full Screen

Using AI Code Generation

copy

Full Screen

1describe('Smoke test', function() {2 it('Smoke test', function() {3 cy.smokeTest()4 })5})6Cypress.Commands.add('smokeTest', () => {7 cy.get('h1').should('contain', 'Welcome to React')8})9"scripts": {10}11"devDependencies": {12}13"dependencies": {14}15"scripts": {16}17"scripts": {18}19"scripts": {20}21"scripts": {22}

Full Screen

Using AI Code Generation

copy

Full Screen

1describe('My First Test', function() {2 it('Does not do much!', function() {3 expect(true).to.equal(true)4 })5})6describe('My First Test', function() {7 it('Visits the Kitchen Sink', function() {8 })9})10describe('My First Test', function() {11 it('Visits the Kitchen Sink', function() {12 cy.contains('type').click()13 cy.url().should('include', '/commands/actions')14 cy.get('.action-email')15 .type('

Full Screen

Using AI Code Generation

copy

Full Screen

1describe('Smoke test', () => {2 it('should run a smoke test', () => {3 cy.smokeTest({4 });5 });6});7const { addMatchImageSnapshotPlugin } = require('cypress-image-snapshot/plugin');8module.exports = (on, config) => {9 addMatchImageSnapshotPlugin(on, config);10 require('cypress-smoke-test/plugin')(on);11};12import 'cypress-smoke-test/support';13Cypress.Commands.add('smokeTest', (options) => {14 const {15 } = options;16 if (smokeTest) {17 cy.visit(smokeTestUrl);18 cy.get(smokeTestSelector, { timeout: smokeTestTimeout });19 }20});21Cypress.Commands.add('smokeTest', (options) => {22 const {23 } = options;24 if (smokeTest) {25 cy.visit(smokeTestUrl);26 cy.get(smokeTestSelector, { timeout: smokeTestTimeout });27 }28});29Cypress.Commands.add('smokeTest', (options) => {30 const {31 } = options;32 if (smokeTest) {33 cy.visit(smokeTestUrl);34 cy.get(smokeTestSelector, { timeout: smokeTestTimeout });35 }36});37Cypress.Commands.add('smokeTest', (options) => {38 const {39 } = options;40 if (smokeTest) {41 cy.visit(smokeTestUrl);42 cy.get(smokeTestSelector, { timeout: smokeTestTimeout });43 }44});45Cypress.Commands.add('smokeTest', (options) => {46 const {47 } =

Full Screen

Using AI Code Generation

copy

Full Screen

1import smoke from '../support/smokeTest/smokeTest'2describe('First Test', function() {3 it('launches', function() {4 smoke.test()5 })6})7import smoke from '../support/smokeTest/smokeTest'8describe('First Test', function() {9 it('launches', function() {10 smoke.test()11 })12})13export default {14 test: () => {15 cy.get('input[name="q"]').type('Cypress')16 cy.get('input[name="btnK"]').click()17 cy.get('input[name="btnK"]').should('be.visible')18 }19}20Cypress.Commands.add('checkPageLoadTime', (url) => {21 cy.visit(url);22 cy.get('body').should('be.visible');23 cy.window().then((win) => {24 cy.log(`Page load time is ${win.performance.timing.loadEventEnd - win.performance.timing.navigationStart} milliseconds.`);25 });26});27it('should load the page in less than 2 seconds', () => {28 cy.checkPageLoadTime('/home');29});30Cypress.Commands.add('checkPageLoadTime', (url) => {31 cy.visit(url);32 cy.wait(5000);33 cy.get('body').should('be.visible');34 cy.window().then((win) => {35 cy.log(`Page load time is ${win.performance.timing.loadEventEnd - win.performance.timing.navigationStart} milliseconds.`);36 });37});

Full Screen

Cypress Tutorial

Cypress is a renowned Javascript-based open-source, easy-to-use end-to-end testing framework primarily used for testing web applications. Cypress is a relatively new player in the automation testing space and has been gaining much traction lately, as evidenced by the number of Forks (2.7K) and Stars (42.1K) for the project. LambdaTest’s Cypress Tutorial covers step-by-step guides that will help you learn from the basics till you run automation tests on LambdaTest.

Chapters:

  1. What is Cypress? -
  2. Why Cypress? - Learn why Cypress might be a good choice for testing your web applications.
  3. Features of Cypress Testing - Learn about features that make Cypress a powerful and flexible tool for testing web applications.
  4. Cypress Drawbacks - Although Cypress has many strengths, it has a few limitations that you should be aware of.
  5. Cypress Architecture - Learn more about Cypress architecture and how it is designed to be run directly in the browser, i.e., it does not have any additional servers.
  6. Browsers Supported by Cypress - Cypress is built on top of the Electron browser, supporting all modern web browsers. Learn browsers that support Cypress.
  7. Selenium vs Cypress: A Detailed Comparison - Compare and explore some key differences in terms of their design and features.
  8. Cypress Learning: Best Practices - Take a deep dive into some of the best practices you should use to avoid anti-patterns in your automation tests.
  9. How To Run Cypress Tests on LambdaTest? - Set up a LambdaTest account, and now you are all set to learn how to run Cypress tests.

Certification

You can elevate your expertise with end-to-end testing using the Cypress automation framework and stay one step ahead in your career by earning a Cypress certification. Check out our Cypress 101 Certification.

YouTube

Watch this 3 hours of complete tutorial to learn the basics of Cypress and various Cypress commands with the Cypress testing at LambdaTest.

Run Cypress 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