Best JavaScript code snippet using wpt
index.test.js
Source:index.test.js
1require('dotenv').config()2const firebase = require('@firebase/testing');3const MY_PROJECT_ID = process.env.REACT_APP_PROJECT_ID;4const adminAuth = { uid: 'adminID', email: 'admin@admin.co.uk', role: 'ADMIN' };5const physiotherpistAuth = { uid: 'physiotherapistID', email: 'physiotherpist@physiotherpist.co.uk', role: 'PHYSIOTHERAPIST' };6const patientAuth = { uid: 'patientID', email: 'patient@patient.co.uk', role: 'PATIENT' };7const mockPatient = { 8 userId: 'patientID',9 email: 'patient@patient.co.uk',10 name: 'Patient Name',11 physiotherapistsList: [],12 requestsList: [],13 dob: new Date('1/1/1999'),14 height: 180,15 weight: 6016}17const mockPhysiotherapist = {18 userId: 'physiotherapistID',19 email: 'physiotherapist@physiotherapist.co.uk',20 name: 'Physiotherapist Name',21 dob: new Date('1/1/1990'),22 height: 180,23 weight: 6024}25const mockSymptom = {26 bodyPart: {},27 creationDate: new Date(),28 feedbackList: [],29 painRangeValue: 0,30 rangeOfMotion: {},31 symptomDetails: 'Non-Empty-Details',32 symptomTitle: 'Non-Empty-Title'33}34const getFirestore = async (auth) => {35 return firebase36 .initializeTestApp({ projectId: MY_PROJECT_ID, auth: auth })37 .firestore();38}39function getAdminFirestore() {40 return firebase.initializeAdminApp({ projectId: MY_PROJECT_ID }).firestore();41}42describe('Physio At Home App - Access Level Testing', () => {43 // eslint-disable-next-line no-undef44 after(() => {45 Promise.all(firebase.apps().map(app => app.delete()))46 })47 beforeEach(async () => {48 await firebase.clearFirestoreData({ projectId: MY_PROJECT_ID });49 });50 afterEach(async () => {51 await firebase.clearFirestoreData({ projectId: MY_PROJECT_ID })52 })53 describe('Admin Tests', () => {54 // reading an admin is only possible if authed user is also admin55 it('should pass as Admins can read all items', async () => {56 const db = await getFirestore(adminAuth);57 const testAdminsDoc = db.collection('ADMINS').doc('adminID');58 await firebase.assertSucceeds(testAdminsDoc.get());59 })60 61 it('should pass as Admins can update Patients` name, dob, height, weight, requestsList, physiotherapistsList', async () => { // Not really62 const admin = getAdminFirestore();63 const setupDoc = admin.collection('PATIENTS').doc('patientID');64 await setupDoc.set(mockPatient);65 66 const db = await getFirestore(adminAuth);67 const testPatientsDoc = db.collection('PATIENTS').doc('patientID');68 await firebase.assertSucceeds(testPatientsDoc.update({ 69 name: 'Updated Patient Name',70 physiotherapistsList: ['UpdatedArrayValue'],71 requestsList: ['UpdatedArrayValue'],72 dob: new Date('1/1/2000'),73 height: 200,74 weight: 8075 }))76 })77 78 it('should fail as Admins can only update Patients` name, dob, height, weight, requestsList, physiotherapistsList', async () => { // Not really79 const admin = getAdminFirestore();80 const setupDoc = admin.collection('PATIENTS').doc('patientID');81 await setupDoc.set(mockPatient);82 83 const db = await getFirestore(adminAuth);84 const testPatientsDoc = db.collection('PATIENTS').doc('patientID');85 await firebase.assertFails(testPatientsDoc.update({ 86 userId: '',87 email: ''88 }))89 })90 91 it('should pass as Admins can update Physiotherapists` name, dob, height, weight', async () => {92 const admin = getAdminFirestore();93 const setupDoc = admin.collection('PHYSIOTHERAPISTS').doc('physiotherapistID');94 await setupDoc.set(mockPhysiotherapist);95 96 const db = await getFirestore(adminAuth);97 const testPhysiotherapistsDoc = db.collection('PHYSIOTHERAPISTS').doc('physiotherapistID');98 await firebase.assertSucceeds(testPhysiotherapistsDoc.update({ 99 name: 'Updated Patient Name',100 dob: new Date('1/1/2000'),101 height: 200,102 weight: 80103 }))104 })105 106 it('should fail as Admins can only update Physiotherapists` name, dob, height, weight', async () => {107 const admin = getAdminFirestore();108 const setupDoc = admin.collection('PHYSIOTHERAPISTS').doc('physiotherapistID');109 await setupDoc.set(mockPhysiotherapist);110 111 const db = await getFirestore(adminAuth);112 const testPhysiotherapistsDoc = db.collection('PHYSIOTHERAPISTS').doc('physiotherapistID');113 await firebase.assertFails(testPhysiotherapistsDoc.update({ 114 userId: '',115 email: ''116 }))117 })118 119 })120 describe('Physiotherapist Tests', () => {121 it('should pass as Physiotherapists can update feedbackList within Patients subcollection Symptoms', async () => {122 const admin = getAdminFirestore();123 const setupDoc = admin.collection('PATIENTS').doc('patientID');124 await setupDoc.set(mockPatient);125 await setupDoc.collection('SYMPTOMS').doc('symptomID').set(mockSymptom);126 const db = await getFirestore(physiotherpistAuth);127 const testSymptomDoc = db.collection('PATIENTS').doc('patientID').collection('SYMPTOMS').doc('symptomID');128 await firebase.assertSucceeds(testSymptomDoc.update({ 129 feedbackList: [{ dateCreated: new Date(), feedbackContent: '', physioID: physiotherpistAuth.uid, physioName: physiotherpistAuth.email }],130 }))131 })132 133 it('should fail as Physiotherapists can only update feedbackList within Patients subcollection Symptoms', async () => {134 const admin = getAdminFirestore();135 const setupDoc = admin.collection('PATIENTS').doc('patientID');136 await setupDoc.set(mockPatient);137 await setupDoc.collection('SYMPTOMS').doc('symptomID').set(mockSymptom);138 const db = await getFirestore(physiotherpistAuth);139 const testSymptomDoc = db.collection('PATIENTS').doc('patientID').collection('SYMPTOMS').doc('symptomID');140 await firebase.assertFails(testSymptomDoc.update({ painRangeValue: 100 }))141 await firebase.assertFails(testSymptomDoc.update({ bodyPart: 'updated' }))142 await firebase.assertFails(testSymptomDoc.update({ creationDate: new Date('1/1/2020') }))143 await firebase.assertFails(testSymptomDoc.update({ rangeOfMotion: 'updated' }))144 await firebase.assertFails(testSymptomDoc.update({ symptomDetails: 'updated' }))145 await firebase.assertFails(testSymptomDoc.update({ symptomTitle: 'updated' }))146 })147 it('should pass as Physiotherapists can only update Patients requestList and physiotherapistsList', async () => {148 const admin = getAdminFirestore();149 const setupDoc = admin.collection('PATIENTS').doc('patientID');150 await setupDoc.set(mockPatient);151 152 const db = await getFirestore(physiotherpistAuth);153 const testPatientsDoc = db.collection('PATIENTS').doc('patientID');154 await firebase.assertSucceeds(testPatientsDoc.update({ 155 physiotherapistsList: ['UpdatedArrayValue'],156 requestsList: ['UpdatedArrayValue']157 }))158 })159 160 it('should fail as Physiotherapists can only update Patients requestList and physiotherapistsList', async () => {161 162 const admin = getAdminFirestore();163 const setupDoc = admin.collection('PATIENTS').doc('patientID');164 await setupDoc.set(mockPatient);165 166 const db = await getFirestore(physiotherpistAuth);167 const testPatientsDoc = db.collection('PATIENTS').doc('patientID');168 await firebase.assertFails(testPatientsDoc.update({ 169 physiotherapistsList: ['UpdatedArrayValue'],170 requestsList: ['UpdatedArrayValue'],171 name: 'Updated Patient Name'172 }))173 })174 it('should fail as Physiotherapists cannot updated patients personal info within their Subcollection', async () => {175 const admin = getAdminFirestore();176 const setupDoc = admin.collection('PHYSIOTHERAPISTS').doc('physiotherapistID');177 await setupDoc.set(mockPhysiotherapist);178 await setupDoc.collection('PATIENTS').doc('patientID').set({ name: 'Patient Name', email: 'patient@patient.co.uk', photoURL: 'url', dob: new Date('1/1/1999'), height: 180, weight: 60 });179 const db = await getFirestore(physiotherpistAuth);180 const testPatientDoc = db.collection('PHYSIOTHERAPISTS').doc('physiotherapistID').collection('PATIENTS').doc('patientID');181 await firebase.assertFails(testPatientDoc.update({ 182 name: 'Updated Patient Name',183 email: 'updatedpatient@patient.co.uk',184 dob: new Date('1/1/2000'),185 height: 200,186 weight: 80187 }))188 })189 })190 describe('Patient Tests', () => {191 192 // reads can only be accomplish by same user, physiotherapists and admins193 it('should pass as Patients can update their own allowed info', async () => {194 const admin = getAdminFirestore();195 const setupDoc = admin.collection('PATIENTS').doc('patientID');196 await setupDoc.set(mockPatient);197 198 const db = await getFirestore(patientAuth);199 const testPatientsDoc = db.collection('PATIENTS').doc('patientID');200 await firebase.assertSucceeds(testPatientsDoc.update({201 name: 'Updated Patient Name',202 physiotherapistsList: ['UpdatedArrayValue'],203 requestsList: ['UpdatedArrayValue'],204 dob: new Date('1/1/2000'),205 height: 200,206 weight: 80207 }))208 })209 210 it('should fail as Patients cannot update their own id or email', async () => {211 const admin = getAdminFirestore();212 const setupDoc = admin.collection('PATIENTS').doc('patientID');213 await setupDoc.set(mockPatient);214 215 const db = await getFirestore(patientAuth);216 const testPatientsDoc = db.collection('PATIENTS').doc('patientID');217 await firebase.assertFails(testPatientsDoc.update({ userId: 'new' }))218 await firebase.assertFails(testPatientsDoc.update({ email: 'new email' }))219 })220 it('should fail as Patients cannot update other Patients info', async () => {221 const admin = getAdminFirestore();222 const setupDoc = admin.collection('PATIENTS').doc('other_patientID');223 await setupDoc.set(mockPatient);224 225 const db = await getFirestore(patientAuth);226 const testPatientsDoc = db.collection('PATIENTS').doc('other_patientID');227 await firebase.assertFails(testPatientsDoc.update({ 228 name: 'Updated Patient Name',229 physiotherapistsList: ['UpdatedArrayValue'],230 requestsList: ['UpdatedArrayValue'],231 dob: new Date('1/1/2000'),232 height: 200,233 weight: 80234 }))235 })236 it('should pass as Patients can update their info within Physiotherapy Subcollection', async () => {237 const admin = getAdminFirestore();238 const setupDoc = admin.collection('PHYSIOTHERAPISTS').doc('physiotherapistID');239 await setupDoc.set(mockPhysiotherapist);240 await setupDoc.collection('PATIENTS').doc('patientID').set({ name: 'Patient Name', email: 'patient@patient.co.uk', photoURL: 'url', dob: new Date('1/1/1999'), height: 180, weight: 60 });241 const db = await getFirestore(patientAuth);242 const testPatientDoc = db.collection('PHYSIOTHERAPISTS').doc('physiotherapistID').collection('PATIENTS').doc('patientID');243 await firebase.assertSucceeds(testPatientDoc.update({ 244 name: 'Updated Patient Name',245 email: 'updatedpatient@patient.co.uk',246 dob: new Date('1/1/2000'),247 height: 200,248 weight: 80249 }))250 })251 it('should fail as Patients cannot update other Patients info within Physiotherapy Subcollection', async () => {252 const admin = getAdminFirestore();253 const setupDoc = admin.collection('PHYSIOTHERAPISTS').doc('physiotherapistID');254 await setupDoc.set(mockPhysiotherapist);255 await setupDoc.collection('PATIENTS').doc('other_patientID').set({ name: 'Patient Name', email: 'patient@patient.co.uk', photoURL: 'url', dob: new Date('1/1/1999'), height: 180, weight: 60 });256 const db = await getFirestore(patientAuth);257 const testPatientDoc = db.collection('PHYSIOTHERAPISTS').doc('physiotherapistID').collection('PATIENTS').doc('other_patientID');258 await firebase.assertFails(testPatientDoc.update({ 259 name: 'Updated Patient Name',260 email: 'updatedpatient@patient.co.uk',261 dob: new Date('1/1/2000'),262 height: 200,263 weight: 80264 }))265 })266 it('should pass as Patients can delete themselves from within Physiotherapy Subcollection', async () => {267 const admin = getAdminFirestore();268 const setupDoc = admin.collection('PHYSIOTHERAPISTS').doc('physiotherapistID');269 await setupDoc.set(mockPhysiotherapist);270 await setupDoc.collection('PATIENTS').doc('patientID').set({ name: 'Patient Name', email: 'patient@patient.co.uk', photoURL: 'url', dob: new Date('1/1/1999'), height: 180, weight: 60 });271 const db = await getFirestore(patientAuth);272 const testPatientDoc = db.collection('PHYSIOTHERAPISTS').doc('physiotherapistID').collection('PATIENTS').doc('patientID');273 await firebase.assertSucceeds(testPatientDoc.delete())274 })275 it('should pass as Patients can add themselves into Physiotherapy Subcollection Invites when sending a request', async () => {276 const admin = getAdminFirestore();277 const setupPhysioDoc = admin.collection('PHYSIOTHERAPISTS').doc('physiotherapistID');278 await setupPhysioDoc.set(mockPhysiotherapist);279 const setupPatientDoc = admin.collection('PATIENTS').doc('patientID');280 await setupPatientDoc.set(mockPatient);281 const invitePath = '/PHYSIOTHERAPISTS/physiotherapistID/INVITES/patientID';282 const db = await getFirestore(patientAuth);283 const inviteDoc = db.doc(invitePath);284 await firebase.assertSucceeds(inviteDoc.set({ name: mockPatient.name, email: mockPatient.email, dob: mockPatient.dob, height: mockPatient.height, weight: mockPatient.weight }))285 })286 it('should fail as Patients cannot delete other patients from within Physiotherapy Subcollection', async () => {287 const admin = getAdminFirestore();288 const setupDoc = admin.collection('PHYSIOTHERAPISTS').doc('physiotherapistID');289 await setupDoc.set(mockPhysiotherapist);290 await setupDoc.collection('PATIENTS').doc('other_patientID').set({ name: 'Patient Name', email: 'patient@patient.co.uk', photoURL: 'url', dob: new Date('1/1/1999'), height: 180, weight: 60 });291 const db = await getFirestore(patientAuth);292 const testPatientDoc = db.collection('PHYSIOTHERAPISTS').doc('physiotherapistID').collection('PATIENTS').doc('other_patientID');293 await firebase.assertFails(testPatientDoc.delete())294 })295 it('should pass as Patients can upload symptoms', async () => {296 const admin = getAdminFirestore();297 const setupDoc = admin.collection('PATIENTS').doc('patientID');298 await setupDoc.set(mockPatient);299 const symptomPath = '/PATIENTS/patientID/SYMPTOMS/symptomID';300 const db = await getFirestore(patientAuth);301 const symptomDoc = db.doc(symptomPath);302 await firebase.assertSucceeds(symptomDoc.set(mockSymptom))303 })304 305 it('should fail as Patients can upload symptoms only on their behalves', async () => {306 const admin = getAdminFirestore();307 const setupDoc = admin.collection('PATIENTS').doc('other_patientID');308 await setupDoc.set(mockPatient);309 const symptomPath = '/PATIENTS/other_patientID/SYMPTOMS/symptomID';310 const db = await getFirestore(patientAuth);311 const symptomDoc = db.doc(symptomPath);312 await firebase.assertFails(symptomDoc.set(mockSymptom))313 })314 })...
docusaurus.config.js
Source:docusaurus.config.js
1// List of projects/orgs using your project for the users page.2const users = [3 {4 caption: "Docusaurus",5 image: "https://docusaurus.io/img/docusaurus.svg",6 infoLink: "https://docusaurus.io/",7 pinned: true,8 },9];10const setupDoc = "docs/basic/setup";11module.exports = {12 favicon: "img/icon.png",13 title: "React TypeScript Cheatsheets", // Title for your website.14 tagline:15 "Cheatsheets for experienced React developers getting started with TypeScript",16 url: "https://react-typescript-cheatsheet.netlify.app/", // Your website URL17 baseUrl: "/",18 projectName: "react-typescript-cheatsheet",19 organizationName: "typescript-cheatsheets",20 presets: [21 [22 "@docusaurus/preset-classic",23 {24 theme: {25 customCss: require.resolve("./src/css/custom.css"),26 },27 docs: {28 // Docs folder path relative to website dir.29 path: "../docs",30 // Sidebars file relative to website dir.31 sidebarPath: require.resolve("./sidebars.json"),32 },33 // ...34 },35 ],36 ],37 themeConfig: {38 colorMode: {39 defaultMode: "dark",40 },41 image:42 "https://user-images.githubusercontent.com/6764957/53868378-2b51fc80-3fb3-11e9-9cee-0277efe8a927.png",43 // Equivalent to `docsSideNavCollapsible`.44 // sidebarCollapsible: false,45 prism: {46 defaultLanguage: "typescript",47 },48 navbar: {49 title: "React TypeScript Cheatsheet",50 logo: {51 alt: "Logo",52 src: "img/icon.png",53 },54 items: [55 {56 to: setupDoc,57 label: "Docs",58 position: "right",59 },60 {61 to: "help",62 label: "Help",63 position: "right",64 },65 {66 to: "https://discord.gg/wTGS5z9",67 label: "Discord",68 position: "right",69 },70 // {to: 'blog', label: 'Blog', position: 'right'},71 ],72 },73 footer: {74 style: "dark",75 logo: {76 alt: "TypeScript Cheatsheets Logo",77 src: "img/icon.png",78 // maxWidth: 128,79 // style: { maxWidth: 128, maxHeight: 128 },80 },81 copyright: `Copyright © ${new Date().getFullYear()} TypeScript Cheatsheets`,82 links: [83 {84 title: "Docs",85 items: [86 {87 label: "Introduction",88 to: setupDoc,89 },90 {91 label: "High Order Component (HOC)",92 to: "docs/hoc/intro",93 },94 {95 label: "Advanced Guides",96 to: "docs/advanced/intro",97 },98 {99 label: "Migrating",100 to: "docs/migration/intro",101 },102 ],103 },104 {105 title: "Community",106 items: [107 {108 label: "Stack Overflow",109 href: "https://stackoverflow.com/questions/tagged/typescript",110 },111 {112 label: "User Showcase",113 to: "users",114 },115 {116 label: "Help",117 to: "help",118 },119 ],120 },121 {122 title: "More",123 items: [124 {125 label: "GitHub",126 href:127 "https://github.com/typescript-cheatsheets/react-typescript-cheatsheet",128 },129 {130 html: `<a class="footer__link-item" href="https://github.com/typescript-cheatsheets/react-typescript-cheatsheet">131 <img src="https://camo.githubusercontent.com/f00e074779455222f68fde1096fbbd91bae555c2/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f73746172732f747970657363726970742d63686561747368656574732f72656163742d747970657363726970742d636865617473686565742e7376673f7374796c653d736f6369616c266c6162656c3d53746172266d61784167653d32353932303030" alt="GitHub stars" data-canonical-src="https://img.shields.io/github/stars/typescript-cheatsheets/react-typescript-cheatsheet.svg?style=social&label=Star&maxAge=2592000" style="max-width:100%;">132 </a>`,133 },134 {135 // label: "Discord",136 html: `<a class="footer__link-item" href="https://discord.gg/wTGS5z9">137 <img src="https://img.shields.io/discord/508357248330760243.svg?label=&logo=discord&logoColor=ffffff&color=7389D8&labelColor=6A7EC2" style="max-width:100%;">138 </a>`,139 },140 {141 // label: "Spread the word",142 html: `<a class="footer__link-item" href="http://twitter.com/home?status=Awesome%20%40Reactjs%20%2B%20%40TypeScript%20cheatsheet%20by%20%40ferdaber%2C%20%40sebsilbermann%2C%20%40swyx%20%26%20others!%20https%3A%2F%2Fgithub.com%2Ftypescript-cheatsheets%2Freact">143 <img src="https://img.shields.io/twitter/url?label=Help%20spread%20the%20word%21&style=social&url=https%3A%2F%2Fgithub.com%2Ftypescript-cheatsheets%2Freact" style="max-width:100%;">144 </a>`,145 },146 ],147 },148 ],149 },150 algolia: {151 apiKey: "e1c87cdc9c52f8ccf84ceb7f9e18bcd3",152 indexName: "react-typescript-cheatsheet",153 // appId: "",154 algoliaOptions: {155 //... },156 },157 },158 },159 customFields: {160 firstDoc: setupDoc,161 // TODO useless user showcase page ?162 users,163 addUserUrl:164 "https://github.com/typescript-cheatsheets/react-typescript-cheatsheet/blob/master/website/docusaurus.config.js",165 },...
server.js
Source:server.js
1var request = require("./json-client"),2 httpProxy = require('http-proxy');3var syncGatewayInfo = {4 host: 'localhost',5 port: 4984,6 admin: 4985,7 dbname: "listream"8 };9syncGatewayInfo.url ='http://'+syncGatewayInfo.host+":"+syncGatewayInfo.port;10var adminURL ='http://'+syncGatewayInfo.host+":"+syncGatewayInfo.admin;11httpProxy.createServer(function (req, res, proxy) {12 //13 // Create a proxy server and add a login handler14 //15 if (/_access_token\/.*/.test(req.url)) {16 console.log("token",req.method, req.url, req.headers)17 handleAccessToken(req.url.split('/').pop(), function(err, userID, session){18 if (err) {19 console.log("error", err)20 res.writeHead(500, {'Content-Type': 'application/json'});21 res.end(JSON.stringify(err));22 } else {23 console.log("session info", session)24 res.writeHead(200, {25 'Content-Type': 'application/json',26 "Set-Cookie" : session.cookie_name+"="+session.session_id+"; Path=/; Expires="+(new Date(session.expires)).toUTCString()27 });28 res.end(JSON.stringify({userID: userID}));29 }30 })31 } else {32 console.log("proxy",req.method, req.url, req.headers)33 proxy.proxyRequest(req, res, syncGatewayInfo);34 }35}).listen(8080);36function handleAccessToken(accessToken, done) {37 console.log("handleAccessToken", accessToken);38 var linkedInUserProfileUrl = "https://api.linkedin.com/v1/people/~:(id,email-address)?format=json&oauth2_access_token="+accessToken;39 request.get(linkedInUserProfileUrl, function(err, res, userData){40 if (err) {return done(err)}41 var userID = userData.id;42 console.log("got userID", userID)43 getSessionForUser(userID, function(err, session) {44 if (err) {return done(err)}45 doApplicationSetup(userID, accessToken, function(err){46 if (err) {return done(err)}47 done(false, userID, session);48 })49 });50 })51}52// APPLICTION logic53// create profile doc that can kick off contacts bot54function doApplicationSetup(userID, accessToken, done){55 var userSetupDocURL = adminURL+"/"+syncGatewayInfo.dbname+"/u:" + userID;56 request.get(userSetupDocURL, function(err, res, setupDoc) {57 // console.log("get doc", err, res.statusCode, setupDoc._id)58 if (err == 404) {59 var newSetupDoc = {60 type : "user",61 state : "new",62 accessToken : accessToken63 };64 request.put(userSetupDocURL, {json:newSetupDoc}, done);65 } else if (err) {66 done(err)67 } else {68 // console.log("existing setupDoc", setupDoc);69 if (setupDoc.accessToken !== accessToken) {70 setupDoc.accessToken = accessToken;71 request.put(userSetupDocURL, {json:setupDoc}, done);72 } else {73 done()74 }75 }76 })77}78function getSessionForUser(userID, done) {79 ensureUserDocExists(userID, function(err) {80 if (err) {return done(err)}81 request.post(adminURL+"/"+syncGatewayInfo.dbname+"/_session", {json:{name : userID}}, function(err, res, body){82 // console.log("session", err, res.statusCode, body)83 if (err) {return done(err)}84 done(false, body)85 })86 });87}88function ensureUserDocExists(userID, done) {89 var userDocURL = adminURL+"/"+syncGatewayInfo.dbname+"/_user/" + userID;90 request.get(userDocURL, function(err, res) {91 // console.log("userDocURL", err, res.statusCode, userDocURL)92 if (err == 404) {93 // create a user doc94 request.put(userDocURL, {json:{email: userID, password : Math.random().toString(36).substr(2)}}, function(err, res, body){95 // console.log("put userDocURL", err, res.statusCode, body)96 done(err)97 })98 } else {99 done(err)100 }101 })...
Using AI Code Generation
1setup({ explicit_done: true });2setup({ explicit_done: true, explicit_timeout: true });3test(function() {4 assert_true(true, "true is true");5 done();6}, "true is true");7promise_test(function() {8 return new Promise(function(resolve, reject) {9 resolve();10 });11}, "true is true");12async_test(function(t) {13 t.step(function() {14 assert_true(true, "true is true");15 });16 t.done();17}, "true is true");18promise_rejects(new TypeError(), new Promise(function(resolve, reject) {19 reject(new TypeError());20}), "true is true");21promise_rejects(new TypeError(), new Promise(function(resolve, reject) {22 reject(new TypeError());23}), "true is true");24promise_rejects(new TypeError(), new Promise(function(resolve, reject) {25 reject(new TypeError());26}), "true is true");27promise_rejects(new TypeError(), new Promise(function(resolve, reject) {28 reject(new TypeError());29}), "true is true");30promise_rejects(new TypeError(), new Promise(function(resolve, reject) {31 reject(new TypeError());32}), "true is true");33promise_rejects(new TypeError(), new Promise(function(resolve, reject) {34 reject(new TypeError());35}), "true is true");36promise_rejects(new TypeError(), new Promise(function(resolve, reject) {37 reject(new TypeError());38}), "true is true");39promise_rejects(new TypeError(), new Promise(function(resolve, reject) {40 reject(new TypeError());41}), "true is true");42promise_rejects(new TypeError(), new Promise(function(resolve, reject) {43 reject(new TypeError());44}), "true is true");
Using AI Code Generation
1setupDoc(doc);2var iframe = doc.getElementById('iframe');3var iframeDoc = iframe.contentDocument;4setupDoc(iframeDoc);5setupDoc(doc);6var iframe = doc.getElementById('iframe');7var iframeDoc = iframe.contentDocument;8setupDoc(iframeDoc);9setupDoc(doc);10var iframe = doc.getElementById('iframe');11var iframeDoc = iframe.contentDocument;12setupDoc(iframeDoc);13setupDoc(doc);14var iframe = doc.getElementById('iframe');15var iframeDoc = iframe.contentDocument;16setupDoc(iframeDoc);17setupDoc(doc);18var iframe = doc.getElementById('iframe');19var iframeDoc = iframe.contentDocument;20setupDoc(iframeDoc);21setupDoc(doc);22var iframe = doc.getElementById('iframe');23var iframeDoc = iframe.contentDocument;24setupDoc(iframeDoc);25setupDoc(doc);26var iframe = doc.getElementById('iframe');27var iframeDoc = iframe.contentDocument;28setupDoc(iframeDoc);29setupDoc(doc);30var iframe = doc.getElementById('iframe');31var iframeDoc = iframe.contentDocument;32setupDoc(iframeDoc);33setupDoc(doc);34var iframe = doc.getElementById('iframe');35var iframeDoc = iframe.contentDocument;36setupDoc(iframeDoc);37setupDoc(doc);38var iframe = doc.getElementById('iframe');39var iframeDoc = iframe.contentDocument;40setupDoc(iframeDoc);41setupDoc(doc);42var iframe = doc.getElementById('iframe');
Using AI Code Generation
1setupDoc("test");2setup({explicit_done: true});3test(function() {4 assert_equals(document.title, "test");5 done();6}, "test title");7var t = async_test("test async");8promise_test(function() {9 return new Promise(function(resolve, reject) {
Using AI Code Generation
1const wpt = require('wpt');2const wptClient = new wpt('your-api-key');3 if (error) {4 console.log(error);5 } else {6 console.log(data);7 }8});9const wpt = require('wpt');10const wptClient = new wpt('your-api-key');11 if (error) {12 console.log(error);13 } else {14 console.log(data);15 }16});17const wpt = require('wpt');18const wptClient = new wpt('your-api-key');19 if (error) {20 console.log(error);21 } else {22 console.log(data);23 }24});25const wpt = require('wpt');26const wptClient = new wpt('your-api-key');27 if (error) {28 console.log(error);29 } else {30 console.log(data);31 }32});33const wpt = require('wpt');34const wptClient = new wpt('your-api-key');35 if (error) {36 console.log(error);37 } else {38 console.log(data);39 }40});41const wpt = require('wpt');42const wptClient = new wpt('your-api-key');43 if (error) {44 console.log(error);45 } else {46 console.log(data);47 }48});
Using AI Code Generation
1setup({explicit_done:true});2setup({explicit_timeout:true});3done();4step_timeout(function() { console.log("timeout"); }, 1000);5step(function() { console.log("step"); });6step_func(function() { console.log("step_func"); });7step_func_done(function() { console.log("step_func_done"); });8async_test(function(t) { console.log("async_test"); });9promise_test(function(t) { console.log("promise_test"); });10promise_rejects(function(t) { console.log("promise_rejects"); });11promise_rejects_js(function(t) { console.log("promise_rejects_js"); });12promise_rejects_dom(function(t) { console.log("promise_rejects_dom"); });13promise_rejects_exactly(function(t) { console.log("promise_rejects_exactly"); });14promise_rejects_unreached(function(t) { console.log("promise_rejects_unreached"); });15promise_rejects_not_reached(function(t) { console.log("promise_rejects_not_reached"); });16promise_rejects_reached(function(t) { console.log("promise_rejects_reached"); });17promise_rejects_reached(function(t) { console.log("promise_rejects_reached"); });18promise_rejects_reached(function(t) { console.log("promise_rejects
Using AI Code Generation
1function setupDoc() {2}3function setupDoc() {4}5function setupDoc() {6}7function setupDoc() {8}9function setupDoc() {10}11function setupDoc() {12}13function setupDoc() {14}15function setupDoc() {16}17function setupDoc() {18}19function setupDoc() {20}21function setupDoc() {22}23function setupDoc() {24}25function setupDoc() {
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!