How to use createInstance method in Playwright Internal

Best JavaScript code snippet using playwright-internal

runtime.js

Source:runtime.js Github

copy

Full Screen

...83 }84 )85 bootstrap('@weex-component/main')86 `87 framework.createInstance(instanceId, code)88 expect(callNativeSpy.callCount).to.be.equal(2)89 expect(callAddElementSpy.callCount).to.be.equal(1)90 expect(callNativeSpy.firstCall.args[0]).to.be.equal(instanceId)91 expect(callNativeSpy.firstCall.args[1]).to.deep.equal([{92 module: 'dom',93 method: 'createBody',94 args: [{95 ref: '_root',96 type: 'container',97 attr: {},98 style: {}99 }]100 }])101 // expect(callNativeSpy.firstCall.args[2]).to.not.equal('-1')102 expect(callAddElementSpy.firstCall.args[0]).to.be.equal(instanceId)103 delete callAddElementSpy.firstCall.args[1].ref104 expect(callAddElementSpy.firstCall.args[1]).to.deep.equal({105 type: 'text',106 attr: { value: 'Hello World' },107 style: {}108 })109 // expect(callNativeSpy.secondCall.args[2]).to.not.equal('-1')110 expect(callNativeSpy.secondCall.args[0]).to.be.equal(instanceId)111 expect(callNativeSpy.secondCall.args[1]).to.deep.equal([{112 module: 'dom',113 method: 'createFinish',114 args: []115 }])116 // expect(callNativeSpy.thirdCall.args[2]).to.not.equal('-1')117 })118 it('with a exist instanceId', () => {119 const code = ''120 const result = framework.createInstance(instanceId, code)121 expect(result).to.be.an.instanceof(Error)122 })123 it('js bundle format version checker', function () {124 const weexFramework = frameworks.Weex125 frameworks.Weex = {126 init: function () {},127 createInstance: sinon.spy()128 }129 frameworks.xxx = {130 init: function () {},131 createInstance: sinon.spy()132 }133 frameworks.yyy = {134 init: function () {},135 createInstance: sinon.spy()136 }137 // test framework xxx138 let code = `// {"framework":"xxx","version":"0.3.1"}139 'This is a piece of JavaScript from a third-party Framework...'`140 framework.createInstance(instanceId + '~', code)141 expect(frameworks.xxx.createInstance.callCount).equal(1)142 expect(frameworks.yyy.createInstance.callCount).equal(0)143 expect(frameworks.Weex.createInstance.callCount).equal(0)144 expect(frameworks.xxx.createInstance.firstCall.args).eql([145 instanceId + '~',146 code,147 { bundleVersion: '0.3.1' },148 undefined149 ])150 // also support spaces in JSON string151 // also ignore spaces between double-slash and JSON string152 code = `//{ "framework":"xxx" }153 'This is a piece of JavaScript from a third-party Framework...'`154 framework.createInstance(instanceId + '~~', code)155 expect(frameworks.xxx.createInstance.callCount).equal(2)156 expect(frameworks.yyy.createInstance.callCount).equal(0)157 expect(frameworks.Weex.createInstance.callCount).equal(0)158 // also support non-strict JSON format159 code = `// {framework:"xxx",'version':"0.3.1"}160 'This is a piece of JavaScript from a third-party Framework...'`161 framework.createInstance(instanceId + '~~~', code)162 expect(frameworks.xxx.createInstance.callCount).equal(2)163 expect(frameworks.yyy.createInstance.callCount).equal(0)164 expect(frameworks.Weex.createInstance.callCount).equal(1)165 expect(frameworks.Weex.createInstance.firstCall.args).eql([166 instanceId + '~~~',167 code,168 { bundleVersion: undefined },169 undefined170 ])171 // test framework yyy172 /* eslint-disable */173 code = `174 // {"framework":"yyy"}175'JS Bundle with space and empty lines behind'` // modified from real generated code from tb176 /* eslint-enable */177 framework.createInstance(instanceId + '~~~~', code)178 expect(frameworks.xxx.createInstance.callCount).equal(2)179 expect(frameworks.yyy.createInstance.callCount).equal(1)180 expect(frameworks.Weex.createInstance.callCount).equal(1)181 expect(frameworks.yyy.createInstance.firstCall.args).eql([182 instanceId + '~~~~',183 code,184 { bundleVersion: undefined },185 undefined186 ])187 // test framework Weex (wrong format at the middle)188 code = `'Some JS bundle code here ... // {"framework":"xxx"}\n ... end.'`189 framework.createInstance(instanceId + '~~~~~', code)190 expect(frameworks.xxx.createInstance.callCount).equal(2)191 expect(frameworks.yyy.createInstance.callCount).equal(1)192 expect(frameworks.Weex.createInstance.callCount).equal(2)193 expect(frameworks.Weex.createInstance.secondCall.args).eql([194 instanceId + '~~~~~',195 code,196 { bundleVersion: undefined },197 undefined198 ])199 // test framework Weex (without any JSON string in comment)200 code = `'Some JS bundle code here'`201 framework.createInstance(instanceId + '~~~~~~', code)202 expect(frameworks.xxx.createInstance.callCount).equal(2)203 expect(frameworks.yyy.createInstance.callCount).equal(1)204 expect(frameworks.Weex.createInstance.callCount).equal(3)205 expect(frameworks.Weex.createInstance.thirdCall.args).eql([206 instanceId + '~~~~~~',207 code,208 { bundleVersion: undefined },209 undefined210 ])211 // revert frameworks212 delete frameworks.xxx213 delete frameworks.yyy214 frameworks.Weex = weexFramework215 })...

Full Screen

Full Screen

constructor.spec.js

Source:constructor.spec.js Github

copy

Full Screen

...35 }36 });37 38 it('should throw if no issuer is provided', () => {39 function createInstance() {40 new ExpressOIDC({41 ...minimumConfig, 42 issuer: undefined 43 });44 }45 const errorMsg = `Your Okta URL is missing. ${findDomainMessage}`;46 expect(createInstance).toThrow(errorMsg);47 });48 it('should throw if an issuer that does not contain https is provided', () => {49 function createInstance() {50 new ExpressOIDC({51 ...minimumConfig, 52 issuer: 'http://foo' 53 });54 }55 const errorMsg = `Your Okta URL must start with https. Current value: http://foo. ${findDomainMessage}`;56 expect(createInstance).toThrow(errorMsg);57 });58 it('should not throw if https issuer validation is skipped', done => {59 jest.spyOn(console, 'warn').mockImplementation(() => {}); // silence for testing60 mockWellKnown('http://foo');61 new ExpressOIDC({62 ...minimumConfig,63 issuer: 'http://foo',64 testing: {65 disableHttpsCheck: true66 }67 })68 .on('error', () => {69 expect(false).toBe(true);70 })71 .on('ready', () => {72 expect(console.warn).toBeCalledWith('Warning: HTTPS check is disabled. This allows for insecure configurations and is NOT recommended for production use.');73 done();74 });75 });76 it('should throw if an issuer matching {yourOktaDomain} is provided', () => {77 function createInstance() {78 new ExpressOIDC({79 ...minimumConfig,80 issuer: 'https://{yourOktaDomain}'81 });82 }83 const errorMsg = `Replace {yourOktaDomain} with your Okta domain. ${findDomainMessage}`;84 expect(createInstance).toThrow(errorMsg);85 });86 it('should throw if an issuer matching -admin.okta.com is provided', () => {87 function createInstance() {88 new ExpressOIDC({89 ...minimumConfig,90 issuer: 'https://foo-admin.okta.com'91 });92 }93 const errorMsg = 'Your Okta domain should not contain -admin. Current value: ' +94 `https://foo-admin.okta.com. ${findDomainMessage}`;95 expect(createInstance).toThrow(errorMsg);96 });97 it('should throw if an issuer matching -admin.oktapreview.com is provided', () => {98 function createInstance() {99 new ExpressOIDC({100 ...minimumConfig,101 issuer: 'https://foo-admin.oktapreview.com'102 });103 }104 const errorMsg = 'Your Okta domain should not contain -admin. Current value: ' +105 `https://foo-admin.oktapreview.com. ${findDomainMessage}`;106 expect(createInstance).toThrow(errorMsg);107 });108 it('should throw if an issuer matching -admin.okta-emea.com is provided', () => {109 function createInstance() {110 new ExpressOIDC({111 ...minimumConfig,112 issuer: 'https://foo-admin.okta-emea.com'113 });114 }115 const errorMsg = 'Your Okta domain should not contain -admin. Current value: ' +116 `https://foo-admin.okta-emea.com. ${findDomainMessage}`;117 expect(createInstance).toThrow(errorMsg);118 });119 it('should throw if the client_id is not provided', () => {120 function createInstance() {121 new ExpressOIDC({122 ...minimumConfig,123 client_id: undefined124 });125 }126 const errorMsg = `Your client ID is missing. ${findCredentialsMessage}`;127 expect(createInstance).toThrow(errorMsg);128 });129 it('should throw if the client_secret is not provided', () => {130 function createInstance() {131 new ExpressOIDC({132 ...minimumConfig,133 client_secret: undefined134 });135 }136 const errorMsg = `Your client secret is missing. ${findCredentialsMessage}`;137 expect(createInstance).toThrow(errorMsg);138 });139 it('should throw if a client_id matching {clientId} is provided', () => {140 function createInstance() {141 new ExpressOIDC({142 ...minimumConfig,143 client_id: '{clientId}'144 });145 }146 const errorMsg = `Replace {clientId} with the client ID of your Application. ${findCredentialsMessage}`;147 expect(createInstance).toThrow(errorMsg);148 });149 it('should throw if a client_secret matching {clientSecret} is provided', () => {150 function createInstance() {151 new ExpressOIDC({152 ...minimumConfig,153 client_secret: '{clientSecret}',154 });155 }156 const errorMsg = `Replace {clientSecret} with the client secret of your Application. ${findCredentialsMessage}`;157 expect(createInstance).toThrow(errorMsg);158 });159 it('should throw if the appBaseUrl is not provided', () => {160 function createInstance() {161 new ExpressOIDC({162 ...minimumConfig,163 appBaseUrl: undefined164 });165 }166 const errorMsg = 'Your appBaseUrl is missing.';167 expect(createInstance).toThrow(errorMsg);168 });169 it('should throw if a appBaseUrl matching {appBaseUrl} is provided', () => {170 function createInstance() {171 new ExpressOIDC({172 ...minimumConfig,173 appBaseUrl: '{appBaseUrl}'174 });175 }176 const errorMsg = 'Replace {appBaseUrl} with the base URL of your Application.'177 expect(createInstance).toThrow(errorMsg);178 });179 it('should throw if an appBaseUrl without a protocol is provided', () => {180 function createInstance() {181 new ExpressOIDC({182 ...minimumConfig,183 appBaseUrl: 'foo.example.com'184 });185 }186 const errorMsg = 'Your appBaseUrl must contain a protocol (e.g. https://). Current value: foo.example.com.';187 expect(createInstance).toThrow(errorMsg);188 });189 it('should throw if an appBaseUrl ending in a slash is provided', () => {190 function createInstance() {191 new ExpressOIDC({192 ...minimumConfig,193 appBaseUrl: 'https://foo.example.com/'194 });195 }196 const errorMsg = `Your appBaseUrl must not end in a '/'. Current value: https://foo.example.com/.`;197 expect(createInstance).toThrow(errorMsg);198 });199 it('should set the HTTP timeout to 10 seconds', done => {200 mockWellKnown();201 new ExpressOIDC({202 ...minimumConfig203 })204 .on('ready', () => {...

Full Screen

Full Screen

Validator.test.js

Source:Validator.test.js Github

copy

Full Screen

1"use strict";2Object.defineProperty(exports, "__esModule", { value: true });3var Validator_1 = require("./Validator");4function createInstance(options) {5 return new Validator_1.default(options);6}7test("tests output of Validator.checkAmount()", function () {8 var validator = createInstance({ amount: {} });9 expect(function () {10 validator.checkAmount();11 }).toThrow(TypeError);12 validator = createInstance({ amount: true });13 expect(function () {14 validator.checkAmount();15 }).toThrow(TypeError);16 validator = createInstance({ amount: "" });17 expect(function () {18 validator.checkAmount();19 }).toThrow(TypeError);20 validator = createInstance({ amount: 0 });21 expect(function () {22 validator.checkAmount();23 }).toThrow(TypeError);24 validator = createInstance({ amount: 51 });25 expect(function () {26 validator.checkAmount();27 }).toThrow(TypeError);28 validator = createInstance({ amount: 25 });29 expect(validator.checkAmount()).toEqual(25);30 validator = createInstance({ amount: "25" });31 expect(validator.checkAmount()).toEqual(25);32 validator = createInstance({ amount: undefined });33 expect(validator.checkAmount()).toEqual(null);34 validator = createInstance({ amount: null });35 expect(validator.checkAmount()).toEqual(null);36});37test("tests output of Validator.checkCategory()", function () {38 var validator = createInstance({ category: {} });39 expect(function () {40 validator.checkCategory();41 }).toThrow(TypeError);42 validator = createInstance({ category: true });43 expect(function () {44 validator.checkCategory();45 }).toThrow(TypeError);46 validator = createInstance({ category: "..." });47 expect(function () {48 validator.checkCategory();49 }).toThrow(TypeError);50 validator = createInstance({ category: 8 });51 expect(function () {52 validator.checkCategory();53 }).toThrow(TypeError);54 validator = createInstance({ category: 33 });55 expect(function () {56 validator.checkCategory();57 }).toThrow(TypeError);58 validator = createInstance({ category: 25 });59 expect(validator.checkCategory()).toEqual(25);60 validator = createInstance({ category: "25" });61 expect(validator.checkCategory()).toEqual(25);62 validator = createInstance({ category: "GENERAL_KNOWLEDGE" });63 expect(validator.checkCategory()).toEqual(9);64 validator = createInstance({65 category: "ENTERTAINMENT_CARTOON_AND_ANIMATIONS",66 });67 expect(validator.checkCategory()).toEqual(32);68 validator = createInstance({ category: "General Knowledge" });69 expect(validator.checkCategory()).toEqual(9);70 validator = createInstance({71 category: "Entertainment: Cartoon and Animations",72 });73 expect(validator.checkCategory()).toEqual(32);74 validator = createInstance({ category: undefined });75 expect(validator.checkCategory()).toEqual(null);76 validator = createInstance({ category: null });77 expect(validator.checkCategory()).toEqual(null);78});79test("tests output of Validator.checkDifficulty()", function () {80 var validator = createInstance({81 difficulty: {},82 });83 expect(function () {84 validator.checkDifficulty();85 }).toThrow(TypeError);86 validator = createInstance({87 difficulty: true,88 });89 expect(function () {90 validator.checkDifficulty();91 }).toThrow(TypeError);92 validator = createInstance({ difficulty: "..." });93 expect(function () {94 validator.checkDifficulty();95 }).toThrow(TypeError);96 validator = createInstance({97 difficulty: 1,98 });99 expect(function () {100 validator.checkDifficulty();101 }).toThrow(TypeError);102 validator = createInstance({103 difficulty: "1",104 });105 expect(function () {106 validator.checkDifficulty();107 }).toThrow(TypeError);108 validator = createInstance({ difficulty: "easy" });109 expect(validator.checkDifficulty()).toEqual("easy");110 validator = createInstance({ difficulty: undefined });111 expect(validator.checkDifficulty()).toEqual(null);112 validator = createInstance({ difficulty: null });113 expect(validator.checkDifficulty()).toEqual(null);114});115test("tests output of Validator.checkEncoding()", function () {116 var validator = createInstance({117 encode: {},118 });119 expect(function () {120 validator.checkEncode();121 }).toThrow(TypeError);122 validator = createInstance({123 encode: true,124 });125 expect(function () {126 validator.checkEncode();127 }).toThrow(TypeError);128 validator = createInstance({ encode: "..." });129 expect(function () {130 validator.checkEncode();131 }).toThrow(TypeError);132 validator = createInstance({133 encode: 1,134 });135 expect(function () {136 validator.checkEncode();137 }).toThrow(TypeError);138 validator = createInstance({139 encode: "1",140 });141 expect(function () {142 validator.checkEncode();143 }).toThrow(TypeError);144 validator = createInstance({ encode: "base64" });145 expect(validator.checkEncode()).toEqual("base64");146 validator = createInstance({ encode: undefined });147 expect(validator.checkEncode()).toEqual(null);148 validator = createInstance({ encode: null });149 expect(validator.checkEncode()).toEqual(null);150});151test("tests output of Validator.checkToken()", function () {152 var validator = createInstance({153 session: {},154 });155 expect(function () {156 validator.checkToken();157 }).toThrow(TypeError);158 validator = createInstance({159 session: true,160 });161 expect(function () {162 validator.checkToken();163 }).toThrow(TypeError);164 validator = createInstance({ session: "" });165 expect(function () {166 validator.checkToken();167 }).toThrow(TypeError);168 validator = createInstance({169 session: 1,170 });171 expect(function () {172 validator.checkToken();173 }).toThrow(TypeError);174 validator = createInstance({ session: "..." });175 expect(validator.checkToken()).toEqual("...");176 validator = createInstance({ session: undefined });177 expect(validator.checkToken()).toEqual(null);178 validator = createInstance({ session: null });179 expect(validator.checkToken()).toEqual(null);180});181test("tests output of Validator.checkType()", function () {182 var validator = createInstance({183 type: {},184 });185 expect(function () {186 validator.checkType();187 }).toThrow(TypeError);188 validator = createInstance({189 type: true,190 });191 expect(function () {192 validator.checkType();193 }).toThrow(TypeError);194 validator = createInstance({ type: "..." });195 expect(function () {196 validator.checkType();197 }).toThrow(TypeError);198 validator = createInstance({199 type: 1,200 });201 expect(function () {202 validator.checkType();203 }).toThrow(TypeError);204 validator = createInstance({ type: "boolean" });205 expect(validator.checkType()).toEqual("boolean");206 validator = createInstance({ type: undefined });207 expect(validator.checkType()).toEqual(null);208 validator = createInstance({ type: null });209 expect(validator.checkType()).toEqual(null);...

Full Screen

Full Screen

test-basics.js

Source:test-basics.js Github

copy

Full Screen

...28});29describe('Slam Test Suite -Run', function() {30 it('Test creating slam object using Promise', function() {31 return new Promise((resolve, reject) => {32 let promise = addon.createInstance();33 assert.equal(typeof promise, 'object');34 assert(promise instanceof Promise);35 promise.then((instance) => {36 assert.equal(typeof instance, 'object');37 assert(instance instanceof addon.Instance);38 resolve();39 }).catch((e) => {40 reject(e);41 });42 });43 });44 it('Make sure properties are all there', function() {45 return new Promise((resolve, reject) => {46 addon.createInstance().then((instance) => {47 assert(instance.hasOwnProperty('state'));48 assert.equal(Object.getOwnPropertyDescriptor(instance, 'state').writable, false);49 resolve();50 });51 });52 });53 it('Make sure methods are all there', function(done) {54 let Instance = addon.Instance;55 [56 'getCameraOptions', 'getInstanceOptions', 'setCameraOptions', 'setInstanceOptions',57 'start', 'stop', 'getTrackingResult', 'getOccupancyMap', 'getRelocalizationPose',58 'getOccupancyMapUpdate', 'getOccupancyMapBounds', 'loadOccupancyMap', 'saveOccupancyMap',59 'saveOccupancyMapAsPpm', 'loadRelocalizationMap', 'saveRelocalizationMap',60 // not support yet61 // 'resetConfig', 'restart',62 ].forEach((methodName) => {63 assert.equal(typeof Instance.prototype[methodName], 'function');64 });65 done();66 });67 it('createInstance() should resolve when providing 1 valid but empty argument', function() {68 return new Promise((resolve, reject) => {69 addon.createInstance({}).then((i) => {70 resolve('success');71 }).catch((e) => {72 reject('should not fail but promise got rejected');73 });74 });75 });76 it('createInstance() should resolve when providing 2 valid but empty arguments (1)', function() {77 return new Promise((resolve, reject) => {78 addon.createInstance({}, {}).then((i) => {79 resolve('success');80 }).catch((e) => {81 reject('should not fail but promise got rejected');82 });83 });84 });85 it('createInstance() should resolve when providing 2 valid but empty arguments (2)', function() {86 return new Promise((resolve, reject) => {87 addon.createInstance(undefined, {}).then((i) => {88 resolve('success');89 }).catch((e) => {90 reject('should not fail but promise got rejected');91 });92 });93 });94 it('createInstance() should resolve when providing 2 valid but empty arguments (3)', function() {95 return new Promise((resolve, reject) => {96 addon.createInstance(undefined, undefined).then((i) => {97 resolve('success');98 }).catch((e) => {99 reject('should not fail but promise got rejected');100 });101 });102 });103 it('createInstance() should resolve when providing 2 valid but empty arguments (4)', function() {104 return new Promise((resolve, reject) => {105 addon.createInstance({}, undefined).then((i) => {106 resolve('success');107 }).catch((e) => {108 reject('should not fail but promise got rejected');109 });110 });111 });112 it('createInstance() should resolve when providing 2 valid but empty arguments (5)', function() {113 return new Promise((resolve, reject) => {114 addon.createInstance(null, null).then((i) => {115 resolve('success');116 }).catch((e) => {117 reject('should not fail but promise got rejected');118 });119 });120 });121 it.skip('createInstance() should reject when providing 1 undefined argument', function() {122 return new Promise((resolve, reject) => {123 addon.createInstance(undefined).then((i) => {124 reject('should fail but promise got resolved');125 }).catch((e) => {126 resolve('success');127 });128 });129 });130 it.skip('createInstance() should reject when providing 1 string argument', function() {131 return new Promise((resolve, reject) => {132 addon.createInstance('dummy').then((i) => {133 reject('should fail but promise got resolved');134 }).catch((e) => {135 resolve('success');136 });137 });138 });139 it.skip('createInstance() should reject when providing 1 number argument', function() {140 return new Promise((resolve, reject) => {141 addon.createInstance(89).then((i) => {142 reject('should fail but promise got resolved');143 }).catch((e) => {144 resolve('success');145 });146 });147 });148 it.skip('createInstance() should reject when providing 2 string arguments', function() {149 return new Promise((resolve, reject) => {150 addon.createInstance('humpty', 'dumpty').then((i) => {151 reject('should fail but promise got resolved');152 }).catch((e) => {153 resolve('success');154 });155 });156 });157 it.skip('createInstance() should reject when providing 2 number arguments', function() {158 return new Promise((resolve, reject) => {159 addon.createInstance(89, 64).then((i) => {160 reject('should fail but promise got resolved');161 }).catch((e) => {162 resolve('success');163 });164 });165 });...

Full Screen

Full Screen

api.js

Source:api.js Github

copy

Full Screen

...8 }9 });10};11export const getStatus = () => {12 return createInstance()13 .get("/api/status")14 .then(res => res.data);15};16// Get all Courses17export const getCourses = () => {18 return createInstance().get("/api/courses");19};20export const getCourseById = async course_id => {21 return await createInstance().get(`/api/courses/${course_id}`);22};23// Add Course24export const addCourse = async (name, location, organisation_id) => {25 return await createInstance().post("/api/courses", {26 name,27 location,28 organisation_id29 });30};31// Edit Course32export const editCourse = async (33 course_id,34 name,35 location,36 organisation_id37) => {38 return await createInstance().put(`/api/courses/${course_id}`, {39 name,40 location,41 organisation_id42 });43};44// Delete Course45export const deleteCourse = async course_id => {46 return await createInstance().delete(`api/courses/${course_id}`);47};48export const getStudentsAndMentor = async () => {49 return await createInstance().get(`api/students`);50};51export const getStudentRatingsByTopic = async topic_id => {52 return await createInstance().get(`api/student-ratings/${topic_id}`);53};54export const getOrganisations = async () => {55 return await createInstance()56 .get("/api/organisations");57};58export const getOrganisationsById = async organisation_id => {59 return await createInstance().get(`/api/organisations/${organisation_id}`);60};61export const addOrganisation = async name => {62 return await createInstance().post("/api/organisations", { name });63};64// Login user with local storage caching of jwt token after login65export const loginUser = async (email, password) => {66 const { data } = await createInstance().post("/auth/login", {67 email,68 password69 });70 // save token to the local storage71 localStorage.setItem("jwtToken", data.token);72 // axios.defaults.headers.common["Authorization"] = `Bearer ${data.token}`;73 // return the token74 return data.token;75};76export const getSessionUser = async () => {77 const token = localStorage.getItem("jwtToken");78 return await createInstance()79 .get("/user/profile", {80 headers: {81 Authorization: `Bearer ${token}`82 }83 })84 .then(res => res.data);85};86export const getUsersByRole = async () => {87 return await createInstance().get("/api/user-roles");88};89export const getUserRoles = async user_id => {90 return await createInstance().get(`/api/user-roles/${user_id}`, { user_id });91};92export const addRoleToUser = async (user_id, roles) => {93 return await createInstance().post("/api/user-roles", {94 user_id,95 roles96 });97};98export const getRoles = async () => {99 return await createInstance().get("/api/roles");100};101export const updateOrganisations = async (organisation_id, name) => {102 return await createInstance().put(`/api/organisations/${organisation_id}`, {103 organisation_id,104 name105 });106};107export const deleteOrganisation = organisation_id => {108 return createInstance().delete("/api/organisations/" + organisation_id);109};110export const getLessons = () => {111 return createInstance()112 .get("/api/lessons")113 .then(res => res.data);114};115export const getLessonsById = async lesson_id => {116 return await createInstance().get(`/api/lessons/${lesson_id}`);117};118export const deleteLesson = async lesson_id => {119 return await createInstance().delete("/api/lessons/" + lesson_id);120};121export const addLesson = async (name, lesson_date, course_id) => {122 return await createInstance().post("/api/lessons", {123 name,124 lesson_date,125 course_id126 });127};128// Edit Lesson129export const editLesson = async (lesson_id, name, lesson_date, course_id) => {130 return await createInstance().put(`/api/lessons/${lesson_id}`, {131 name,132 lesson_date,133 course_id134 });135};136export const getTopicsByLessonId = async lessonId => {137 return await createInstance().get(`/api/topics?lessonId=${lessonId}`);138};139export const deleteTopic = async topic_id => {140 return await createInstance().delete(`/api/topics/${topic_id}`);141};142export const addTopic = async (title, lesson_id) => {143 return await createInstance().post("/api/topics", { title, lesson_id });144};145export const updateTopics = async (topic_id, title) => {146 return await createInstance().put(`/api/topics/${topic_id}`, {147 topic_id,148 title149 });150};151export const getTopicById = async topic_id => {152 return await createInstance().get(`/api/topics/${topic_id}`);153};154// Add User155export const addUser = async (name, email, password) => {156 return await createInstance().post("/api/users", {157 name,158 email,159 password160 });161};162//Edit User163export const updateUserProfile = async (name, email) => {164 const token = localStorage.getItem("jwtToken");165 return await createInstance().put(`/user/profile`, {166 headers: {167 Authorization: `Bearer ${token}`168 },169 name,170 email171 });172};173export const getStudentsByCourseId = async course_id => {174 return await createInstance().get(`api/courses/${course_id}/students`);175};176export const assignUserToCourse = async (course_id, user_id) => {177 return await createInstance().post("/api/enrol", { course_id, user_id });178};179export const getCoursesByUser = async userId => {180 return await createInstance().get(`/api/user-courses/${userId}`);181};182export const getRatings = async lesson_id => {183 return await createInstance().get(`/api/ratings/${lesson_id}`);184};185export const addRatings = async (lessonId, ratings) => {186 return await createInstance().post(`/api/ratings/${lessonId}`, {187 ratings188 });189};190export const getUserProfileById = async user_id => {191 return await createInstance().get(`/api/user/${user_id}`);...

Full Screen

Full Screen

classConstructorAccessibility2.js

Source:classConstructorAccessibility2.js Github

copy

Full Screen

1//// [classConstructorAccessibility2.ts]2class BaseA {3 public constructor(public x: number) { }4 createInstance() { new BaseA(1); }5}6class BaseB {7 protected constructor(public x: number) { }8 createInstance() { new BaseB(2); }9}10class BaseC {11 private constructor(public x: number) { }12 createInstance() { new BaseC(3); }13 static staticInstance() { new BaseC(4); }14}15class DerivedA extends BaseA {16 constructor(public x: number) { super(x); }17 createInstance() { new DerivedA(5); }18 createBaseInstance() { new BaseA(6); }19 static staticBaseInstance() { new BaseA(7); }20}21class DerivedB extends BaseB {22 constructor(public x: number) { super(x); }23 createInstance() { new DerivedB(7); }24 createBaseInstance() { new BaseB(8); } // ok25 static staticBaseInstance() { new BaseB(9); } // ok26}27class DerivedC extends BaseC { // error28 constructor(public x: number) { super(x); }29 createInstance() { new DerivedC(9); }30 createBaseInstance() { new BaseC(10); } // error31 static staticBaseInstance() { new BaseC(11); } // error32}33var ba = new BaseA(1);34var bb = new BaseB(1); // error35var bc = new BaseC(1); // error36var da = new DerivedA(1);37var db = new DerivedB(1);38var dc = new DerivedC(1);394041//// [classConstructorAccessibility2.js]42var __extends = (this && this.__extends) || function (d, b) {43 for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];44 function __() { this.constructor = d; }45 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());46};47var BaseA = (function () {48 function BaseA(x) {49 this.x = x;50 }51 BaseA.prototype.createInstance = function () { new BaseA(1); };52 return BaseA;53}());54var BaseB = (function () {55 function BaseB(x) {56 this.x = x;57 }58 BaseB.prototype.createInstance = function () { new BaseB(2); };59 return BaseB;60}());61var BaseC = (function () {62 function BaseC(x) {63 this.x = x;64 }65 BaseC.prototype.createInstance = function () { new BaseC(3); };66 BaseC.staticInstance = function () { new BaseC(4); };67 return BaseC;68}());69var DerivedA = (function (_super) {70 __extends(DerivedA, _super);71 function DerivedA(x) {72 var _this = _super.call(this, x) || this;73 _this.x = x;74 return _this;75 }76 DerivedA.prototype.createInstance = function () { new DerivedA(5); };77 DerivedA.prototype.createBaseInstance = function () { new BaseA(6); };78 DerivedA.staticBaseInstance = function () { new BaseA(7); };79 return DerivedA;80}(BaseA));81var DerivedB = (function (_super) {82 __extends(DerivedB, _super);83 function DerivedB(x) {84 var _this = _super.call(this, x) || this;85 _this.x = x;86 return _this;87 }88 DerivedB.prototype.createInstance = function () { new DerivedB(7); };89 DerivedB.prototype.createBaseInstance = function () { new BaseB(8); }; // ok90 DerivedB.staticBaseInstance = function () { new BaseB(9); }; // ok91 return DerivedB;92}(BaseB));93var DerivedC = (function (_super) {94 __extends(DerivedC, _super);95 function DerivedC(x) {96 var _this = _super.call(this, x) || this;97 _this.x = x;98 return _this;99 }100 DerivedC.prototype.createInstance = function () { new DerivedC(9); };101 DerivedC.prototype.createBaseInstance = function () { new BaseC(10); }; // error102 DerivedC.staticBaseInstance = function () { new BaseC(11); }; // error103 return DerivedC;104}(BaseC));105var ba = new BaseA(1);106var bb = new BaseB(1); // error107var bc = new BaseC(1); // error108var da = new DerivedA(1);109var db = new DerivedB(1);110var dc = new DerivedC(1);111112113//// [classConstructorAccessibility2.d.ts]114declare class BaseA {115 x: number;116 constructor(x: number);117 createInstance(): void;118}119declare class BaseB {120 x: number;121 protected constructor(x: number);122 createInstance(): void;123}124declare class BaseC {125 x: number;126 private constructor(x);127 createInstance(): void;128 static staticInstance(): void;129}130declare class DerivedA extends BaseA {131 x: number;132 constructor(x: number);133 createInstance(): void;134 createBaseInstance(): void;135 static staticBaseInstance(): void;136}137declare class DerivedB extends BaseB {138 x: number;139 constructor(x: number);140 createInstance(): void;141 createBaseInstance(): void;142 static staticBaseInstance(): void;143}144declare class DerivedC extends BaseC {145 x: number;146 constructor(x: number);147 createInstance(): void;148 createBaseInstance(): void;149 static staticBaseInstance(): void;150}151declare var ba: BaseA;152declare var bb: any;153declare var bc: any;154declare var da: DerivedA;155declare var db: DerivedB; ...

Full Screen

Full Screen

configuration.spec.js

Source:configuration.spec.js Github

copy

Full Screen

1const OktaJwtVerifier = require('../../lib');2describe('jwt-verifier configuration validation', () => {3 it('should throw if no issuer is provided', () => {4 function createInstance() {5 new OktaJwtVerifier();6 }7 expect(createInstance).toThrow();8 });9 it('should throw if an issuer that does not contain https is provided', () => {10 function createInstance() {11 new OktaJwtVerifier({12 issuer: 'http://foo.com'13 });14 }15 expect(createInstance).toThrow();16 });17 it('should not throw if https issuer validation is skipped', () => {18 jest.spyOn(console, 'warn');19 function createInstance() {20 new OktaJwtVerifier({21 issuer: 'http://foo.com',22 testing: {23 disableHttpsCheck: true24 }25 });26 }27 expect(createInstance).not.toThrow();28 expect(console.warn).toBeCalledWith('Warning: HTTPS check is disabled. This allows for insecure configurations and is NOT recommended for production use.');29 });30 it('should throw if an issuer matching {yourOktaDomain} is provided', () => {31 function createInstance() {32 new OktaJwtVerifier({33 issuer: 'https://{yourOktaDomain}'34 });35 }36 expect(createInstance).toThrow();37 });38 it('should throw if an issuer matching -admin.okta.com is provided', () => {39 function createInstance() {40 new OktaJwtVerifier({41 issuer: 'https://foo-admin.okta.com'42 });43 }44 expect(createInstance).toThrow();45 });46 it('should throw if an issuer matching -admin.oktapreview.com is provided', () => {47 function createInstance() {48 new OktaJwtVerifier({49 issuer: 'https://foo-admin.oktapreview.com'50 });51 }52 expect(createInstance).toThrow();53 });54 it('should throw if an issuer matching -admin.okta-emea.com is provided', () => {55 function createInstance() {56 new OktaJwtVerifier({57 issuer: 'https://foo-admin.okta-emea.com'58 });59 }60 expect(createInstance).toThrow();61 });62 it('should throw if an issuer matching more than one ".com" is provided', () => {63 function createInstance() {64 new OktaJwtVerifier({65 issuer: 'https://foo.okta.com.com'66 });67 }68 expect(createInstance).toThrow();69 });70 it('should throw if an issuer matching more than one sequential "://" is provided', () => {71 function createInstance() {72 new OktaJwtVerifier({73 issuer: 'https://://foo.okta.com'74 });75 }76 expect(createInstance).toThrow();77 });78 it('should throw if an issuer matching more than one "://" is provided', () => {79 function createInstance() {80 new OktaJwtVerifier({81 issuer: 'https://foo.okta://.com'82 });83 }84 expect(createInstance).toThrow();85 });86 it('should throw if clientId matching {clientId} is provided', () => {87 function createInstance() {88 new OktaJwtVerifier({89 issuer: 'https://foo',90 clientId: '{clientId}',91 });92 }93 expect(createInstance).toThrow();94 });95 it('should NOT throw if clientId not matching {clientId} is provided', () => {96 function createInstance() {97 new OktaJwtVerifier({98 issuer: 'https://foo',99 clientId: '123456',100 });101 }102 expect(createInstance).not.toThrow();103 });...

Full Screen

Full Screen

debug-utils.js

Source:debug-utils.js Github

copy

Full Screen

1import localForage from 'localforage';2import localForageLru from '../lib/localforage-lru';3const deleteDatabases = () => Promise.all([4 localForage.createInstance({ name: 'accountsMetadata' }).clear(),5 localForage.createInstance({ name: 'accounts' }).clear(),6 localForageLru.createInstance({ name: 'subplebbits' }).clear(),7 localForageLru.createInstance({ name: 'comments' }).clear(),8 localForageLru.createInstance({ name: 'subplebbitsPages' }).clear(),9]);10const deleteCaches = () => Promise.all([11 localForageLru.createInstance({ name: 'subplebbits' }).clear(),12 localForageLru.createInstance({ name: 'comments' }).clear(),13 localForageLru.createInstance({ name: 'subplebbitsPages' }).clear(),14]);15const deleteAccountsDatabases = () => Promise.all([16 localForage.createInstance({ name: 'accountsMetadata' }).clear(),17 localForage.createInstance({ name: 'accounts' }).clear(),18]);19const deleteNonAccountsDatabases = () => Promise.all([20 localForageLru.createInstance({ name: 'subplebbits' }).clear(),21 localForageLru.createInstance({ name: 'comments' }).clear(),22 localForageLru.createInstance({ name: 'subplebbitsPages' }).clear(),23]);24const debugUtils = {25 deleteDatabases,26 deleteCaches,27 deleteAccountsDatabases,28 deleteNonAccountsDatabases29};30export { deleteDatabases, deleteCaches, deleteAccountsDatabases, deleteNonAccountsDatabases };...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1const playwright = require('playwright');2(async () => {3 const browser = await playwright.chromium.createInstance();4 const context = await browser.newContext();5 const page = await context.newPage();6 await page.screenshot({ path: 'example.png' });7 await browser.close();8})();9const playwright = require('playwright');10(async () => {11 const browser = await playwright.chromium.createBrowser();12 const context = await browser.newContext();13 const page = await context.newPage();14 await page.screenshot({ path: 'example.png' });15 await browser.close();16})();17const playwright = require('playwright');18(async () => {19 const browser = await playwright.chromium.launch();20 const context = await browser.createBrowserContext();21 const page = await context.newPage();22 await page.screenshot({ path: 'example.png' });23 await browser.close();24})();25const playwright = require('playwright');26(async () => {27 const browser = await playwright.chromium.launch();28 const context = await browser.newContext();29 const page = await context.createPage();30 await page.screenshot({ path: 'example.png' });31 await browser.close();32})();33const playwright = require('playwright');34(async () => {35 const browser = await playwright.chromium.launch();36 const proxy = await browser.createProxy();37 await proxy.authenticate('username', 'password');38 await proxy.close();39})();40const playwright = require('playwright');41(async () => {42 const browserType = await playwright.createBrowserType('chromium');43 const browser = await browserType.launch();44 const context = await browser.newContext();45 const page = await context.newPage();46 await page.goto('

Full Screen

Using AI Code Generation

copy

Full Screen

1const playwright = require("playwright");2(async () => {3 const browser = await playwright.chromium.createInstance();4 const context = await browser.newContext();5 const page = await context.newPage();6 await page.screenshot({ path: "example.png" });7 await browser.close();8})();9const playwright = require("playwright");10(async () => {11 const browser = await playwright.chromium.createInstance();12 const context = await browser.newContext();13 const page = await context.newPage();14 await page.screenshot({ path: "example.png" });15 await browser.close();16})();17const playwright = require("playwright");18(async () => {19 const browser = await playwright.chromium.createInstance();20 const context = await browser.newContext();21 const page = await context.newPage();22 await page.screenshot({ path: "example.png" });23 await browser.close();24})();25const playwright = require("playwright");26(async () => {27 const browser = await playwright.chromium.createInstance();28 const context = await browser.newContext();29 const page = await context.newPage();30 await page.screenshot({ path: "example.png" });31 await browser.close();32})();33const playwright = require("playwright");34(async () => {35 const browser = await playwright.chromium.createInstance();36 const context = await browser.newContext();37 const page = await context.newPage();38 await page.screenshot({ path: "example.png" });39 await browser.close();40})();41const playwright = require("playwright");42(async () => {43 const browser = await playwright.chromium.createInstance();44 const context = await browser.newContext();45 const page = await context.newPage();46 await page.goto("https

Full Screen

Using AI Code Generation

copy

Full Screen

1const { chromium } = require('playwright');2(async () => {3 const browser = await chromium.createInstance({4 });5 const context = await browser.newContext();6 const page = await context.newPage();7 await page.screenshot({ path: 'example.png' });8 await browser.close();9})();10const browser = await chromium.createInstance({11 });12const browser = await chromium.createInstance({13 proxy: {14 },15 geolocation: { longitude: 12.492507, latitude: 41.889938 },16 extraHTTPHeaders: {17 },18 });19const browser = await chromium.createInstance({20 });21const browser = await chromium.createInstance({22 });

Full Screen

Using AI Code Generation

copy

Full Screen

1const playwright = require('playwright');2(async () => {3 const browser = await playwright.chromium.createInstance({4 });5 const context = await browser.newContext();6 const page = await context.newPage();7 await page.screenshot({ path: 'google.png' });8 await browser.close();9})();10{11 "scripts": {12 },13 "dependencies": {14 }15}16const playwright = require('playwright');17(async () => {18 const browser = await playwright.chromium.createInstance({19 });20 const context = await browser.newContext();21 const page = await context.newPage();22 await page.screenshot({ path: 'google.png' });23 await browser.close();24})();25const playwright = require('playwright');26(async () => {27 const browser = await playwright.chromium.createInstance({28 });

Full Screen

Using AI Code Generation

copy

Full Screen

1const { createInstance } = require('playwright-core/lib/server/browserType');2const browserType = createInstance('chromium');3const browser = await browserType.launch();4const context = await browser.newContext();5const page = await context.newPage();6await page.screenshot({ path: 'example.png' });7await browser.close();8const { createInstance } = require('playwright-core/lib/server/browserType');9const browserType = createInstance('chromium');10const browser = await browserType.launch();11const context = await browser.newContext();12const page = await context.newPage();13await page.screenshot({ path: 'example.png' });14await browser.close();15const { createInstance } = require('playwright-core/lib/server/browserType');16const browserType = createInstance('chromium');17const browser = await browserType.launch();18const context = await browser.newContext();19const page = await context.newPage();20await page.screenshot({ path: 'example.png' });21await browser.close();22const { createInstance } = require('playwright-core/lib/server/browserType');23const browserType = createInstance('chromium');24const browser = await browserType.launch();25const context = await browser.newContext();26const page = await context.newPage();27await page.screenshot({ path: 'example.png' });28await browser.close();29const { createInstance } = require('playwright-core/lib/server/browserType');30const browserType = createInstance('chromium');31const browser = await browserType.launch();32const context = await browser.newContext();33const page = await context.newPage();34await page.screenshot({ path: 'example.png' });35await browser.close();36const { createInstance } = require('playwright-core/lib/server/browserType');

Full Screen

Using AI Code Generation

copy

Full Screen

1const playwright = require('playwright');2(async () => {3 const browser = await playwright.chromium.createInstance({4 });5 const context = await browser.newContext();6 const page = await context.newPage();7 await page.screenshot({ path: 'example.png' });8 await browser.close();9})();

Full Screen

Using AI Code Generation

copy

Full Screen

1const { PlaywrightInternalAPI } = require('playwright');2const browser = PlaywrightInternalAPI.createInstance('chromium');3(async () => {4 const context = await browser.newContext();5 const page = await context.newPage();6 await page.screenshot({ path: 'example.png' });7 await browser.close();8})();

Full Screen

Using AI Code Generation

copy

Full Screen

1const { chromium } = require('playwright');2(async () => {3 const browser = await chromium.createInstance({4 });5 const context = await browser.newContext();6 const page = await context.newPage();7 await page.screenshot({ path: `example.png` });8 await browser.close();9})();10 ✓ sample.spec.js (1s)11 1 passed (2s)12 ✓ sample.spec.js (1s)13 1 passed (2s)14 ✓ sample.spec.js (1s)15 1 passed (2s)

Full Screen

Using AI Code Generation

copy

Full Screen

1const { createInstance } = require('playwright-core/lib/server/browserType');2(async () => {3 const browser = await createInstance('chromium', {4 });5 const context = await browser.newContext();6 const page = await context.newPage();7 await page.screenshot({ path: 'example.png' });8 await browser.close();9})();

Full Screen

Using AI Code Generation

copy

Full Screen

1const {createInstance} = require('@playwright/test/lib/server/playwright');2const playwright = createInstance('/Users/xyz/playwright/playwright-cli/node_modules/playwright');3const {createInstance} = require('@playwright/test/lib/server/playwright');4const playwright = createInstance('/Users/xyz/playwright/playwright-cli/node_modules/playwright');5const {createInstance} = require('@playwright/test/lib/server/playwright');6const playwright = createInstance('/Users/xyz/playwright/playwright-cli/node_modules/playwright');7const {createInstance} = require('@playwright/test/lib/server/playwright');8const playwright = createInstance('/Users/xyz/playwright/playwright-cli/node_modules/playwright');9const {createInstance} = require('@playwright/test/lib/server/playwright');10const playwright = createInstance('/Users/xyz/playwright/playwright-cli/node_modules/playwright');11const {createInstance} = require('@playwright/test/lib/server/playwright');12const playwright = createInstance('/Users/xyz/playwright/playwright-cli/node_modules/playwright');13const {createInstance} = require('@playwright/test/lib/server/playwright');14const playwright = createInstance('/Users/xyz/playwright/playwright-cli/node_modules/playwright');15const {createInstance} = require('@playwright/test/lib/server/playwright');16const playwright = createInstance('/Users/xyz/playwright/playwright-cli/node_modules/playwright');17const {createInstance} = require('@playwright/test/lib/server/playwright');18const playwright = createInstance('/Users/xyz/playwright/playwright-cli/node_modules/playwright');19const {createInstance} = require('@playwright/test/lib/server/playwright');20const playwright = createInstance('/Users/xyz/playwright/playwright-cli/node_modules/playwright');21const {createInstance} = require('@playwright/test/lib/server/playwright');22const playwright = createInstance('/Users/xyz/playwright/play

Full Screen

Playwright tutorial

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

Chapters:

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

Run Playwright Internal automation tests on LambdaTest cloud grid

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

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful