From 8fec652e36954f3fb8e4a161be55a4ae0afc040b Mon Sep 17 00:00:00 2001 From: Ando Date: Sat, 28 Dec 2024 10:56:54 +0300 Subject: [PATCH] docs: update code usage --- src/pages/docs/drowser.mdx | 71 +++++++++++++++----------------------- 1 file changed, 28 insertions(+), 43 deletions(-) diff --git a/src/pages/docs/drowser.mdx b/src/pages/docs/drowser.mdx index 6a24cf4..4ca114e 100644 --- a/src/pages/docs/drowser.mdx +++ b/src/pages/docs/drowser.mdx @@ -20,9 +20,9 @@ Create a drowser.json in root directory and define some configuration like this: } ``` -## Deno 2 +## Installation -Install npm dependecies on `node_modules` with this command: +Install dependencies using Deno with this command: ```sh deno install --allow-scripts @@ -37,47 +37,32 @@ With this test we only test this sample code inside a Chrome ,Firefox but create ```ts import { driver } from 'https://deno.land/x/drowser@v0.1.6/mod.ts' -driver({ browser: 'chrome' }) - .then(({ service }) => { - service.cases = [ - { - name: 'Verify Failed Title', - fn: async ({ builder, assert }) => { - const title = await builder.getTitle() - assert.assertEquals(title, 'Drowsers') - } - }, - { - name: 'Verify Title', - fn: async ({ builder, assert }) => { - const title = await builder.getTitle() - assert.assertEquals(title, 'Drowser') - } - } - ] - }) - .catch((error) => console.log(error)) - -driver({ browser: 'firefox' }) - .then(({ service }) => { - service.cases = [ - { - name: 'Verify Failed Title', - fn: async ({ builder, assert }) => { - const title = await builder.getTitle() - assert.assertEquals(title, 'Drowsers') - } - }, - { - name: 'Verify Title', - fn: async ({ builder, assert }) => { - const title = await builder.getTitle() - assert.assertEquals(title, 'Drowser') - } - } - ] - }) - .catch((error) => console.log(error)) +const testCases = [ + { + name: 'Verify Failed Title', + fn: async ({ builder, assert }) => { + const title = await builder.getTitle() + assert.assertEquals(title, 'Drowsers') + } + }, + { + name: 'Verify Title', + fn: async ({ builder, assert }) => { + const title = await builder.getTitle() + assert.assertEquals(title, 'Drowser') + } + } +] + +;[('chrome', 'firefox')].forEach((browser) => { + driver({ browser }) + .then(({ service }) => { + service.cases = testCases + }) + .catch((error) => { + console.error(`Error in ${browser} tests:`, error) + }) +}) ``` ## Report