How to use getExclusive method in Playwright Internal

Best JavaScript code snippet using playwright-internal

ReactPerf-test.js

Source:ReactPerf-test.js Github

copy

Full Screen

...71 ReactPerf.stop();72 // Make sure none of the methods crash.73 ReactPerf.getWasted();74 ReactPerf.getInclusive();75 ReactPerf.getExclusive();76 ReactPerf.getOperations();77 return ReactPerf.getLastMeasurements();78 }79 it('should count no-op update as waste', function() {80 var container = document.createElement('div');81 ReactDOM.render(<App />, container);82 var measurements = measure(() => {83 ReactDOM.render(<App />, container);84 });85 var summary = ReactPerf.getWasted(measurements);86 expect(summary).toEqual([{87 key: 'App',88 instanceCount: 1,89 inclusiveRenderDuration: 3,90 renderCount: 1,91 }, {92 key: 'App > Box',93 instanceCount: 2,94 inclusiveRenderDuration: 2,95 renderCount: 2,96 }]);97 });98 it('should count no-op update in child as waste', function() {99 var container = document.createElement('div');100 ReactDOM.render(<App />, container);101 // Here, we add a Box -- two of the <Box /> updates are wasted time (but the102 // addition of the third is not)103 var measurements = measure(() => {104 ReactDOM.render(<App flipSecond={true} />, container);105 });106 var summary = ReactPerf.getWasted(measurements);107 expect(summary).toEqual([{108 key: 'App > Box',109 instanceCount: 1,110 inclusiveRenderDuration: 1,111 renderCount: 1,112 }]);113 });114 function expectNoWaste(fn) {115 var measurements = measure(fn);116 var summary = ReactPerf.getWasted(measurements);117 expect(summary).toEqual([]);118 }119 it('should not count initial render as waste', function() {120 expectNoWaste(() => {121 ReactTestUtils.renderIntoDocument(<App />);122 });123 });124 it('should not count unmount as waste', function() {125 var container = document.createElement('div');126 ReactDOM.render(<Div>hello</Div>, container);127 expectNoWaste(() => {128 ReactDOM.unmountComponentAtNode(container);129 });130 });131 it('should not count content update as waste', function() {132 var container = document.createElement('div');133 ReactDOM.render(<Div>hello</Div>, container);134 expectNoWaste(() => {135 ReactDOM.render(<Div>hello world</Div>, container);136 });137 });138 it('should not count child addition as waste', function() {139 var container = document.createElement('div');140 ReactDOM.render(<Div><span /></Div>, container);141 expectNoWaste(() => {142 ReactDOM.render(<Div><span /><span /></Div>, container);143 });144 });145 it('should not count child removal as waste', function() {146 var container = document.createElement('div');147 ReactDOM.render(<Div><span /><span /></Div>, container);148 expectNoWaste(() => {149 ReactDOM.render(<Div><span /></Div>, container);150 });151 });152 it('should not count property update as waste', function() {153 var container = document.createElement('div');154 ReactDOM.render(<Div className="yellow">hey</Div>, container);155 expectNoWaste(() => {156 ReactDOM.render(<Div className="blue">hey</Div>, container);157 });158 });159 it('should not count style update as waste', function() {160 var container = document.createElement('div');161 ReactDOM.render(<Div style={{color: 'yellow'}}>hey</Div>, container);162 expectNoWaste(() => {163 ReactDOM.render(<Div style={{color: 'blue'}}>hey</Div>, container);164 });165 });166 it('should not count property removal as waste', function() {167 var container = document.createElement('div');168 ReactDOM.render(<Div className="yellow">hey</Div>, container);169 expectNoWaste(() => {170 ReactDOM.render(<Div>hey</Div>, container);171 });172 });173 it('should not count raw HTML update as waste', function() {174 var container = document.createElement('div');175 ReactDOM.render(176 <Div dangerouslySetInnerHTML={{__html: 'me'}} />,177 container178 );179 expectNoWaste(() => {180 ReactDOM.render(181 <Div dangerouslySetInnerHTML={{__html: 'you'}} />,182 container183 );184 });185 });186 it('should not count child reordering as waste', function() {187 var container = document.createElement('div');188 ReactDOM.render(<Div><div key="A" /><div key="B" /></Div>, container);189 expectNoWaste(() => {190 ReactDOM.render(<Div><div key="B" /><div key="A" /></Div>, container);191 });192 });193 it('should not count text update as waste', function() {194 var container = document.createElement('div');195 ReactDOM.render(<Div>{'hello'}{'world'}</Div>, container);196 expectNoWaste(() => {197 ReactDOM.render(<Div>{'hello'}{'friend'}</Div>, container);198 });199 });200 it('should not count replacing null with a host as waste', function() {201 var element = null;202 function Foo() {203 return element;204 }205 var container = document.createElement('div');206 ReactDOM.render(<Foo />, container);207 expectNoWaste(() => {208 element = <div />;209 ReactDOM.render(<Foo />, container);210 });211 });212 it('should not count replacing a host with null as waste', function() {213 var element = <div />;214 function Foo() {215 return element;216 }217 var container = document.createElement('div');218 ReactDOM.render(<Foo />, container);219 expectNoWaste(() => {220 element = null;221 ReactDOM.render(<Foo />, container);222 });223 });224 it('should include stats for components unmounted during measurement', function() {225 var container = document.createElement('div');226 var measurements = measure(() => {227 ReactDOM.render(<Div><Div key="a" /></Div>, container);228 ReactDOM.render(<Div><Div key="b" /></Div>, container);229 });230 expect(ReactPerf.getExclusive(measurements)).toEqual([{231 key: 'Div',232 instanceCount: 3,233 counts: { ctor: 3, render: 4 },234 durations: { ctor: 3, render: 4 },235 totalDuration: 7,236 }]);237 });238 it('should include lifecycle methods in measurements', function() {239 var container = document.createElement('div');240 var measurements = measure(() => {241 var instance = ReactDOM.render(<LifeCycle />, container);242 ReactDOM.render(<LifeCycle />, container);243 instance.setState({});244 ReactDOM.unmountComponentAtNode(container);245 });246 expect(ReactPerf.getExclusive(measurements)).toEqual([{247 key: 'LifeCycle',248 instanceCount: 1,249 totalDuration: 14,250 counts: {251 ctor: 1,252 shouldComponentUpdate: 2,253 componentWillMount: 1,254 componentDidMount: 1,255 componentWillReceiveProps: 1,256 componentWillUpdate: 2,257 componentDidUpdate: 2,258 componentWillUnmount: 1,259 render: 3,260 },261 durations: {262 ctor: 1,263 shouldComponentUpdate: 2,264 componentWillMount: 1,265 componentDidMount: 1,266 componentWillReceiveProps: 1,267 componentWillUpdate: 2,268 componentDidUpdate: 2,269 componentWillUnmount: 1,270 render: 3,271 },272 }]);273 });274 it('should include render time of functional components', function() {275 function Foo() {276 return null;277 }278 var container = document.createElement('div');279 var measurements = measure(() => {280 ReactDOM.render(<Foo />, container);281 });282 expect(ReactPerf.getExclusive(measurements)).toEqual([{283 key: 'Foo',284 instanceCount: 1,285 totalDuration: 1,286 counts: {287 render: 1,288 },289 durations: {290 render: 1,291 },292 }]);293 });294 it('should not count time in a portal towards lifecycle method', function() {295 function Foo() {296 return null;297 }298 var portalContainer = document.createElement('div');299 class Portal extends React.Component {300 componentDidMount() {301 ReactDOM.render(<Foo />, portalContainer);302 }303 render() {304 return null;305 }306 }307 var container = document.createElement('div');308 var measurements = measure(() => {309 ReactDOM.render(<Portal />, container);310 });311 expect(ReactPerf.getExclusive(measurements)).toEqual([{312 key: 'Portal',313 instanceCount: 1,314 totalDuration: 6,315 counts: {316 ctor: 1,317 componentDidMount: 1,318 render: 1,319 },320 durations: {321 ctor: 1,322 // We want to exclude nested imperative ReactDOM.render() from lifecycle hook's own time.323 // Otherwise it would artificially float to the top even though its exclusive time is small.324 // This is how we get 4 as a number with the performanceNow() mock:325 // - we capture the time we enter componentDidMount (n = 0)326 // - we capture the time when we enter a nested flush (n = 1)327 // - in the nested flush, we call it twice: before and after <Foo /> rendering. (n = 3)328 // - we capture the time when we exit a nested flush (n = 4)329 // - we capture the time we exit componentDidMount (n = 5)330 // Time spent in componentDidMount = (5 - 0 - (4 - 3)) = 4.331 componentDidMount: 4,332 render: 1,333 },334 }, {335 key: 'Foo',336 instanceCount: 1,337 totalDuration: 1,338 counts: {339 render: 1,340 },341 durations: {342 render: 1,343 },344 }]);345 });346 it('warns once when using getMeasurementsSummaryMap', function() {347 var measurements = measure(() => {});348 spyOn(console, 'error');349 ReactPerf.getMeasurementsSummaryMap(measurements);350 expect(console.error.calls.count()).toBe(1);351 expect(console.error.calls.argsFor(0)[0]).toContain(352 '`ReactPerf.getMeasurementsSummaryMap(...)` is deprecated. Use ' +353 '`ReactPerf.getWasted(...)` instead.'354 );355 ReactPerf.getMeasurementsSummaryMap(measurements);356 expect(console.error.calls.count()).toBe(1);357 });358 it('warns once when using printDOM', function() {359 var measurements = measure(() => {});360 spyOn(console, 'error');361 ReactPerf.printDOM(measurements);362 expect(console.error.calls.count()).toBe(1);363 expect(console.error.calls.argsFor(0)[0]).toContain(364 '`ReactPerf.printDOM(...)` is deprecated. Use ' +365 '`ReactPerf.printOperations(...)` instead.'366 );367 ReactPerf.printDOM(measurements);368 expect(console.error.calls.count()).toBe(1);369 });370 it('returns isRunning state', () => {371 expect(ReactPerf.isRunning()).toBe(false);372 ReactPerf.start();373 expect(ReactPerf.isRunning()).toBe(true);374 ReactPerf.stop();375 expect(ReactPerf.isRunning()).toBe(false);376 });377 it('start has no effect when already running', () => {378 expect(ReactPerf.isRunning()).toBe(false);379 ReactPerf.start();380 expect(ReactPerf.isRunning()).toBe(true);381 ReactPerf.start();382 expect(ReactPerf.isRunning()).toBe(true);383 ReactPerf.stop();384 expect(ReactPerf.isRunning()).toBe(false);385 });386 it('stop has no effect when already stopped', () => {387 expect(ReactPerf.isRunning()).toBe(false);388 ReactPerf.stop();389 expect(ReactPerf.isRunning()).toBe(false);390 ReactPerf.stop();391 expect(ReactPerf.isRunning()).toBe(false);392 });393 it('should print console error only once', () => {394 __DEV__ = false;395 spyOn(console, 'error');396 expect(ReactPerf.getLastMeasurements()).toEqual([]);397 expect(ReactPerf.getExclusive()).toEqual([]);398 expect(ReactPerf.getInclusive()).toEqual([]);399 expect(ReactPerf.getWasted()).toEqual([]);400 expect(ReactPerf.getOperations()).toEqual([]);401 expect(ReactPerf.printExclusive()).toEqual(undefined);402 expect(ReactPerf.printInclusive()).toEqual(undefined);403 expect(ReactPerf.printWasted()).toEqual(undefined);404 expect(ReactPerf.printOperations()).toEqual(undefined);405 expect(ReactPerf.start()).toBe(undefined);406 expect(ReactPerf.stop()).toBe(undefined);407 expect(ReactPerf.isRunning()).toBe(false);408 expect(console.error.calls.count()).toBe(1);409 __DEV__ = true;410 });411 it('should work when measurement starts during reconciliation', () => {...

Full Screen

Full Screen

ReactPerf.js

Source:ReactPerf.js Github

copy

Full Screen

...36 return [];37 }38 return ReactDebugTool.getFlushHistory();39 }40 function getExclusive() {41 var flushHistory = arguments.length <= 0 || arguments[0] === undefined ? getLastMeasurements() : arguments[0];42 if (!(process.env.NODE_ENV !== 'production')) {43 warnInProduction();44 return [];45 }46 var aggregatedStats = {};47 var affectedIDs = {};48 function updateAggregatedStats(treeSnapshot, instanceID, timerType, applyUpdate) {49 var displayName = treeSnapshot[instanceID].displayName;50 var key = displayName;51 var stats = aggregatedStats[key];52 if (!stats) {53 affectedIDs[key] = {};54 stats = aggregatedStats[key] = {55 key: key,56 instanceCount: 0,57 counts: {},58 durations: {},59 totalDuration: 060 };61 }62 if (!stats.durations[timerType]) {63 stats.durations[timerType] = 0;64 }65 if (!stats.counts[timerType]) {66 stats.counts[timerType] = 0;67 }68 affectedIDs[key][instanceID] = true;69 applyUpdate(stats);70 }71 flushHistory.forEach(function(flush) {72 var measurements = flush.measurements;73 var treeSnapshot = flush.treeSnapshot;74 measurements.forEach(function(measurement) {75 var duration = measurement.duration;76 var instanceID = measurement.instanceID;77 var timerType = measurement.timerType;78 updateAggregatedStats(treeSnapshot, instanceID, timerType, function(stats) {79 stats.totalDuration += duration;80 stats.durations[timerType] += duration;81 stats.counts[timerType]++;82 });83 });84 });85 return Object.keys(aggregatedStats).map(function(key) {86 return _extends({}, aggregatedStats[key], {instanceCount: Object.keys(affectedIDs[key]).length});87 }).sort(function(a, b) {88 return b.totalDuration - a.totalDuration;89 });90 }91 function getInclusive() {92 var flushHistory = arguments.length <= 0 || arguments[0] === undefined ? getLastMeasurements() : arguments[0];93 if (!(process.env.NODE_ENV !== 'production')) {94 warnInProduction();95 return [];96 }97 var aggregatedStats = {};98 var affectedIDs = {};99 function updateAggregatedStats(treeSnapshot, instanceID, applyUpdate) {100 var _treeSnapshot$instanc = treeSnapshot[instanceID];101 var displayName = _treeSnapshot$instanc.displayName;102 var ownerID = _treeSnapshot$instanc.ownerID;103 var owner = treeSnapshot[ownerID];104 var key = (owner ? owner.displayName + ' > ' : '') + displayName;105 var stats = aggregatedStats[key];106 if (!stats) {107 affectedIDs[key] = {};108 stats = aggregatedStats[key] = {109 key: key,110 instanceCount: 0,111 inclusiveRenderDuration: 0,112 renderCount: 0113 };114 }115 affectedIDs[key][instanceID] = true;116 applyUpdate(stats);117 }118 var isCompositeByID = {};119 flushHistory.forEach(function(flush) {120 var measurements = flush.measurements;121 measurements.forEach(function(measurement) {122 var instanceID = measurement.instanceID;123 var timerType = measurement.timerType;124 if (timerType !== 'render') {125 return;126 }127 isCompositeByID[instanceID] = true;128 });129 });130 flushHistory.forEach(function(flush) {131 var measurements = flush.measurements;132 var treeSnapshot = flush.treeSnapshot;133 measurements.forEach(function(measurement) {134 var duration = measurement.duration;135 var instanceID = measurement.instanceID;136 var timerType = measurement.timerType;137 if (timerType !== 'render') {138 return;139 }140 updateAggregatedStats(treeSnapshot, instanceID, function(stats) {141 stats.renderCount++;142 });143 var nextParentID = instanceID;144 while (nextParentID) {145 if (isCompositeByID[nextParentID]) {146 updateAggregatedStats(treeSnapshot, nextParentID, function(stats) {147 stats.inclusiveRenderDuration += duration;148 });149 }150 nextParentID = treeSnapshot[nextParentID].parentID;151 }152 });153 });154 return Object.keys(aggregatedStats).map(function(key) {155 return _extends({}, aggregatedStats[key], {instanceCount: Object.keys(affectedIDs[key]).length});156 }).sort(function(a, b) {157 return b.inclusiveRenderDuration - a.inclusiveRenderDuration;158 });159 }160 function getWasted() {161 var flushHistory = arguments.length <= 0 || arguments[0] === undefined ? getLastMeasurements() : arguments[0];162 if (!(process.env.NODE_ENV !== 'production')) {163 warnInProduction();164 return [];165 }166 var aggregatedStats = {};167 var affectedIDs = {};168 function updateAggregatedStats(treeSnapshot, instanceID, applyUpdate) {169 var _treeSnapshot$instanc2 = treeSnapshot[instanceID];170 var displayName = _treeSnapshot$instanc2.displayName;171 var ownerID = _treeSnapshot$instanc2.ownerID;172 var owner = treeSnapshot[ownerID];173 var key = (owner ? owner.displayName + ' > ' : '') + displayName;174 var stats = aggregatedStats[key];175 if (!stats) {176 affectedIDs[key] = {};177 stats = aggregatedStats[key] = {178 key: key,179 instanceCount: 0,180 inclusiveRenderDuration: 0,181 renderCount: 0182 };183 }184 affectedIDs[key][instanceID] = true;185 applyUpdate(stats);186 }187 flushHistory.forEach(function(flush) {188 var measurements = flush.measurements;189 var treeSnapshot = flush.treeSnapshot;190 var operations = flush.operations;191 var isDefinitelyNotWastedByID = {};192 operations.forEach(function(operation) {193 var instanceID = operation.instanceID;194 var nextParentID = instanceID;195 while (nextParentID) {196 isDefinitelyNotWastedByID[nextParentID] = true;197 nextParentID = treeSnapshot[nextParentID].parentID;198 }199 });200 var renderedCompositeIDs = {};201 measurements.forEach(function(measurement) {202 var instanceID = measurement.instanceID;203 var timerType = measurement.timerType;204 if (timerType !== 'render') {205 return;206 }207 renderedCompositeIDs[instanceID] = true;208 });209 measurements.forEach(function(measurement) {210 var duration = measurement.duration;211 var instanceID = measurement.instanceID;212 var timerType = measurement.timerType;213 if (timerType !== 'render') {214 return;215 }216 var updateCount = treeSnapshot[instanceID].updateCount;217 if (isDefinitelyNotWastedByID[instanceID] || updateCount === 0) {218 return;219 }220 updateAggregatedStats(treeSnapshot, instanceID, function(stats) {221 stats.renderCount++;222 });223 var nextParentID = instanceID;224 while (nextParentID) {225 var isWasted = renderedCompositeIDs[nextParentID] && !isDefinitelyNotWastedByID[nextParentID];226 if (isWasted) {227 updateAggregatedStats(treeSnapshot, nextParentID, function(stats) {228 stats.inclusiveRenderDuration += duration;229 });230 }231 nextParentID = treeSnapshot[nextParentID].parentID;232 }233 });234 });235 return Object.keys(aggregatedStats).map(function(key) {236 return _extends({}, aggregatedStats[key], {instanceCount: Object.keys(affectedIDs[key]).length});237 }).sort(function(a, b) {238 return b.inclusiveRenderDuration - a.inclusiveRenderDuration;239 });240 }241 function getOperations() {242 var flushHistory = arguments.length <= 0 || arguments[0] === undefined ? getLastMeasurements() : arguments[0];243 if (!(process.env.NODE_ENV !== 'production')) {244 warnInProduction();245 return [];246 }247 var stats = [];248 flushHistory.forEach(function(flush, flushIndex) {249 var operations = flush.operations;250 var treeSnapshot = flush.treeSnapshot;251 operations.forEach(function(operation) {252 var instanceID = operation.instanceID;253 var type = operation.type;254 var payload = operation.payload;255 var _treeSnapshot$instanc3 = treeSnapshot[instanceID];256 var displayName = _treeSnapshot$instanc3.displayName;257 var ownerID = _treeSnapshot$instanc3.ownerID;258 var owner = treeSnapshot[ownerID];259 var key = (owner ? owner.displayName + ' > ' : '') + displayName;260 stats.push({261 flushIndex: flushIndex,262 instanceID: instanceID,263 key: key,264 type: type,265 ownerID: ownerID,266 payload: payload267 });268 });269 });270 return stats;271 }272 function printExclusive(flushHistory) {273 if (!(process.env.NODE_ENV !== 'production')) {274 warnInProduction();275 return;276 }277 var stats = getExclusive(flushHistory);278 var table = stats.map(function(item) {279 var key = item.key;280 var instanceCount = item.instanceCount;281 var totalDuration = item.totalDuration;282 var renderCount = item.counts.render || 0;283 var renderDuration = item.durations.render || 0;284 return {285 'Component': key,286 'Total time (ms)': roundFloat(totalDuration),287 'Instance count': instanceCount,288 'Total render time (ms)': roundFloat(renderDuration),289 'Average render time (ms)': renderCount ? roundFloat(renderDuration / renderCount) : undefined,290 'Render count': renderCount,291 'Total lifecycle time (ms)': roundFloat(totalDuration - renderDuration)...

Full Screen

Full Screen

page.js

Source:page.js Github

copy

Full Screen

...18 current: 119 }20 },21 mounted() {22 this.getExclusive(1);23 },24 methods: {25 getExclusive(currentPage) {26 var that = this;27 that.loading = true;28 that.current = currentPage || that.current;29 $("#exclusive").find(".showAnimate").hide();30 $.ajaxForJson(config.wwwPath + "tenderAjax", {31 cglx: $(".tender_type_wrap[data-type='cglx']").find("li.active").attr("data-id"),32 cgzt: $(".tender_type_wrap[data-type='cgzt']").find("li.active").attr("data-id"),33 cgfs: $(".tender_type_wrap[data-type='cgfs']").find("li.active").attr("data-id"),34 stype: $(".tender_search").find("dl dd.act").attr("data-id"),35 sword: $(".tender_search").find("input.tender_search_input").val(),36 sort: $("ul[name='sort']").find("li.active").attr("data-id"),37 p: that.current38 }, function (dataObj) {39 if (dataObj.code == 2000) {40 that.count = dataObj.data.count;41 that.list = dataObj.data.data;42 $("#exclusive").find(".showAnimate").show();43 }44 that.loading = false;45 });46 },47 showTips(val) {48 $.msgTips({49 type: "warning",50 content: val51 });52 }53 }54 });55 //选择类型56 $("div.tender_type_wrap li a").unbind().bind("click", function () {57 var main = $(this);58 main.parents(".tender_type_wrap").find("li").removeClass("active");59 main.parent().addClass("active");60 vm.getExclusive(1);61 return false;62 });63 //选择搜索类型64 $(".tender_search").find("dd").unbind().bind("click", function () {65 $(".tender_search").find("dd").removeClass("act");66 $(this).addClass("act");67 $(".tender_search_sel > span").html($(this).html());68 $(".tender_search").find("dl").hide();69 });70 $(".tender_search_sel").unbind().bind({71 "mouseover": function () {72 $(".tender_search_sel").find("dl").show();73 },74 "mouseleave": function () {75 $(".tender_search_sel").find("dl").hide();76 }77 });78 //点击搜索事件79 $(".tender_search").find("a.tender_search_btn").unbind().bind("click", function () {80 vm.getExclusive(1);81 return false;82 });83 //清空搜索84 $(".tender_select").find("a.tender_clear_btn").unbind().bind("click", function () {85 $(".tender_search").find("input.tender_search_input").val("");86 vm.getExclusive(1);87 return false;88 });89 //回车事件90 $(".tender_search").find("input.tender_search_input").unbind().bind("keyup", function (event) {91 if (event.keyCode == "13") {92 $(".tender_search").find("a.tender_search_btn").triggerHandler("click");93 return false;94 }95 });96 //排序事件97 $("ul[name='sort']").find("li a").unbind().bind("click", function () {98 var main = $(this);99 $("ul[name='sort']").find("li").removeClass("active");100 main.parent().addClass("active");101 vm.getExclusive(1);102 return false;103 });...

Full Screen

Full Screen

index.js

Source:index.js Github

copy

Full Screen

...37 case '/':38 getAll(storageItems);39 break;40 case '/exclusivos':41 getExclusive(storageItems);42 break;43 case '/promocao':44 getPromotion(storageItems);45 break;46 case '/favoritos':47 getFavorite(storageItems);48 break;49 default:50 break;51 }52 setLoading(false);53 }54 loadItems();55 }, [...

Full Screen

Full Screen

shareController.js

Source:shareController.js Github

copy

Full Screen

1var e = require("../models/models.js"), n = require("../interfaces/shareITF.js"), t = {2 getExclusive: function(t) {3 return n.getExclusive(t).then(function(e) {4 return Promise.resolve(e);5 }, e.failHandle);6 },7 getExclusiveCoupon: function(t) {8 return n.getExclusiveCoupon(t).then(function(e) {9 e.data = e.data || {};10 var n = [], t = e.data.coupon_list || {};11 return Object.keys(t).forEach(function(e) {12 n.push(t[e]);13 }), n.forEach(function(e, t) {14 var o = [];15 e.coupon_content && o.push("· " + e.coupon_content), e.coupon_date && o.push("· " + e.coupon_date), 16 n[t] = {17 usable: !0,...

Full Screen

Full Screen

search.js

Source:search.js Github

copy

Full Screen

...34 method: 'get',35 })36}37// 获取该搜索词的专属词条(往往是一些词汇所对应的acg作品名称)38function getExclusive(param) {39 return axios({40 url: `/keywords/${format(param)}/suggestions`,41 method: 'get',42 })43}44function getTranslations(param) {45 return axios({46 url: `/keywords/${format(param)}/translations`,47 method: 'get',48 })49}50// 图片上传51function uploadImg(data, params) {52 return axios({...

Full Screen

Full Screen

service.js

Source:service.js Github

copy

Full Screen

1const tools = require('../tools');2const userService = require('../user/service');3const SapiError = require('../../sapi').SapiError;4const ObjectId = require('mongodb').ObjectId;5var debug = require('debug')('app:service');6debug.log = console.log.bind(console);7const dbReset = (db) => {8 return db.dropCollection('appdata')9 .catch((err) => { console.log(err) })10 .then(() => db.createCollection('appdata'))11 .then(() => db.collection('appdata')12 .createIndex(13 { lobbyId: 1, exclusive: 1 },14 { unique: true }15 ))16 .then(() => db.collection('appdata')17 .createIndex(18 { lobbyId: 1, name: 1 },19 { unique: true }20 ));21}22const destroyAppdata = (db, lobbyId, name = null) => {23 var query;24 if (name) {25 debug('Destroy app %s for %s', name, lobbyId);26 query = { lobbyId: lobbyId, name: name };27 }28 else {29 debug('Destroy all apps for %s', lobbyId);30 query = { lobbyId: lobbyId };31 }32 return db.collection('appdata')33 .deleteOne(query)34 .then(cmdRes => (cmdRes.result.ok == 1 && cmdRes.result.n == 1) ?35 Promise.resolve() : Promise.reject("Not deleted"));36}37const commitAppdata = (db, appdata) =>38 db.collection('appdata').updateOne(39 { lobbyId: appdata.lobbyId },40 { $set: appdata },41 { upsert: true }42 );43const getByLobbyIdAndName = (db, lobbyId, name) =>44 db.collection('appdata').findOne({45 lobbyId: lobbyId,46 name: name47 })48const getList = (db, lobbyId) => {49 return db.collection('appdata')50 .find({ lobbyId: lobbyId })51 .toArray();52}53const getMap = (db, lobbyId) => getList(db, lobbyId)54 .then(appdataList => appdataList.reduce(55 (accum, curr) => {56 accum[curr.name] = curr;57 return accum;58 }, {}))59const getExclusive = (db, lobbyId) =>60 db.collection('appdata')61 .findOne({ lobbyId: lobbyId, exclusive: true })62 .then(app =>63 app ? Promise.resolve(app) : Promise.reject("No exclusive map")64 );65module.exports = {66 dbReset,67 getByLobbyIdAndName,68 getList,69 getMap,70 getExclusive,71 commitAppdata,72 destroyAppdata...

Full Screen

Full Screen

shapeMeasurements.js

Source:shapeMeasurements.js Github

copy

Full Screen

...38 const output = JSON.parse(JSON.stringify(placeToStoreValueTemporarily));39 placeToStoreValueTemporarily = null;40 return output;41}42export function getExclusive(measurements) {43 mockConsole.mock(callbacks);44 Perf.printExclusive(measurements);45 mockConsole.restore();46 const output = JSON.parse(JSON.stringify(placeToStoreValueTemporarily));47 placeToStoreValueTemporarily = null;48 return output;49}50export default {51 getWasted,52 getDOM,53 getInclusive,54 getExclusive,...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1const playwright = require('playwright');2(async () => {3 const browser = await playwright.chromium.launch();4 const context = await browser.newContext();5 const page = await context.newPage();6 const exclusive = await page._delegate.getExclusive();7 console.log(exclusive);8 await browser.close();9})();

Full Screen

Using AI Code Generation

copy

Full Screen

1const { getExclusive } = require('playwright/lib/server/chromium/crBrowser');2const browser = await chromium.launch();3const context = await browser.newContext();4const page = await context.newPage();5const exclusive = await getExclusive(page);6const exclusivePage = await exclusive.newPage();

Full Screen

Using AI Code Generation

copy

Full Screen

1const { getExclusive } = require('playwright/lib/server/chromium/crBrowser');2const { chromium } = require('playwright');3(async () => {4 const browser = await chromium.launch();5 const page = await browser.newPage();6 const exclusive = await getExclusive(page);7 const exclusivePage = await exclusive.newPage();8 await browser.close();9})();10const { test, expect } = require('@playwright/test');11const { getExclusive } = require('playwright/lib/server/chromium/crBrowser');12test.describe('Exclusive context', () => {13 test('should open an exclusive browser context', async ({ browser }) => {14 const exclusive = await getExclusive(browser);15 const exclusivePage = await exclusive.newPage();16 const title = await exclusivePage.title();17 expect(title).toBe('Google');18 });19});20const { test, expect } = require('@playwright/test');21const { getExclusive } = require('playwright/lib/server/chromium/crBrowser');22test.describe('Exclusive context', () => {23 test('should open an exclusive browser context', async ({ browser }) => {24 const exclusive = await getExclusive(browser);25 const exclusivePage = await exclusive.newPage();26 const title = await exclusivePage.title();27 expect(title).toBe('Google');28 });29});30module.exports = {31 {32 use: {33 },34 },35};36{37 "scripts": {38 },39 "devDependencies": {40 }41}42const { test, expect } = require('@

Full Screen

Using AI Code Generation

copy

Full Screen

1const { getExclusive } = require('playwright/lib/server/browserType');2(async () => {3 const browser = await getExclusive('chromium');4 const context = await browser.newContext();5 const page = await context.newPage();6 await page.screenshot({ path: 'example.png' });7 await browser.close();8})();9 at BrowserType.getExclusive (node_modules/playwright/lib/server/browserType.js:66:22)10 at Object.<anonymous> (test.js:3:22)11 at Module._compile (internal/modules/cjs/loader.js:1137:30)12 at Object.Module._extensions..js (internal/modules/cjs/loader.js:1157:10)13 at Module.load (internal/modules/cjs/loader.js:986:32)14 at Function.Module._load (internal/modules/cjs/loader.js:879:14)15 at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)

Full Screen

Using AI Code Generation

copy

Full Screen

1const { getExclusive } = require('playwright');2const { chromium } = require('playwright');3(async () => {4 const browser = await getExclusive(chromium);5 const context = await browser.newContext();6 const page = await context.newPage();7 await browser.close();8})();9### getExclusive(browserType: BrowserType, options?: Options): Promise\<Browser\>10[Apache 2.0](LICENSE)

Full Screen

Using AI Code Generation

copy

Full Screen

1const { getExclusive } = require('playwright/lib/server/browserType');2const { chromium } = require('playwright');3(async () => {4 const browser1 = await chromium.launch();5 const browser2 = await chromium.launch();6 const page1 = await getExclusive(browser1, 'Page');7 const page2 = await getExclusive(browser2, 'Page');8 await page1.setContent(`<button>Click me</button>`);9 await page2.setContent(`<button>Click me</button>`);10 await Promise.all([11 page1.waitForEvent('dialog'),12 page2.waitForEvent('dialog'),13 page1.click('button'),14 ]);15 await browser1.close();16 await browser2.close();17})();18const browser = await chromium.launch();19const page1 = await browser.newPage();20const page2 = await browser.newPage();21const page = await browser.newPage();22const context1 = await page.context();23const context2 = await page.context();

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