From 61f7b59d1e470ef01435b13cacd4758a6f72c786 Mon Sep 17 00:00:00 2001 From: Ando Date: Mon, 29 Apr 2024 17:40:28 +0300 Subject: [PATCH 1/2] docs: update docs, don't use hard tabs on readme (#28) * feat: add prettierrc json config and update git ignore * feat: add import map * docs: use contributing and code of conduct * feat: install selenium webdriver and std assert on deps * feat: configure deno.json use fmt, lint, compiler options * chore: delete tsconfig * feat: create browser engines, types, constants * feat: create gh workflows to auto create pull request * feat: add edge to browser enginer and remove utils folder from import maps * feat: clean arch and update deno fmt, lint * feat: re-arch pkg to be drowser and clean file, dir * feat: handle drowser json config and validate url * feat: handle new promise execution for driver and return as value driver from selenium * fix: handle return promise in driver in get url * chore: clean lib and move basic example to examples folder * feat: create pkg types and handle builder quit outside the pkg for now * feat: create service type, obj to set extra services for pkg and create types * docs: update readme docs * docs: update readme docs * docs: update readme docs * feat: set version to v0.1.0 * fix: for todo specify builder.quit to be able to quit internaly * docs: update docs, don't use hard tabs on readme --- README.md | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index c1fcabc..089a08d 100644 --- a/README.md +++ b/README.md @@ -13,10 +13,11 @@ A easy way to implement and write Selenium with TypeScript using Deno 🦕 ## Features - - Easy handling on driver side web browser to isolate each test ✅ - - Possibility to export test case as PDF 🛠️ - - Possibility to export test case as Log 🛠️ - - Usage of AI for analyse the percentage of success and failed test 🛠️ + +- Easy handling on driver side web browser to isolate each test ✅ +- Possibility to export test case as PDF 🛠️ +- Possibility to export test case as Log 🛠️ +- Usage of AI for analyse the percentage of success and failed test 🛠️ ## Configuration @@ -57,20 +58,20 @@ import type { TDrowserBuilder } from "drowser" const testTitle = (builder: TDrowserBuilder) => { builder.getTitle().then((t) => { - try { - const tVal = "Todo App" - assert.assertEquals(t, tVal) - } catch (err) { - console.log(err) - } - }) + try { + const tVal = "Todo App" + assert.assertEquals(t, tVal) + } catch (err) { + console.log(err) + } + }) } driver({ browserType: "chrome" }).then(({ builder }) => { - testTitle(builder) - builder.quit() + testTitle(builder) + builder.quit() }).catch((err) => { - console.log(err) + console.log(err) }) ``` From 7358fdf75b30aa89e8197910e54b95be6a886af5 Mon Sep 17 00:00:00 2001 From: Ando Date: Mon, 29 Apr 2024 20:08:30 +0300 Subject: [PATCH 2/2] feat: migrate export log , pdf to be at drowser json config (#29) * feat: add prettierrc json config and update git ignore * feat: add import map * docs: use contributing and code of conduct * feat: install selenium webdriver and std assert on deps * feat: configure deno.json use fmt, lint, compiler options * chore: delete tsconfig * feat: create browser engines, types, constants * feat: create gh workflows to auto create pull request * feat: add edge to browser enginer and remove utils folder from import maps * feat: clean arch and update deno fmt, lint * feat: re-arch pkg to be drowser and clean file, dir * feat: handle drowser json config and validate url * feat: handle new promise execution for driver and return as value driver from selenium * fix: handle return promise in driver in get url * chore: clean lib and move basic example to examples folder * feat: create pkg types and handle builder quit outside the pkg for now * feat: create service type, obj to set extra services for pkg and create types * docs: update readme docs * docs: update readme docs * docs: update readme docs * feat: set version to v0.1.0 * fix: for todo specify builder.quit to be able to quit internaly * docs: update docs, don't use hard tabs on readme * feat: migrate export log , pdf to be at drowser json config --- driver.ts | 14 +++++++++----- drowser.json | 4 +++- types.ts | 4 ++-- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/driver.ts b/driver.ts index 01ad62d..51362ad 100644 --- a/driver.ts +++ b/driver.ts @@ -12,16 +12,16 @@ import { driverBrowser, driverBrowserType } from '@pkg/constants.ts' import { generatedLog, generatedPdf } from '@pkg/export.ts' const driver = async ( - { browserType, exportPdf = false, exportLog = true }: TDriverParams, + { browserType }: TDriverParams, ): Promise => { - console.log({ browserType, exportPdf, exportLog }) - const data: TData = { url: '', results: [], log: [] } + const configPath = join(Deno.cwd(), 'drowser.json') try { - const configPath = join(Deno.cwd(), 'drowser.json') await Deno.stat(configPath) - const { url }: TConfigJSON = JSON.parse(await Deno.readTextFile(configPath)) + const { url }: TConfigJSON = JSON.parse( + await Deno.readTextFile(configPath), + ) if (isEmpty(url) || !isValidHttpUrl({ url })) { throw new Error( @@ -68,6 +68,10 @@ const driver = async ( .catch((err) => reject(err)) // .finally(() => builder.quit()) //TODO: Need to find a solution to handle this internaly .finally(() => { + const { exportLog, exportPdf }: TConfigJSON = JSON.parse( + Deno.readTextFileSync(configPath), + ) + if (exportLog) generatedLog() if (exportPdf) generatedPdf() }) diff --git a/drowser.json b/drowser.json index 1d3fb83..a0ff5de 100644 --- a/drowser.json +++ b/drowser.json @@ -1,3 +1,5 @@ { - "url": "http://localhost:3000" + "url": "http://localhost:3000", + "exportPdf": false, + "exportLog": false } diff --git a/types.ts b/types.ts index 238d25c..81cb0d4 100644 --- a/types.ts +++ b/types.ts @@ -2,14 +2,14 @@ import type { ThenableWebDriver } from '@pkg/deps.ts' export type TDriverParams = { browserType: TDriverBrowser - exportPdf?: boolean - exportLog?: boolean } export type TDriverBrowser = 'chrome' | 'firefox' | 'safari' | 'edge' export type TConfigJSON = { url: string + exportPdf: boolean + exportLog: boolean } export type TData = {