Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it('should complain if an option arg key is of the wrong type', () => {
// $ExpectError string is incompatible with boolean in property `ignoreHTTPSErrors`
puppeteer.connect({ ignoreHTTPSErrors: 'testing...' });
});
it('should preserve Browser type', () => {
it('should complain if passed args', () => {
// $ExpectError no arguments are expected by function type
(defaultArgs('testing...'): Array);
});
});
it('should complain if passed args', () => {
// $ExpectError no arguments are expected by function type
(puppeteer.defaultArgs('testing...'): Array);
});
});
// Helpers
const helpers = require("./helpers");
const IstanbulInstrumenter = require("./istanbul-instrumenter");
// Puppeteer: https://github.com/GoogleChrome/puppeteer/
// takes care of download Chrome and making it available (can do much more :p)
process.env.CHROME_BIN = require("puppeteer").executablePath();
const rawKarmaConfig = {
// base path that will be used to resolve all patterns (e.g. files, exclude)
basePath: "",
// frameworks to use
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
frameworks: ["jasmine", "karma-typescript"],
// list of files / patterns to load in the browser
files: [
{ pattern: helpers.root(helpers.getAngularCliAppConfig().architect.test.options.main) },
{ pattern: helpers.root("src/**/*.ts") },
{ pattern: helpers.root("src/**/*.html") }
],
const _ = require('lodash')
const babelConfig = JSON.parse(
require('fs').readFileSync(`${__dirname}/../.babelrc`)
)
/**
* Headless Chrome setup
*/
const ChromiumRevision = require('puppeteer/package.json').puppeteer
.chromium_revision
const Downloader = require('puppeteer/utils/ChromiumDownloader')
const revisionInfo = Downloader.revisionInfo(
Downloader.currentPlatform(),
ChromiumRevision
)
process.env.CHROMIUM_BIN = revisionInfo.executablePath
/**
* Karma config
*/
module.exports = function(config) {
config.set({
// browsers: ['ChromiumHeadless'],
browsers: ['Chrome'],
const _ = require('lodash')
const babelConfig = JSON.parse(
require('fs').readFileSync(`${__dirname}/../.babelrc`)
)
/**
* Headless Chrome setup
*/
const ChromiumRevision = require('puppeteer/package.json').puppeteer
.chromium_revision
const Downloader = require('puppeteer/utils/ChromiumDownloader')
const revisionInfo = Downloader.revisionInfo(
Downloader.currentPlatform(),
ChromiumRevision
)
process.env.CHROMIUM_BIN = revisionInfo.executablePath
/**
* Karma config
*/
module.exports = function(config) {
config.set({
// browsers: ['ChromiumHeadless'],
browsers: ['Chrome'],
frameworks: ['mocha'],
// this is the entry file for all our tests.
const _ = require('lodash')
const babelConfig = JSON.parse(
require('fs').readFileSync(`${__dirname}/../.babelrc`)
)
/**
* Headless Chrome setup
*/
const ChromiumRevision = require('puppeteer/package.json').puppeteer
.chromium_revision
const Downloader = require('puppeteer/utils/ChromiumDownloader')
const revisionInfo = Downloader.revisionInfo(
Downloader.currentPlatform(),
ChromiumRevision
)
process.env.CHROMIUM_BIN = revisionInfo.executablePath
/**
* Karma config
*/
module.exports = function(config) {
config.set({
// browsers: ['ChromiumHeadless'],
browsers: ['Chrome'],
frameworks: ['mocha'],
async function main() {
const browser = await puppeteer.launch();
const page = await browser.newPage();
// Catch + "forward" hashchange events from page to node puppeteer.
await page.exposeFunction('onHashChange', url => page.emit('hashchange', url));
await page.evaluateOnNewDocument(() => {
addEventListener('hashchange', e => onHashChange(location.href));
});
// Listen for hashchange events in node Puppeteer code.
page.on('hashchange', url => console.log('hashchange event:', new URL(url).hash));
await page.goto(url);
await page.waitForSelector('[data-page="#page1"]'); // wait for view 1 to be "loaded".
await printVisibleView(page);
// as for grpc download (ie darwin-x64-unknown) so we need to transform it a bit
platform,
arch
] = archArg.split('-');
if (platform === 'win32' && arch === 'x64') {
platform = 'win64'
}
if (platform === 'darwin') {
platform = 'mac'
}
const outputPath = "dist/" + (process.argv[3] || `plugin-${archArg}`);
const browserFetcher = Puppeteer.createBrowserFetcher({ platform });
const revision = puppeteerPackageJson.puppeteer.chromium_revision;
browserFetcher
.download(revision, null)
.then(() => {
console.log("Chromium downloaded");
const parts = browserFetcher.revisionInfo(revision).executablePath.split(path.sep);
// based on where puppeteer puts the binaries see BrowserFetcher.revisionInfo()
while (!parts[parts.length - 1].startsWith('chrome-')) {
parts.pop()
}
let execPath = parts.join(path.sep);
child_process.execSync(`cp -RP ${execPath} ${outputPath}`);
if (stderr.trim().length) {
console.error(stderr);
return process.exit(1);
}
return stdout.trim();
};
// This is used in docker to symlink the puppeteer's
// chrome to a place where most other libraries expect it
// (IE: WebDriver) without having to specify it
if (!IS_DOCKER) {
return;
}
const browserFetcher = puppeteer.createBrowserFetcher();
const { executablePath } = browserFetcher.revisionInfo(packageJson.puppeteer.chromium_revision);
(async () => fs.existsSync(CHROME_BINARY_LOCATION) ?
Promise.resolve() :
exec(`ln -s ${executablePath} ${CHROME_BINARY_LOCATION}`)
)();