Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: set export log to default a true and remove from json config #42

Merged
merged 55 commits into from
May 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
5648477
feat: add prettierrc json config and update git ignore
Apr 23, 2024
3169584
feat: add import map
Apr 23, 2024
9be90ab
docs: use contributing and code of conduct
Apr 23, 2024
300c428
Merge branches 'develop' and 'main' of github.com:iamando/easy-seleni…
Apr 23, 2024
add9dc3
feat: install selenium webdriver and std assert on deps
Apr 24, 2024
0904873
feat: configure deno.json use fmt, lint, compiler options
Apr 24, 2024
89cf6e5
fix: resolve confilct
Apr 24, 2024
4e6d6f8
chore: delete tsconfig
Apr 24, 2024
8d614c5
feat: create browser engines, types, constants
Apr 24, 2024
a780080
feat: create gh workflows to auto create pull request
Apr 24, 2024
cdf85ff
feat: add edge to browser enginer and remove utils folder from import…
Apr 24, 2024
331245c
fix: resolve conflict
Apr 24, 2024
67e5ec6
feat: clean arch and update deno fmt, lint
Apr 25, 2024
7998103
fix: resolve conflict
Apr 25, 2024
3c34cec
feat: re-arch pkg to be drowser and clean file, dir
Apr 26, 2024
0ed52a7
fix: resolve conflict
Apr 26, 2024
84ce755
feat: handle drowser json config and validate url
Apr 26, 2024
4fdd228
fix: resolve conflict
Apr 26, 2024
6094a57
feat: handle new promise execution for driver and return as value dri…
Apr 27, 2024
25c4511
fix: resolve conflict
Apr 27, 2024
a9a6f10
Merge branches 'develop' and 'main' of github.com:iamando/drowser int…
Apr 27, 2024
cc55998
fix: handle return promise in driver in get url
Apr 27, 2024
3fb97e5
chore: clean lib and move basic example to examples folder
Apr 27, 2024
f929d44
Merge branch 'main' into develop
Apr 27, 2024
152373f
feat: create pkg types and handle builder quit outside the pkg for now
Apr 27, 2024
3b11ba6
Merge branch 'develop' of github.com:iamando/drowser into develop
Apr 27, 2024
4484866
fix: resolve conflict
Apr 27, 2024
a1a36a0
feat: create service type, obj to set extra services for pkg and crea…
Apr 28, 2024
f2bc8a5
fix: resolve conflicts
Apr 28, 2024
2cb6858
docs: update readme docs
Apr 28, 2024
9433c29
docs: update readme docs
Apr 28, 2024
ac6a244
fix: resolve some conflict on readme docs
Apr 28, 2024
cfe27b5
docs: update readme docs
Apr 28, 2024
47fbc86
feat: set version to v0.1.0
Apr 28, 2024
c5d40a5
fix: for todo specify builder.quit to be able to quit internaly
Apr 28, 2024
cba42cd
docs: update docs, don't use hard tabs on readme
Apr 29, 2024
99a505d
fix: resolve conflicts
Apr 29, 2024
b49348a
feat: migrate export log , pdf to be at drowser json config
Apr 29, 2024
a9e8546
feat: update return type of driver and check on finally to generate l…
Apr 30, 2024
1321880
fix: resolve conflicts
Apr 30, 2024
8b8de66
Merge branches 'develop' and 'main' of github.com:iamando/drowser int…
Apr 30, 2024
e7f5983
feat: handle builder inside driver core and get only json of test or …
May 2, 2024
abc6f70
chore: rename lib to be mod
May 2, 2024
0a3c6a3
chore: rename lib to be mod
May 2, 2024
3611f8a
feat: install kya and show loading spinner while running test and fai…
May 2, 2024
fb89244
feat: handle selenium webdriver errors
May 2, 2024
176fee6
fix: resolve conflicts
May 2, 2024
64d3f4b
feat: handle log on each level of test
May 2, 2024
75cce37
feat: get results from each test to be in array of results with test …
May 2, 2024
6cce55b
fix: resolve conflicts
May 2, 2024
413cc0b
feat: use chrome driver only on basic examples
May 2, 2024
09c2953
feat: create log file and write each row of test passed or failed
May 2, 2024
cf68456
fix: resolve some conflicts
May 2, 2024
a741b2d
fix: fix some types with assert function and use global func for gett…
May 3, 2024
c3e9558
feat: set export log to default a true and remove from json config
May 3, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 18 additions & 13 deletions driver.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { assert, Builder, isEmpty, join, Kia } from '@deps'
import type {
TAssertFunction,
TConfigJSON,
TData,
TDriverParams,
Expand Down Expand Up @@ -73,10 +74,19 @@ const driver = async (
reject(seleniumExceptions[err.name])
})
.finally(() => {
const { exportLog, exportPdf }: TConfigJSON = JSON.parse(
const { exportPdf }: TConfigJSON = JSON.parse(
Deno.readTextFileSync(configPath),
)
const methodPromises: Promise<void>[] = []
const result = (
{ name, status }: { name: string; status: 'Passed' | 'Failed' },
) => {
return {
name,
status,
timestamp: new Date(),
}
}

service.cases.forEach((c: TDrowserServiceCase) => {
if (typeof c === 'object') {
Expand All @@ -87,19 +97,14 @@ const driver = async (
const methodPromise = method.call(builder)

methodPromise.then((v: unknown) => {
assert[c.test](v, c.except)
data.results.push({
name: c.method,
status: 'Passed',
timestamp: new Date(),
})
const assertFunction = assert[c.test] as TAssertFunction
assertFunction(v, c.except)
data.results.push(result({ name: c.method, status: 'Passed' }))
})
.catch(() => {
data.results.push({
name: c.method,
status: 'Failed',
timestamp: new Date(),
})
data.results.push(
result({ name: c.method, status: 'Failed' }),
)
})

methodPromises.push(methodPromise)
Expand All @@ -113,8 +118,8 @@ const driver = async (

Promise.all(methodPromises)
.then(() => {
if (exportLog) exportGeneratedLog({ results: data.results })
if (exportPdf) exportGeneratedPdf({ results: data.results })
exportGeneratedLog({ results: data.results })
})
.catch((error) => {
console.error('An error occurred while processing promises:', error)
Expand Down
3 changes: 1 addition & 2 deletions drowser.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{
"url": "http://localhost:3000",
"exportPdf": false,
"exportLog": true
"exportPdf": false
}
2 changes: 1 addition & 1 deletion examples/basic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ driver({ browserType: 'chrome' }).then(({ service }) => {
service.cases = [
{
method: 'getTitle',
test: 'assert',
test: 'assertEquals',
except: 'Todo App',
},
]
Expand Down
15 changes: 10 additions & 5 deletions types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ export type TDriverBrowser = 'chrome' | 'firefox' | 'safari' | 'edge'
export type TConfigJSON = {
url: string
exportPdf: boolean
exportLog: boolean
}

export type TData = {
Expand All @@ -24,10 +23,6 @@ export type TData = {
}>
}

export type TAssertError = {
name: string
}

export type TDrowserThenableWebDriver = ThenableWebDriver

export type TDrowserBuilder = Omit<
Expand All @@ -48,3 +43,13 @@ export type TDrowserService = {
export type TDrowserDriverResponse = {
service: TDrowserService
}

export type TAssertFunction = (
actual: unknown,
expected: unknown,
msg?: string,
) => void

export type TAssertError = {
name: string
}
Loading