github.com/siglens/siglens@v0.0.0-20240328180423-f7ce9ae441ed/ui-test/specs/common.js (about) 1 /* 2 Copyright 2023. 3 4 Licensed under the Apache License, Version 2.0 (the "License"); 5 you may not use this file except in compliance with the License. 6 You may obtain a copy of the License at 7 8 http://www.apache.org/licenses/LICENSE-2.0 9 10 Unless required by applicable law or agreed to in writing, software 11 distributed under the License is distributed on an "AS IS" BASIS, 12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 See the License for the specific language governing permissions and 14 limitations under the License. 15 */ 16 17 /** 18 * siglens 19 * (c) 2022 - All rights reserved. 20 */ 21 22 'use strict'; 23 24 // puppeteer api - https://pptr.dev/api/ 25 26 const puppeteer = require('puppeteer'); 27 const { expect } = require('chai'); 28 const _ = require('lodash'); 29 const globalVariables = _.pick(global, ['browser', 'expect']); 30 31 // puppeteer options 32 const opts = { 33 args: ['--no-sandbox', '--disable-dev-shm-usage', '--disable-setuid-sandbox'], 34 ignoreHTTPSErrors: true, 35 timeout: 30000, 36 headless: true 37 // dumpio: true 38 }; 39 40 // expose variables 41 before (async function () { 42 global.expect = expect; 43 global.browser = await puppeteer.launch(opts); 44 }); 45 46 // close browser and reset global variables 47 after (function () { 48 browser.close(); 49 50 global.browser = globalVariables.browser; 51 global.expect = globalVariables.expect; 52 });