diff --git a/.eslintrc.json b/.eslintrc.json new file mode 100644 index 0000000..fb4a101 --- /dev/null +++ b/.eslintrc.json @@ -0,0 +1,22 @@ +{ + "env": { + "browser": true, + "es2021": true + }, + "extends": [ + "eslint:recommended", + "plugin:@typescript-eslint/recommended" + ], + "overrides": [ + ], + "parser": "@typescript-eslint/parser", + "parserOptions": { + "ecmaVersion": "latest", + "sourceType": "module" + }, + "plugins": [ + "@typescript-eslint" + ], + "rules": { + } +} diff --git a/.prettierrc b/.prettierrc index 4ddba9a..59b8de9 100644 --- a/.prettierrc +++ b/.prettierrc @@ -1,5 +1,6 @@ { - "printWidth": 120, - "trailingComma": "all", - "singleQuote": true + "semi": true, + "singleQuote": true, + "tabWidth": 2, + "useTabs": false } \ No newline at end of file diff --git a/package.json b/package.json index 2f53843..30798e1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@gbisogno/cdp-utils", - "version": "1.3.10", + "version": "1.4.0", "description": "A set of utilities/wrapper for Test Automation or Performance testing on top of Chrome DevTools Protocol", "repository": { "type": "git", @@ -11,8 +11,9 @@ "scripts": { "build": "tsc", "test": "jest", - "format": "prettier --write \"src/**/*.ts\" \"src/**/*.js\"", - "lint": "tslint -p tsconfig.json", + "format": "prettier --write src/**/*.ts", + "prebuild": "npm run lint && npm run format", + "lint": "eslint --fix ./src/**/*.ts", "doc": "compodoc -p --tsconfig tsconfig.json -s" }, "keywords": [ @@ -33,14 +34,17 @@ "@types/chrome-remote-interface": "^0.31.4", "@types/jest": "^27.5.2", "@types/selenium-webdriver": "^4.0.16", + "@typescript-eslint/eslint-plugin": "^5.42.0", + "@typescript-eslint/parser": "^5.42.0", "chromedriver": "latest", "endpoint-utils": "^1.0.2", + "eslint": "^8.27.0", + "eslint-config-prettier": "^8.5.0", + "eslint-plugin-prettier": "^4.2.1", "jest": "^27.4.5", "prettier": "^2.4.1", "selenium-webdriver": "^4.0.0", "ts-jest": "^27.1.2", - "tslint": "^6.1.3", - "tslint-config-prettier": "^1.18.0", "typed-query-selector": "^2.6.1", "typescript": "^4.4.4" }, diff --git a/src/__tests__/browser.test.ts b/src/__tests__/browser.test.ts index 4b8c944..d3e1a61 100644 --- a/src/__tests__/browser.test.ts +++ b/src/__tests__/browser.test.ts @@ -1,45 +1,43 @@ -import { Builder } from "selenium-webdriver"; -import * as chrome from "selenium-webdriver/chrome"; +import { Builder } from 'selenium-webdriver'; +import * as chrome from 'selenium-webdriver/chrome'; import 'chromedriver'; import { CDPClient } from '../cdpClient'; import { GooglePage } from '../pages/googlePage'; import { Browser } from '../browser'; -import { cdpConfig } from "../config/cdpConfig"; +import { cdpConfig } from '../config/cdpConfig'; import { getFreePort } from 'endpoint-utils'; jest.setTimeout(cdpConfig.maxTimeout); test('Test Browser', async () => { + const port = await getFreePort(); + const options = new chrome.Options(); - const port = await getFreePort(); - const options = new chrome.Options(); + options.addArguments(`--remote-debugging-port=${port}`); - options.addArguments(`--remote-debugging-port=${port}`); + const driver = await new Builder() + .forBrowser('chrome') + .setChromeOptions(options) + .build(); - const driver = await new Builder().forBrowser('chrome') - .setChromeOptions(options) - .build(); + const googlePage = new GooglePage(driver); - const googlePage = new GooglePage(driver); + const cdpClient = new CDPClient(); + await cdpClient.init(port); - const cdpClient = new CDPClient(); - await cdpClient.init(port); - - const browser = new Browser(cdpClient); + const browser = new Browser(cdpClient); - await driver.get("https://www.google.com"); + await driver.get('https://www.google.com'); - const url = await driver.getCurrentUrl(); - await browser.grantPermissions({ - origin: url, - permissions: ['clipboardReadWrite', 'clipboardSanitizedWrite'], - }); + const url = await driver.getCurrentUrl(); + await browser.grantPermissions({ + origin: url, + permissions: ['clipboardReadWrite', 'clipboardSanitizedWrite'], + }); - await googlePage.searchFromClipboard(); + await googlePage.searchFromClipboard(); - await cdpClient.close(); + await cdpClient.close(); - await driver.quit(); + await driver.quit(); }); - - diff --git a/src/__tests__/lighthouse.tests.ts b/src/__tests__/lighthouse.tests.ts index d92710b..4e78635 100644 --- a/src/__tests__/lighthouse.tests.ts +++ b/src/__tests__/lighthouse.tests.ts @@ -1,46 +1,45 @@ -import { Builder } from "selenium-webdriver"; -import * as chrome from "selenium-webdriver/chrome"; +import { Builder } from 'selenium-webdriver'; +import * as chrome from 'selenium-webdriver/chrome'; import 'chromedriver'; import { GooglePage } from '../pages/googlePage'; import { Lighthouse } from '../lighthouse'; import { getFreePort } from 'endpoint-utils'; import * as DesktopConfig from 'lighthouse/lighthouse-core/config/desktop-config.js'; -import { cdpConfig } from "../config/cdpConfig"; +import { cdpConfig } from '../config/cdpConfig'; jest.setTimeout(cdpConfig.maxTimeout); test('Test Lighthouse', async () => { + const port = await getFreePort(); + const options = new chrome.Options(); - const port = await getFreePort(); - const options = new chrome.Options(); + options.addArguments(`--remote-debugging-port=${port}`); + options.excludeSwitches('--enable-logging'); - options.addArguments(`--remote-debugging-port=${port}`); - options.excludeSwitches('--enable-logging'); + const driver = await new Builder() + .forBrowser('chrome') + .setChromeOptions(options) + .build(); - const driver = await new Builder().forBrowser('chrome') - .setChromeOptions(options) - .build(); + const googlePage = new GooglePage(driver); - const googlePage = new GooglePage(driver); + const lighthouse = new Lighthouse(port); - const lighthouse = new Lighthouse(port); + await lighthouse.initWorkFlow('Google search', DesktopConfig.settings); - await lighthouse.initWorkFlow('Google search', DesktopConfig.settings); + await lighthouse.navigate('https://www.google.com'); - await lighthouse.navigate("https://www.google.com"); + await lighthouse.startTrace('search operation'); - await lighthouse.startTrace('search operation'); + await googlePage.search('test'); - await googlePage.search('test'); + const res = await lighthouse.stopTrace(); - const res = await lighthouse.stopTrace(); + await driver.quit(); - await driver.quit(); - - await lighthouse.generateFlowReport('lighthouse.html'); - - res.forEach((step) => { - expect(step.lhr.categories.performance.score).toBeGreaterThanOrEqual(0.8); - }) + await lighthouse.generateFlowReport('lighthouse.html'); + res.forEach((step) => { + expect(step.lhr.categories.performance.score).toBeGreaterThanOrEqual(0.8); + }); }); diff --git a/src/__tests__/network.test.ts b/src/__tests__/network.test.ts index 1dd584d..180d125 100644 --- a/src/__tests__/network.test.ts +++ b/src/__tests__/network.test.ts @@ -1,45 +1,43 @@ -import { Builder } from "selenium-webdriver"; -import * as chrome from "selenium-webdriver/chrome"; +import { Builder } from 'selenium-webdriver'; +import * as chrome from 'selenium-webdriver/chrome'; import 'chromedriver'; import { GooglePage } from '../pages/googlePage'; import { Network } from '../network'; import { CDPClient } from '../cdpClient'; import { getFreePort } from 'endpoint-utils'; -import { Har } from "har-format"; -import { cdpConfig } from "../config/cdpConfig"; +import { Har } from 'har-format'; +import { cdpConfig } from '../config/cdpConfig'; jest.setTimeout(cdpConfig.maxTimeout); test('Test Network', async () => { + const port = await getFreePort(); + const options = new chrome.Options(); - const port = await getFreePort(); - const options = new chrome.Options(); + options.addArguments(`--remote-debugging-port=${port}`); - options.addArguments(`--remote-debugging-port=${port}`); + const driver = await new Builder() + .forBrowser('chrome') + .setChromeOptions(options) + .build(); - const driver = await new Builder().forBrowser('chrome') - .setChromeOptions(options) - .build(); + const googlePage = new GooglePage(driver); - const googlePage = new GooglePage(driver); + const cdpClient = new CDPClient(); + await cdpClient.init(port); - const cdpClient = new CDPClient(); - await cdpClient.init(port); + const network = new Network(cdpClient, 'network.har'); - const network = new Network(cdpClient, 'network.har'); + await network.startTrace(); - await network.startTrace(); + await driver.get('https://www.google.com'); - await driver.get("https://www.google.com"); + await googlePage.search('test'); - await googlePage.search('test'); + const networkResults: Har = await network.stopTrace(); + expect(networkResults.log.entries.length).toBeGreaterThan(0); - const networkResults: Har = await network.stopTrace(); - expect(networkResults.log.entries.length).toBeGreaterThan(0); - - await cdpClient.close(); - - await driver.quit() + await cdpClient.close(); + await driver.quit(); }); - diff --git a/src/__tests__/performance.test.ts b/src/__tests__/performance.test.ts index 4a2c93d..0d10c88 100644 --- a/src/__tests__/performance.test.ts +++ b/src/__tests__/performance.test.ts @@ -1,46 +1,48 @@ -import { Builder } from "selenium-webdriver"; -import * as chrome from "selenium-webdriver/chrome"; +import { Builder } from 'selenium-webdriver'; +import * as chrome from 'selenium-webdriver/chrome'; import 'chromedriver'; import { GooglePage } from '../pages/googlePage'; import { Performance } from '../performance'; import { CDPClient } from '../cdpClient'; import { getFreePort } from 'endpoint-utils'; -import { cdpConfig } from "../config/cdpConfig"; +import { cdpConfig } from '../config/cdpConfig'; jest.setTimeout(cdpConfig.maxTimeout); test('Test Performance', async () => { + const port = await getFreePort(); + const options = new chrome.Options(); - const port = await getFreePort(); - const options = new chrome.Options(); + options.addArguments(`--remote-debugging-port=${port}`); - options.addArguments(`--remote-debugging-port=${port}`); + const driver = await new Builder() + .forBrowser('chrome') + .setChromeOptions(options) + .build(); - const driver = await new Builder().forBrowser('chrome') - .setChromeOptions(options) - .build(); + const googlePage = new GooglePage(driver); - const googlePage = new GooglePage(driver); + const cdpClient = new CDPClient(); + await cdpClient.init(port); - const cdpClient = new CDPClient(); - await cdpClient.init(port); + const performance = new Performance( + cdpClient, + 'startTrace.json', + 'endTrace.json' + ); - const performance = new Performance(cdpClient, 'startTrace.json', 'endTrace.json'); + const perfStartResults = await performance.startTrace(); - const perfStartResults = await performance.startTrace(); + await driver.get('https://www.google.com'); - await driver.get("https://www.google.com"); + await googlePage.search('test'); - await googlePage.search('test'); + const perfEndResults = await performance.stopTrace(); - const perfEndResults = await performance.stopTrace(); + expect(perfStartResults.metrics.length).toBeGreaterThan(0); + expect(perfEndResults.metrics.length).toBeGreaterThan(0); - expect(perfStartResults.metrics.length).toBeGreaterThan(0); - expect(perfEndResults.metrics.length).toBeGreaterThan(0); - - await cdpClient.close(); - - await driver.quit() + await cdpClient.close(); + await driver.quit(); }); - diff --git a/src/__tests__/runtime.test.ts b/src/__tests__/runtime.test.ts index 09884b4..5307d00 100644 --- a/src/__tests__/runtime.test.ts +++ b/src/__tests__/runtime.test.ts @@ -1,53 +1,51 @@ -import { Builder } from "selenium-webdriver"; -import * as chrome from "selenium-webdriver/chrome"; +import { Builder } from 'selenium-webdriver'; +import * as chrome from 'selenium-webdriver/chrome'; import 'chromedriver'; import { GooglePage } from '../pages/googlePage'; import { Runtime } from '../runtime'; import { CDPClient } from '../cdpClient'; import { getFreePort } from 'endpoint-utils'; -import { cdpConfig } from "../config/cdpConfig"; +import { cdpConfig } from '../config/cdpConfig'; jest.setTimeout(cdpConfig.maxTimeout); test('Test Runtime', async () => { + const port = await getFreePort(); + const options = new chrome.Options(); - const port = await getFreePort(); - const options = new chrome.Options(); + options.addArguments(`--remote-debugging-port=${port}`); - options.addArguments(`--remote-debugging-port=${port}`); + const driver = await new Builder() + .forBrowser('chrome') + .setChromeOptions(options) + .build(); - const driver = await new Builder().forBrowser('chrome') - .setChromeOptions(options) - .build(); + const googlePage = new GooglePage(driver); - const googlePage = new GooglePage(driver); + const cdpClient = new CDPClient(); + await cdpClient.init(port); - const cdpClient = new CDPClient(); - await cdpClient.init(port); + const runtime = new Runtime(cdpClient, 'console.json'); - const runtime = new Runtime(cdpClient, 'console.json'); + await runtime.startTrace(); - await runtime.startTrace(); + await driver.get('https://www.google.com'); - await driver.get("https://www.google.com"); + await driver.executeScript(() => { + console.error('test error message'); + console.warn('test warning message'); + console.log('test log message'); + }); - await driver.executeScript(() => { - console.error('test error message'); - console.warn('test warning message'); - console.log('test log message'); - }); + await googlePage.search('test'); - await googlePage.search('test'); + const consoleResults = await runtime.stopTrace(); - const consoleResults = await runtime.stopTrace(); + expect(consoleResults.find((x) => x.type === 'error')).toBeDefined(); + expect(consoleResults.find((x) => x.type === 'warning')).toBeDefined(); + expect(consoleResults.find((x) => x.type === 'log')).toBeDefined(); - expect(consoleResults.find(x => x.type === 'error')).toBeDefined(); - expect(consoleResults.find(x => x.type === 'warning')).toBeDefined(); - expect(consoleResults.find(x => x.type === 'log')).toBeDefined(); - - await cdpClient.close(); - - await driver.quit() + await cdpClient.close(); + await driver.quit(); }); - diff --git a/src/__tests__/tracing.test.ts b/src/__tests__/tracing.test.ts index 26c9e58..e8b8744 100644 --- a/src/__tests__/tracing.test.ts +++ b/src/__tests__/tracing.test.ts @@ -1,45 +1,43 @@ -import { Builder } from "selenium-webdriver"; -import * as chrome from "selenium-webdriver/chrome"; +import { Builder } from 'selenium-webdriver'; +import * as chrome from 'selenium-webdriver/chrome'; import 'chromedriver'; import { CDPClient } from '../cdpClient'; import { GooglePage } from '../pages/googlePage'; import { Tracing } from '../tracing'; -import { cdpConfig } from "../config/cdpConfig"; +import { cdpConfig } from '../config/cdpConfig'; import { getFreePort } from 'endpoint-utils'; jest.setTimeout(cdpConfig.maxTimeout); test('Test Tracing', async () => { + const port = await getFreePort(); + const options = new chrome.Options(); - const port = await getFreePort(); - const options = new chrome.Options(); + options.addArguments(`--remote-debugging-port=${port}`); - options.addArguments(`--remote-debugging-port=${port}`); + const driver = await new Builder() + .forBrowser('chrome') + .setChromeOptions(options) + .build(); - const driver = await new Builder().forBrowser('chrome') - .setChromeOptions(options) - .build(); + const googlePage = new GooglePage(driver); - const googlePage = new GooglePage(driver); + const cdpClient = new CDPClient(); + await cdpClient.init(port); - const cdpClient = new CDPClient(); - await cdpClient.init(port); - - const tracing = new Tracing(cdpClient, 'tracing.json'); + const tracing = new Tracing(cdpClient, 'tracing.json'); - await driver.get("https://www.google.com"); + await driver.get('https://www.google.com'); - await tracing.startTrace(); + await tracing.startTrace(); - await googlePage.search('test'); + await googlePage.search('test'); - const tracingResults = await tracing.stopTrace(); + const tracingResults = await tracing.stopTrace(); - expect(tracingResults.length).toBeGreaterThan(0); + expect(tracingResults.length).toBeGreaterThan(0); - await cdpClient.close(); + await cdpClient.close(); - await driver.quit(); + await driver.quit(); }); - - diff --git a/src/browser.ts b/src/browser.ts index e85eba2..9b72961 100644 --- a/src/browser.ts +++ b/src/browser.ts @@ -1,27 +1,32 @@ -import { logger } from "./utils/logger"; +import { logger } from './utils/logger'; import { Protocol } from 'devtools-protocol'; import { CDPClient } from './cdpClient'; import CDP from 'chrome-remote-interface'; import { BrowserOperations } from './browserOperations'; export class Browser extends BrowserOperations { - private _client: CDP.Client; + private _client: CDP.Client; - constructor(cdpClient: CDPClient) { - super(); - this._client = cdpClient.get(); - } + constructor(cdpClient: CDPClient) { + super(); + this._client = cdpClient.get(); + } - /** - * Grant browser permissions - * @returns response metrics - */ - public async grantPermissions(grantPermissionRequest: Protocol.Browser.GrantPermissionsRequest): Promise { - try { - await this._client.send('Browser.grantPermissions', grantPermissionRequest); - } catch (e) { - logger.error(e); - throw e; - } + /** + * Grant browser permissions + * @returns response metrics + */ + public async grantPermissions( + grantPermissionRequest: Protocol.Browser.GrantPermissionsRequest + ): Promise { + try { + await this._client.send( + 'Browser.grantPermissions', + grantPermissionRequest + ); + } catch (e) { + logger.error(e); + throw e; } -} \ No newline at end of file + } +} diff --git a/src/browserOperations.ts b/src/browserOperations.ts index 3be1f55..be2c93a 100644 --- a/src/browserOperations.ts +++ b/src/browserOperations.ts @@ -1,5 +1,7 @@ -import Protocol from "devtools-protocol"; +import Protocol from 'devtools-protocol'; export abstract class BrowserOperations { - abstract grantPermissions(grantPermissionRequest: Protocol.Browser.GrantPermissionsRequest): Promise; -} \ No newline at end of file + abstract grantPermissions( + grantPermissionRequest: Protocol.Browser.GrantPermissionsRequest + ): Promise; +} diff --git a/src/cdpClient.ts b/src/cdpClient.ts index 58123e5..f887c44 100644 --- a/src/cdpClient.ts +++ b/src/cdpClient.ts @@ -1,48 +1,48 @@ -import CDP from "chrome-remote-interface"; -import { logger } from "./utils/logger"; +import CDP from 'chrome-remote-interface'; +import { logger } from './utils/logger'; export class CDPClient { - private _client: CDP.Client; + private _client: CDP.Client; - /** - * Initializes the CDP client connection - * @port a given port number - * @returns CDP Client - */ - public async init(port: number): Promise { - try { - if (!this._client) { - this._client = await CDP({ port }); + /** + * Initializes the CDP client connection + * @port a given port number + * @returns CDP Client + */ + public async init(port: number): Promise { + try { + if (!this._client) { + this._client = await CDP({ port }); - logger.info('CDP Session created using port: ' + port); - } - } catch (e) { - logger.error('CDP Session not created! due to: ' + e); - throw e; - } + logger.info('CDP Session created using port: ' + port); + } + } catch (e) { + logger.error('CDP Session not created! due to: ' + e); + throw e; } + } - /** - * Gets the CDP client connection - */ - public get(): CDP.Client { - if (!this._client) throw new Error('CDP Session not initialized!'); - return this._client; - } + /** + * Gets the CDP client connection + */ + public get(): CDP.Client { + if (!this._client) throw new Error('CDP Session not initialized!'); + return this._client; + } - /** - * Closes the CDP client connection - */ - public async close(): Promise { - try { - if (this._client) { - await this._client.close(); - } - } catch (e) { - logger.error('CDP Session not closed! due to: ' + e); - throw e; - } finally { - this._client = undefined; - } + /** + * Closes the CDP client connection + */ + public async close(): Promise { + try { + if (this._client) { + await this._client.close(); + } + } catch (e) { + logger.error('CDP Session not closed! due to: ' + e); + throw e; + } finally { + this._client = undefined; } -} \ No newline at end of file + } +} diff --git a/src/config/cdpConfig.ts b/src/config/cdpConfig.ts index e806e4d..508a301 100644 --- a/src/config/cdpConfig.ts +++ b/src/config/cdpConfig.ts @@ -2,11 +2,13 @@ import Protocol from 'devtools-protocol'; import * as fs from 'fs'; export interface CDPConfig { - tracing: Protocol.Tracing.StartRequest; - cdpPort: number; - maxTimeout: number; + tracing: Protocol.Tracing.StartRequest; + cdpPort: number; + maxTimeout: number; } -export const cdpConfig: CDPConfig = JSON.parse(fs.readFileSync('config/cdp.config.json', { encoding: 'utf-8', flag: 'r' }).toString()); - - +export const cdpConfig: CDPConfig = JSON.parse( + fs + .readFileSync('config/cdp.config.json', { encoding: 'utf-8', flag: 'r' }) + .toString() +); diff --git a/src/geoLocation.ts b/src/geoLocation.ts index 13ceaf3..87128a9 100644 --- a/src/geoLocation.ts +++ b/src/geoLocation.ts @@ -1,25 +1,25 @@ import * as CDP from 'chrome-remote-interface'; import { CDPClient } from './cdpClient'; -import { Coordinates } from './interfaces/coordinates' -import { logger } from "./utils/logger"; +import { Coordinates } from './interfaces/coordinates'; +import { logger } from './utils/logger'; export class GeoLocation { - private _client: CDP.Client; + private _client: CDP.Client; - constructor(cdpClient: CDPClient) { - this._client = cdpClient.get(); + constructor(cdpClient: CDPClient) { + this._client = cdpClient.get(); + } + /** + * Emulates a geo location by coordinates + * @param coordinates given coordinates + */ + async emulateGeoLocation(coordinates: Coordinates): Promise { + try { + await this._client.Emulation.setGeolocationOverride(coordinates); + } catch (e) { + logger.error(e); + throw e; } - /** - * Emulates a geo location by coordinates - * @param coordinates given coordinates - */ - async emulateGeoLocation(coordinates: Coordinates): Promise { - try { - await this._client.Emulation.setGeolocationOverride(coordinates); - } catch (e) { - logger.error(e); - throw e; - } - }; -} \ No newline at end of file + } +} diff --git a/src/index.ts b/src/index.ts index 78ed519..bf9d173 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,4 +1,3 @@ - export { Network } from './network'; export { Performance } from './performance'; export { Lighthouse } from './lighthouse'; @@ -7,4 +6,4 @@ export { Runtime } from './runtime'; export { GeoLocation } from './geoLocation'; export { Browser } from './browser'; export { CDPClient } from './cdpClient'; -export { cdpConfig } from './config/cdpConfig'; \ No newline at end of file +export { cdpConfig } from './config/cdpConfig'; diff --git a/src/interfaces/coordinates.ts b/src/interfaces/coordinates.ts index 53a7ba4..fa4eecc 100644 --- a/src/interfaces/coordinates.ts +++ b/src/interfaces/coordinates.ts @@ -1,5 +1,5 @@ export interface Coordinates { - latitude: number, - longitude: number, - accuracy: number, -}; \ No newline at end of file + latitude: number; + longitude: number; + accuracy: number; +} diff --git a/src/interfaces/networkConditions.ts b/src/interfaces/networkConditions.ts index 699c8c5..24be30d 100644 --- a/src/interfaces/networkConditions.ts +++ b/src/interfaces/networkConditions.ts @@ -1,11 +1,11 @@ export interface NetworkConditions { - // Whether chrome should simulate - // the absence of connectivity - offline: boolean, - // Simulated download speed (bytes/s) - downloadThroughput: number, - // Simulated upload speed (bytes/s) - uploadThroughput: number, - // Simulated latency (ms) - latency: number -} \ No newline at end of file + // Whether chrome should simulate + // the absence of connectivity + offline: boolean; + // Simulated download speed (bytes/s) + downloadThroughput: number; + // Simulated upload speed (bytes/s) + uploadThroughput: number; + // Simulated latency (ms) + latency: number; +} diff --git a/src/lighthouse.ts b/src/lighthouse.ts index 0361054..f7c1762 100644 --- a/src/lighthouse.ts +++ b/src/lighthouse.ts @@ -1,96 +1,106 @@ -import { TraceOperations } from "./traceOperations"; +import { TraceOperations } from './traceOperations'; import { startFlow } from 'lighthouse/lighthouse-core/fraggle-rock/api'; -import { RunnerResult } from 'lighthouse/types/externs' +import { RunnerResult } from 'lighthouse/types/externs'; import * as fs from 'fs'; -import puppeteer from "puppeteer"; +import puppeteer from 'puppeteer'; import axios from 'axios'; export class Lighthouse extends TraceOperations { - private _flow: any; - private _report: any; - private _port: number; - private _browser: puppeteer.Browser | undefined; + private _flow: any; + private _report: any; + private _port: number; + private _browser: puppeteer.Browser | undefined; - constructor(port: number) { - super(); - this._port = port; - } + constructor(port: number) { + super(); + this._port = port; + } + + /** + * Initializes a lighthouse workflow + * + * @param name workflow name + * @param config lighthouse configuration + * @param viewPort (optional) view port settings + */ + public async initWorkFlow( + name: string, + config: any, + viewPort?: puppeteer.Viewport + ) { /** - * Initializes a lighthouse workflow - * - * @param name workflow name - * @param config lighthouse configuration - * @param viewPort (optional) view port settings + * NOTE: this is a temporary solution to allow itegrating Selenium or any other test framework with lighthouse without opening a new tab in the browser. + * + * See related issues: + * https://github.com/GoogleChrome/lighthouse/issues/3837 + * https://github.com/GoogleChrome/lighthouse/issues/11313 */ + const req = await axios.get( + `http://${'localhost'}:${this._port}/json/version` + ); + this._browser = await puppeteer.connect({ + browserWSEndpoint: req.data.webSocketDebuggerUrl, + }); - public async initWorkFlow(name: string, config: any, viewPort?: puppeteer.Viewport) { - /** - * NOTE: this is a temporary solution to allow itegrating Selenium or any other test framework with lighthouse without opening a new tab in the browser. - * - * See related issues: - * https://github.com/GoogleChrome/lighthouse/issues/3837 - * https://github.com/GoogleChrome/lighthouse/issues/11313 - */ - const req = await axios.get(`http://${'localhost'}:${this._port}/json/version`); - this._browser = await puppeteer.connect({ - browserWSEndpoint: req.data.webSocketDebuggerUrl, - }); - - const pages = await this._browser.pages(); + const pages = await this._browser.pages(); - if (viewPort) { - await pages[0].setViewport(viewPort); - } - - this._flow = await startFlow(pages[0], { - name, configContext: { - settingsOverrides: config - } - }); + if (viewPort) { + await pages[0].setViewport(viewPort); } - /** - * Starts the trace wrapping startTimespan from lighthouse - * @param stepName - */ - public async startTrace(stepName?: string): Promise { - await this._flow.startTimespan({ stepName }); - } + this._flow = await startFlow(pages[0], { + name, + configContext: { + settingsOverrides: config, + }, + }); + } - /** - * Navigates to a url using lighthouse - * @param url url to navigate - * @param stepOptions { stepName?: string } - */ - public async navigate(url: string, stepOptions?: { stepName?: string }): Promise { - await this._flow.navigate(url, stepOptions); - } + /** + * Starts the trace wrapping startTimespan from lighthouse + * @param stepName + */ + public async startTrace(stepName?: string): Promise { + await this._flow.startTimespan({ stepName }); + } - /** - * Stop tracing wrapping endTimespan from lighthouse and return lighthouse flow report - * @returns LH Runner results - */ - public async stopTrace(): Promise { - await this._flow.endTimespan(); - const results = await this._flow.createFlowResult(); - return results.steps; - } + /** + * Navigates to a url using lighthouse + * @param url url to navigate + * @param stepOptions { stepName?: string } + */ + public async navigate( + url: string, + stepOptions?: { stepName?: string } + ): Promise { + await this._flow.navigate(url, stepOptions); + } - /** - * Generates the flow report - * @param fileName name of the report file - */ - public async generateFlowReport(fileName: string): Promise { - this._report = await this._flow.generateReport(); - fs.writeFileSync(fileName, this._report); - } + /** + * Stop tracing wrapping endTimespan from lighthouse and return lighthouse flow report + * @returns LH Runner results + */ + public async stopTrace(): Promise { + await this._flow.endTimespan(); + const results = await this._flow.createFlowResult(); + return results.steps; + } - /** - * Takes a snapshot of the current status of the page - * @param stepName name of the step - */ - public async snapshot(stepName?: string): Promise { - await this._flow.snapshot({ stepName }); - } -} \ No newline at end of file + /** + * Generates the flow report + * @param fileName name of the report file + */ + public async generateFlowReport(fileName: string): Promise { + this._report = await this._flow.generateReport(); + fs.writeFileSync(fileName, this._report); + } + + /** + * Takes a snapshot of the current status of the page + * @param stepName name of the step + */ + public async snapshot(stepName?: string): Promise { + await this._flow.snapshot({ stepName }); + } +} diff --git a/src/network.ts b/src/network.ts index f75845f..1fd1b90 100644 --- a/src/network.ts +++ b/src/network.ts @@ -1,7 +1,7 @@ import * as fs from 'fs'; import { harFromMessages } from 'chrome-har'; -import { TraceOperations } from './traceOperations' -import { logger } from "./utils/logger"; +import { TraceOperations } from './traceOperations'; +import { logger } from './utils/logger'; import { NetworkConditions } from './interfaces/networkConditions'; import { Har } from 'har-format'; import { CDPClient } from './cdpClient'; @@ -9,130 +9,137 @@ import CDP from 'chrome-remote-interface'; // event types to observe const observe = [ - 'Page.loadEventFired', - 'Page.domContentEventFired', - 'Page.frameStartedLoading', - 'Page.frameAttached', - 'Network.requestWillBeSent', - 'Network.requestServedFromCache', - 'Network.dataReceived', - 'Network.responseReceived', - 'Network.resourceChangedPriority', - 'Network.loadingFinished', - 'Network.loadingFailed', - 'Network.requestFinished' + 'Page.loadEventFired', + 'Page.domContentEventFired', + 'Page.frameStartedLoading', + 'Page.frameAttached', + 'Network.requestWillBeSent', + 'Network.requestServedFromCache', + 'Network.dataReceived', + 'Network.responseReceived', + 'Network.resourceChangedPriority', + 'Network.loadingFinished', + 'Network.loadingFailed', + 'Network.requestFinished', ]; export const NETWORK_PRESETS = { - 'GPRS': { - 'offline': false, - 'downloadThroughput': 50 * 1024 / 8, - 'uploadThroughput': 20 * 1024 / 8, - 'latency': 500 - }, - 'Regular2G': { - 'offline': false, - 'downloadThroughput': 250 * 1024 / 8, - 'uploadThroughput': 50 * 1024 / 8, - 'latency': 300 - }, - 'Good2G': { - 'offline': false, - 'downloadThroughput': 450 * 1024 / 8, - 'uploadThroughput': 150 * 1024 / 8, - 'latency': 150 - }, - 'Regular3G': { - 'offline': false, - 'downloadThroughput': 750 * 1024 / 8, - 'uploadThroughput': 250 * 1024 / 8, - 'latency': 100 - }, - 'Good3G': { - 'offline': false, - 'downloadThroughput': 1.5 * 1024 * 1024 / 8, - 'uploadThroughput': 750 * 1024 / 8, - 'latency': 40 - }, - 'Regular4G': { - 'offline': false, - 'downloadThroughput': 4 * 1024 * 1024 / 8, - 'uploadThroughput': 3 * 1024 * 1024 / 8, - 'latency': 20 - }, - 'DSL': { - 'offline': false, - 'downloadThroughput': 2 * 1024 * 1024 / 8, - 'uploadThroughput': 1 * 1024 * 1024 / 8, - 'latency': 5 - }, - 'WiFi': { - 'offline': false, - 'downloadThroughput': 30 * 1024 * 1024 / 8, - 'uploadThroughput': 15 * 1024 * 1024 / 8, - 'latency': 2 - } -} + GPRS: { + offline: false, + downloadThroughput: (50 * 1024) / 8, + uploadThroughput: (20 * 1024) / 8, + latency: 500, + }, + Regular2G: { + offline: false, + downloadThroughput: (250 * 1024) / 8, + uploadThroughput: (50 * 1024) / 8, + latency: 300, + }, + Good2G: { + offline: false, + downloadThroughput: (450 * 1024) / 8, + uploadThroughput: (150 * 1024) / 8, + latency: 150, + }, + Regular3G: { + offline: false, + downloadThroughput: (750 * 1024) / 8, + uploadThroughput: (250 * 1024) / 8, + latency: 100, + }, + Good3G: { + offline: false, + downloadThroughput: (1.5 * 1024 * 1024) / 8, + uploadThroughput: (750 * 1024) / 8, + latency: 40, + }, + Regular4G: { + offline: false, + downloadThroughput: (4 * 1024 * 1024) / 8, + uploadThroughput: (3 * 1024 * 1024) / 8, + latency: 20, + }, + DSL: { + offline: false, + downloadThroughput: (2 * 1024 * 1024) / 8, + uploadThroughput: (1 * 1024 * 1024) / 8, + latency: 5, + }, + WiFi: { + offline: false, + downloadThroughput: (30 * 1024 * 1024) / 8, + uploadThroughput: (15 * 1024 * 1024) / 8, + latency: 2, + }, +}; export class Network extends TraceOperations { - private _traceFileName: string; - protected _events: any[] = []; - private _client: CDP.Client; + private _traceFileName: string; + protected _events: any[] = []; + private _client: CDP.Client; - constructor(cdpClient: CDPClient, traceFileName: string = '') { - super(); - this._client = cdpClient.get(); - this._traceFileName = traceFileName; - } + constructor(cdpClient: CDPClient, traceFileName = '') { + super(); + this._client = cdpClient.get(); + this._traceFileName = traceFileName; + } - /** - * Start tracing using Network and Page domain - */ - public async startTrace(): Promise { - try { - await this._client.send('Page.enable'); - await this._client.send('Network.enable'); - observe.forEach(method => { - this._client.on(method, params => { - this._events.push({ method, params }); - }); - }); - } catch (e) { - logger.error(e); - throw e; - } + /** + * Start tracing using Network and Page domain + */ + public async startTrace(): Promise { + try { + await this._client.send('Page.enable'); + await this._client.send('Network.enable'); + observe.forEach((method) => { + this._client.on(method, (params) => { + this._events.push({ method, params }); + }); + }); + } catch (e) { + logger.error(e); + throw e; } + } - /** - * Stop tracing, writes a trace file if provided - * @returns a promise of har events - */ - public async stopTrace(): Promise { - try { - const har = await harFromMessages(this._events, { includeTextFromResponseBody: true }); - if (this._traceFileName) { - fs.writeFileSync(this._traceFileName, JSON.stringify(har)); - } - return har; - } catch (e) { - logger.error(e); - throw e; - } finally { - await this._client.send('Page.disable'); - await this._client.send('Network.disable'); - } + /** + * Stop tracing, writes a trace file if provided + * @returns a promise of har events + */ + public async stopTrace(): Promise { + try { + const har = await harFromMessages(this._events, { + includeTextFromResponseBody: true, + }); + if (this._traceFileName) { + fs.writeFileSync(this._traceFileName, JSON.stringify(har)); + } + return har; + } catch (e) { + logger.error(e); + throw e; + } finally { + await this._client.send('Page.disable'); + await this._client.send('Network.disable'); } + } - /** - * Emulates network conditions - * @param networkConditions given network conditions - */ - public async emulateNetworkConditions(networkConditions: NetworkConditions): Promise { - try { - await this._client.send('Network.emulateNetworkConditions', networkConditions); - } catch (e) { - logger.error(e); - throw e; - } + /** + * Emulates network conditions + * @param networkConditions given network conditions + */ + public async emulateNetworkConditions( + networkConditions: NetworkConditions + ): Promise { + try { + await this._client.send( + 'Network.emulateNetworkConditions', + networkConditions + ); + } catch (e) { + logger.error(e); + throw e; } + } } diff --git a/src/pages/googlePage.ts b/src/pages/googlePage.ts index 4be75a3..f01fb95 100644 --- a/src/pages/googlePage.ts +++ b/src/pages/googlePage.ts @@ -1,26 +1,36 @@ -import { By, WebDriver, Key } from "selenium-webdriver"; -import { elementLocated } from "selenium-webdriver/lib/until"; -import { cdpConfig } from "../config/cdpConfig"; +import { By, WebDriver, Key } from 'selenium-webdriver'; +import { elementLocated } from 'selenium-webdriver/lib/until'; +import { cdpConfig } from '../config/cdpConfig'; export class GooglePage { - private _driver: WebDriver; - private searchBoxLoc: By = By.name('q'); + private _driver: WebDriver; + private searchBoxLoc: By = By.name('q'); - constructor(driver: WebDriver) { - this._driver = driver; - } + constructor(driver: WebDriver) { + this._driver = driver; + } - async search(criteria: string): Promise { - const el = await this._driver.wait(elementLocated(this.searchBoxLoc), cdpConfig.maxTimeout); - await el.sendKeys(criteria); - await el.sendKeys(Key.RETURN); - } + async search(criteria: string): Promise { + const el = await this._driver.wait( + elementLocated(this.searchBoxLoc), + cdpConfig.maxTimeout + ); + await el.sendKeys(criteria); + await el.sendKeys(Key.RETURN); + } - async searchFromClipboard(): Promise { - const el = await this._driver.wait(elementLocated(this.searchBoxLoc), cdpConfig.maxTimeout); - await el.click(); - await this._driver.executeScript("await navigator.clipboard.writeText('test');"); - const criteria: string = await this._driver.executeScript('return await navigator.clipboard.readText();'); - await this.search(criteria); - } -} \ No newline at end of file + async searchFromClipboard(): Promise { + const el = await this._driver.wait( + elementLocated(this.searchBoxLoc), + cdpConfig.maxTimeout + ); + await el.click(); + await this._driver.executeScript( + "await navigator.clipboard.writeText('test');" + ); + const criteria: string = await this._driver.executeScript( + 'return await navigator.clipboard.readText();' + ); + await this.search(criteria); + } +} diff --git a/src/performance.ts b/src/performance.ts index 7fcb410..49dcf93 100644 --- a/src/performance.ts +++ b/src/performance.ts @@ -1,70 +1,73 @@ -import { TraceOperations } from './traceOperations' -import { logger } from "./utils/logger"; +import { TraceOperations } from './traceOperations'; +import { logger } from './utils/logger'; import { Protocol } from 'devtools-protocol'; import * as fs from 'fs'; import { CDPClient } from './cdpClient'; import CDP from 'chrome-remote-interface'; export class Performance extends TraceOperations { - private _startTraceFileName: string; - private _endTraceFileName: string; - private _client: CDP.Client; + private _startTraceFileName: string; + private _endTraceFileName: string; + private _client: CDP.Client; - constructor(cdpClient: CDPClient, startTraceFileName: string = '', - endTraceFileName: string = '') { - super(); - this._client = cdpClient.get(); - this._startTraceFileName = startTraceFileName; - this._endTraceFileName = endTraceFileName; - } + constructor( + cdpClient: CDPClient, + startTraceFileName = '', + endTraceFileName = '' + ) { + super(); + this._client = cdpClient.get(); + this._startTraceFileName = startTraceFileName; + this._endTraceFileName = endTraceFileName; + } - /** - * Start tracing using Performance domain - */ - public async startTrace(): Promise { - try { - await this._client.send("Performance.enable"); - const metrics = await this.getMetrics(); - if (this._startTraceFileName) { - fs.writeFileSync(this._startTraceFileName, JSON.stringify(metrics)) - } - return metrics; - } catch (e) { - logger.error(e); - throw e; - } + /** + * Start tracing using Performance domain + */ + public async startTrace(): Promise { + try { + await this._client.send('Performance.enable'); + const metrics = await this.getMetrics(); + if (this._startTraceFileName) { + fs.writeFileSync(this._startTraceFileName, JSON.stringify(metrics)); + } + return metrics; + } catch (e) { + logger.error(e); + throw e; } + } - /** - * Stop tracing, writes a trace file if provided - * @returns response metrics - */ - public async stopTrace(): Promise { - try { - const metrics = await this.getMetrics(); - if (this._endTraceFileName) { - fs.writeFileSync(this._endTraceFileName, JSON.stringify(metrics)) - } - return metrics; - } catch (e) { - logger.error(e); - throw e; - } finally { - await this._client.send("Performance.disable"); - } + /** + * Stop tracing, writes a trace file if provided + * @returns response metrics + */ + public async stopTrace(): Promise { + try { + const metrics = await this.getMetrics(); + if (this._endTraceFileName) { + fs.writeFileSync(this._endTraceFileName, JSON.stringify(metrics)); + } + return metrics; + } catch (e) { + logger.error(e); + throw e; + } finally { + await this._client.send('Performance.disable'); } + } - /** - * Retrieves metrics using Performance domain - * @returns response metrics - */ - private async getMetrics(): Promise { - try { - const response = await this._client.send('Performance.getMetrics'); - return response; - } catch (e) { - logger.error(e); - throw e; - } + /** + * Retrieves metrics using Performance domain + * @returns response metrics + */ + private async getMetrics(): Promise { + try { + const response = await this._client.send('Performance.getMetrics'); + return response; + } catch (e) { + logger.error(e); + throw e; } -} \ No newline at end of file + } +} diff --git a/src/runtime.ts b/src/runtime.ts index c01241e..ee9797c 100644 --- a/src/runtime.ts +++ b/src/runtime.ts @@ -1,50 +1,55 @@ -import { logger } from "./utils/logger"; +import { logger } from './utils/logger'; import * as fs from 'fs'; -import { TraceOperations } from "./traceOperations"; +import { TraceOperations } from './traceOperations'; import { Protocol } from 'devtools-protocol'; import { CDPClient } from './cdpClient'; -import CDP from "chrome-remote-interface"; +import CDP from 'chrome-remote-interface'; export class Runtime extends TraceOperations { - private _consoleLogEntries: Protocol.Runtime.ConsoleAPICalledEvent[] = []; - private _traceFileName: string; - private _client: CDP.Client; + private _consoleLogEntries: Protocol.Runtime.ConsoleAPICalledEvent[] = []; + private _traceFileName: string; + private _client: CDP.Client; - constructor(cdpClient: CDPClient, traceFileName: string = '') { - super(); - this._client = cdpClient.get(); - this._traceFileName = traceFileName; - } + constructor(cdpClient: CDPClient, traceFileName = '') { + super(); + this._client = cdpClient.get(); + this._traceFileName = traceFileName; + } - /** - * Start tracing using Runtime domain, captures console messages - */ - public async startTrace(): Promise { - try { - await this._client.send('Runtime.enable'); - this._client['Runtime.consoleAPICalled']((event: Protocol.Runtime.ConsoleAPICalledEvent) => { - this._consoleLogEntries.push(event); - }); - } catch (e) { - logger.error(e); - throw e; + /** + * Start tracing using Runtime domain, captures console messages + */ + public async startTrace(): Promise { + try { + await this._client.send('Runtime.enable'); + this._client['Runtime.consoleAPICalled']( + (event: Protocol.Runtime.ConsoleAPICalledEvent) => { + this._consoleLogEntries.push(event); } + ); + } catch (e) { + logger.error(e); + throw e; } - /** - * Stop tracing, writes a trace file if provided - * @returns console entries - */ - public async stopTrace(): Promise { - try { - if (this._traceFileName) { - fs.writeFileSync(this._traceFileName, JSON.stringify(this._consoleLogEntries)); - } - return this._consoleLogEntries; - } catch (e) { - logger.error(e); - throw e; - } finally { - await this._client.send('Runtime.disable'); - } + } + /** + * Stop tracing, writes a trace file if provided + * @returns console entries + */ + public async stopTrace(): Promise { + try { + if (this._traceFileName) { + fs.writeFileSync( + this._traceFileName, + JSON.stringify(this._consoleLogEntries) + ); + } + return this._consoleLogEntries; + } catch (e) { + logger.error(e); + throw e; + } finally { + await this._client.send('Runtime.disable'); } -} \ No newline at end of file + } +} diff --git a/src/traceOperations.ts b/src/traceOperations.ts index 1589a6c..ae28fe7 100644 --- a/src/traceOperations.ts +++ b/src/traceOperations.ts @@ -1,12 +1,16 @@ -import Protocol from "devtools-protocol"; -import { Har } from "har-format"; -import { RunnerResult } from "lighthouse/types/externs"; +import Protocol from 'devtools-protocol'; +import { Har } from 'har-format'; +import { RunnerResult } from 'lighthouse/types/externs'; export abstract class TraceOperations { - abstract startTrace(stepName?: string): Promise | Promise; - abstract stopTrace(): Promise | Promise - | Promise - | Promise - | Promise - | Promise; -} \ No newline at end of file + abstract startTrace( + stepName?: string + ): Promise | Promise; + abstract stopTrace(): + | Promise + | Promise + | Promise + | Promise + | Promise + | Promise; +} diff --git a/src/tracing.ts b/src/tracing.ts index 227697a..6d180bd 100644 --- a/src/tracing.ts +++ b/src/tracing.ts @@ -1,57 +1,63 @@ import * as fs from 'fs'; import CDP from 'chrome-remote-interface'; -import { TraceOperations } from './traceOperations' -import { logger } from "./utils/logger"; +import { TraceOperations } from './traceOperations'; +import { logger } from './utils/logger'; import { Protocol } from 'devtools-protocol'; import { CDPClient } from './cdpClient'; import { cdpConfig } from './config/cdpConfig'; export class Tracing extends TraceOperations { - private _traceFileName: string; - private _client: CDP.Client; - protected _events: Protocol.Tracing.DataCollectedEvent[] = []; + private _traceFileName: string; + private _client: CDP.Client; + protected _events: Protocol.Tracing.DataCollectedEvent[] = []; - constructor(cdpClient: CDPClient, traceFileName: string = '') { - super(); - this._client = cdpClient.get(); - this._traceFileName = traceFileName; - } + constructor(cdpClient: CDPClient, traceFileName = '') { + super(); + this._client = cdpClient.get(); + this._traceFileName = traceFileName; + } - /** - * Start tracing using Tracing domain, captures events - */ - public async startTrace() { - try { - await this._client.send('Page.enable'); - await this._client.send('Tracing.start', cdpConfig.tracing); - this._client.on('Tracing.dataCollected', ({ value }: Protocol.Tracing.DataCollectedEvent) => { - this._events.push(...value); - }); - } catch (e) { - logger.error(e); - throw e; + /** + * Start tracing using Tracing domain, captures events + */ + public async startTrace() { + try { + await this._client.send('Page.enable'); + await this._client.send('Tracing.start', cdpConfig.tracing); + this._client.on( + 'Tracing.dataCollected', + ({ value }: Protocol.Tracing.DataCollectedEvent) => { + this._events.push(...value); } + ); + } catch (e) { + logger.error(e); + throw e; } + } - /** - * Stop tracing, writes a trace file if provided - * @returns collected events - */ - public async stopTrace(): Promise { - try { - await new Promise((resolve, reject) => { - this._client.on('Tracing.tracingComplete', _ => { - resolve(this._events); - if (this._traceFileName) { - fs.writeFileSync(this._traceFileName, JSON.stringify(this._events, null, 2)) - } - }); - this._client.send('Tracing.end').catch(reject); - }); - return this._events; - } catch (e) { - logger.error(e); - throw e; - } + /** + * Stop tracing, writes a trace file if provided + * @returns collected events + */ + public async stopTrace(): Promise { + try { + await new Promise((resolve, reject) => { + this._client.on('Tracing.tracingComplete', () => { + resolve(this._events); + if (this._traceFileName) { + fs.writeFileSync( + this._traceFileName, + JSON.stringify(this._events, null, 2) + ); + } + }); + this._client.send('Tracing.end').catch(reject); + }); + return this._events; + } catch (e) { + logger.error(e); + throw e; } -} \ No newline at end of file + } +} diff --git a/src/typings.d.ts b/src/typings.d.ts index d6c2db3..1d19500 100644 --- a/src/typings.d.ts +++ b/src/typings.d.ts @@ -1,8 +1,8 @@ -declare module "*.json" { - const value: any; - export default value; +declare module '*.json' { + const value: any; + export default value; } declare module 'chrome-har'; declare module 'endpoint-utils'; -declare module 'tracelib'; \ No newline at end of file +declare module 'tracelib'; diff --git a/src/utils/logger.ts b/src/utils/logger.ts index b5d46a0..080e896 100644 --- a/src/utils/logger.ts +++ b/src/utils/logger.ts @@ -1,7 +1,5 @@ import * as winston from 'winston'; export const logger = winston.createLogger({ - transports: [ - new winston.transports.Console() - ] -}); \ No newline at end of file + transports: [new winston.transports.Console()], +}); diff --git a/tslint.json b/tslint.json deleted file mode 100644 index 71287e5..0000000 --- a/tslint.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "extends": [ - "tslint:recommended", - "tslint-config-prettier" - ] -} \ No newline at end of file