Skip to content

Commit

Permalink
Breaking: Replace chrome connector with puppeteer
Browse files Browse the repository at this point in the history
Fix #2255
  • Loading branch information
molant committed May 17, 2019
1 parent bbce68a commit 086a4a7
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 16 deletions.
4 changes: 2 additions & 2 deletions packages/connector-puppeteer/src/connector.ts
Expand Up @@ -337,8 +337,8 @@ export default class PuppeteerConnector implements IConnector {
const options = {
headers,
// we sync the ignore SSL error options with `request`. This is neeeded for local https tests
rejectUnauthorized: this._options.ignoreHTTPSErrors,
strictSSL: this._options.ignoreHTTPSErrors
rejectUnauthorized: !this._options.ignoreHTTPSErrors,
strictSSL: !this._options.ignoreHTTPSErrors
};

const request = new Requester(options);
Expand Down
5 changes: 3 additions & 2 deletions packages/utils-tests-helpers/package.json
@@ -1,12 +1,13 @@
{
"dependencies": {
"@hint/connector-chrome": "^4.0.1",
"@hint/connector-jsdom": "^4.0.1",
"@hint/connector-local": "^3.0.1",
"@hint/connector-puppeteer": "^1.0.0",
"@hint/utils": "^2.0.0",
"@hint/utils-create-server": "^3.1.1",
"ava": "^1.4.1",
"hint": "^5.0.1"
"hint": "^5.0.1",
"is-ci": "^2.0.0"
},
"description": "hint tests helpers",
"devDependencies": {
Expand Down
35 changes: 27 additions & 8 deletions packages/utils-tests-helpers/src/connectors.ts
@@ -1,26 +1,45 @@
import * as isCI from 'is-ci';

/*
* This interface needs to be imported in order
* to generate the definition of this file.
*/
import { IConnectorConstructor } from 'hint';

import ChromeConnector from '@hint/connector-chrome';
import PuppeteerConnector from '@hint/connector-puppeteer';
import JSDOMConnector from '@hint/connector-jsdom';

/** The IDs of the available connectors to test. */
export const ids = [
'chrome',
const ids = [
'jsdom'
];

/** The Constructors of the available connectors to test. */
export const connectors: { ctor: IConnectorConstructor; name: string }[] = [
{
ctor: ChromeConnector,
name: 'chrome'
},
const connectors: { ctor: IConnectorConstructor; name: string }[] = [
{
ctor: JSDOMConnector,
name: 'jsdom'
}
];

/**
* Azure Pipelines has an old version of Chrome that does not
* work with puppeteer correctly. This is needed to ignore
* the connector until they update.
*/
if (!(isCI && process.platform === 'win32')) {
/**
* Need to `unshift` instead of `push` because otherwise some
* tests with `jsdom` could time out (i.e.: `no-disallowed-headers`)
*/
ids.unshift('puppeteer');
connectors.unshift({
ctor: PuppeteerConnector,
name: 'puppeteer'
});
}

export {
connectors,
ids
};
8 changes: 6 additions & 2 deletions packages/utils-tests-helpers/src/hint-runner.ts
Expand Up @@ -109,8 +109,12 @@ const createConfig = (id: string, connector: string, opts?: any): Configuration
parsers: determineParsers(opts && opts.parsers)
};

// Allow us to use our self-signed cert for testing.
config.connector.options = { ignoreHTTPSErrors: true };
// Defaults needed to run the tests
config.connector.options = {
detached: true, // This only applies to `puppeteer`
ignoreHTTPSErrors: true,
waitUntil: 'networkidle0' // This only applies to `puppeteer`
};

return Configuration.fromConfig(config);
};
Expand Down
2 changes: 1 addition & 1 deletion packages/utils-tests-helpers/tsconfig.json
Expand Up @@ -14,9 +14,9 @@
"tests/**/*.ts"
],
"references": [
{ "path": "../connector-chrome" },
{ "path": "../connector-jsdom" },
{ "path": "../connector-local" },
{ "path": "../connector-puppeteer" },
{ "path": "../hint" },
{ "path": "../utils" },
{ "path": "../utils-create-server" }
Expand Down
7 changes: 6 additions & 1 deletion yarn.lock
Expand Up @@ -737,7 +737,12 @@
resolved "https://registry.yarnpkg.com/@types/lockfile/-/lockfile-1.0.1.tgz#434a3455e89843312f01976e010c60f1bcbd56f7"
integrity sha512-65WZedEm4AnOsBDdsapJJG42MhROu3n4aSSiu87JXF/pSdlubxZxp3S1yz3kTfkJ2KBPud4CpjoHVAptOm9Zmw==

"@types/lodash@^4.14.123", "@types/lodash@^4.14.129":
"@types/lodash@^4.14.123":
version "4.14.125"
resolved "https://registry.yarnpkg.com/@types/lodash/-/lodash-4.14.125.tgz#b5fa71f3080a2136ba2702c390ffe528ec1e3980"
integrity sha512-s29jU/MIOSddXeji0TSZPJjf0agnfJYpWeKlr79BbtXlfuYamGVyCNQA2IRi5/plaQiNSxMmNGdvFbdtMMJ3nw==

"@types/lodash@^4.14.129":
version "4.14.129"
resolved "https://registry.yarnpkg.com/@types/lodash/-/lodash-4.14.129.tgz#9aaca391db126802482655c48dd79a814488202f"
integrity sha512-oYaV0eSlnOacOr7i4X1FFdH8ttSlb57gu3I9MuStIv2CYkISEY84dNHYsC3bF6sNH7qYcu1BtVrCtQ8Q4KPTfQ==
Expand Down

0 comments on commit 086a4a7

Please sign in to comment.