Skip to content

Commit

Permalink
update to v2
Browse files Browse the repository at this point in the history
  • Loading branch information
vasfvitor committed Nov 14, 2023
1 parent b57f64f commit 356a064
Show file tree
Hide file tree
Showing 9 changed files with 67 additions and 150 deletions.
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
---
sidebar_position: 2
title: Selenium
description: WebDriver Testing
sidebar:
order: 2
---
{/*TODO: REVISE COPY TO V2 */}

import Tabs from '@theme/Tabs'
import TabItem from '@theme/TabItem'
import CommandTabs from '@components/CommandTabs.astro';

# Selenium

:::info Example Application
:::info[Example Application]
This [Selenium] guide expects you to have already gone through the [example Application setup] to follow
step-by-step. The general information may still be helpful otherwise.
:::
Expand Down Expand Up @@ -50,56 +52,23 @@ We have a script that runs [Mocha] as a test framework exposed as the `test` com
that we will be using to run the tests. [Mocha] as the testing framework, [Chai] as the assertion library, and
[`selenium-webdriver`] which is the Node.js [Selenium] package.

<details><summary>Click me if you want to see how to set a project up from scratch</summary>
<details>
<summary>Click me if you want to see how to set a project up from scratch</summary>

If you want to install the dependencies from scratch, just run the following command.

<Tabs groupId="package-manager"
defaultValue="yarn"
values={[
{label: 'npm', value: 'npm'}, {label: 'Yarn', value: 'yarn'},
]}>
<TabItem value="npm">

```shell
npm install mocha chai selenium-webdriver
```

</TabItem>

<TabItem value="yarn">

```shell
yarn add mocha chai selenium-webdriver
```

</TabItem>
</Tabs>
<CommandTabs
npm="npm install mocha chai selenium-webdriver"
yarn="yarn add mocha chai selenium-webdriver"
/>

I suggest also adding a `"test": "mocha"` item in the `package.json` `"scripts"` key so that running Mocha can be called
simply with

<Tabs groupId="package-manager"
defaultValue="yarn"
values={[
{label: 'npm', value: 'npm'}, {label: 'Yarn', value: 'yarn'},
]}>
<TabItem value="npm">

```shell
npm test
```

</TabItem>

<TabItem value="yarn">

```shell
yarn test
```

</TabItem>
</Tabs>
<CommandTabs
npm="npm test"
yarn="yarn test"
/>

</details>

Expand Down Expand Up @@ -204,27 +173,11 @@ more WebDriver related items.

Now that we are all set up with our dependencies and our test script, let's run it!

<Tabs groupId="package-manager"
defaultValue="yarn"
values={[
{label: 'npm', value: 'npm'}, {label: 'Yarn', value: 'yarn'},
]}>
<TabItem value="npm">

```shell
npm test
```

</TabItem>

<TabItem value="yarn">

```shell
yarn test
```

</TabItem>
</Tabs>
<CommandTabs
npm="npm test"
yarn="yarn test"
/>

We should see output the following output:

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
---
sidebar_position: 1
title: Setup Example
description: WebDriver Testing
sidebar:
order: 1
---
<!-- {/*TODO: REVISE COPY TO V2 */} -->

import HelloTauriWebdriver from '@site/static/img/webdriver/hello-tauri-webdriver.png'

# Setup Example

This example application solely focuses on adding WebDriver testing to an already existing project. To have a
project to test in the following two sections, we will set up an extremely minimal Tauri application for use in
our testing. We will not use the Tauri CLI, any frontend dependencies or build steps, and not be bundling the
Expand All @@ -22,6 +24,8 @@ line with `cargo new hello-tauri-webdriver --bin`, which will scaffold a minimal
directory will serve as the working directory for the rest of this guide, so make sure the commands you run are inside
this new `hello-tauri-webdriver/` directory.



## Creating a Minimal Frontend

We will create a minimal HTML file to act as our example application's front end. We will also be using a few things
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
---
sidebar_position: 3
title: WebdriverIO
description: WebDriver Testing
sidebar:
order: 3
---
{/*TODO: REVISE COPY TO V2 */}

import Tabs from '@theme/Tabs'
import TabItem from '@theme/TabItem'

# WebdriverIO
import CommandTabs from '@components/CommandTabs.astro';

:::info Example Application
This [WebdriverIO] guide expects you to have already gone through the [example Application setup] to follow
Expand Down Expand Up @@ -53,58 +54,25 @@ We have a script that runs a [WebdriverIO] config as a test suite exposed as the
dependencies added by the `@wdio/cli` command when we first set it up. In short, these dependencies are for
the most simple setup using a local WebDriver runner, [Mocha] as the test framework, and a simple Spec Reporter.

<details><summary>Click me if you want to see how to set a project up from scratch</summary>
<details>
<summary>Click me if you want to see how to set a project up from scratch</summary>

The CLI is interactive, and you may choose the tools to work with yourself. Note that you will likely diverge from
the rest of the guide, and you need to set up the differences yourself.

Let's add the [WebdriverIO] CLI to this npm project.

<Tabs groupId="package-manager"
defaultValue="yarn"
values={[
{label: 'npm', value: 'npm'}, {label: 'Yarn', value: 'yarn'},
]}>
<TabItem value="npm">

```shell
npm install @wdio/cli
```

</TabItem>

<TabItem value="yarn">

```shell
yarn add @wdio/cli
```

</TabItem>
</Tabs>
<CommandTabs
npm="npm install @wdio/cli"
yarn="yarn add @wdio/cli"
/>

To then run the interactive config command to set up a [WebdriverIO] test suite, you can then run:

<Tabs groupId="package-manager"
defaultValue="yarn"
values={[
{label: 'npm', value: 'npm'}, {label: 'Yarn', value: 'yarn'},
]}>
<TabItem value="npm">

```shell
npx wdio config
```

</TabItem>

<TabItem value="yarn">

```shell
yarn wdio config
```

</TabItem>
</Tabs>
<CommandTabs
npm="npx wdio config"
yarn="yarn wdio config"
/>

</details>

Expand Down Expand Up @@ -212,27 +180,11 @@ covered by the [WebdriverIO API docs].

Now that we are all set up with config and a spec let's run it!

<Tabs groupId="package-manager"
defaultValue="yarn"
values={[
{label: 'npm', value: 'npm'}, {label: 'Yarn', value: 'yarn'},
]}>
<TabItem value="npm">

```shell
npm test
```

</TabItem>

<TabItem value="yarn">

```shell
yarn test
```

</TabItem>
</Tabs>
<CommandTabs
npm="npm test"
yarn="yarn test"
/>

We should see output the following output:

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
# Continuous Integration
---
title: Continuous Integration
description: WebDriver Testing

---
<!-- {/*TODO: REVISE COPY TO V2 */} -->

Utilizing Linux and some programs to create a fake display, it is possible to run [WebDriver] tests with
[`tauri-driver`] on your CI. The following example uses the [WebdriverIO] example we [previously built together] and
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
---
sidebar_position: 1
title: Introduction
description: WebDriver Testing
sidebar:
order: 1
---
<!-- {/*TODO: REVISE COPY TO V2 */} -->

:::caution Currently in pre-alpha
:::caution[Currently in pre-alpha]
Webdriver support for Tauri is still in pre-alpha. Tooling that is dedicated to it, such as [tauri-driver], is still in
active development and may change as necessary over time. Additionally, only Windows and Linux are currently supported.
:::
Expand Down
4 changes: 0 additions & 4 deletions src/content/docs/guides/test/_category_.yml

This file was deleted.

9 changes: 8 additions & 1 deletion src/content/docs/guides/test/mocking.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
# Mocking Tauri APIs
---
title: Mock Tauri APIs
description: Techniques for testing inside and outside the Tauri runtime
sidebar:
order: 1
---
<!-- {/*TODO: REVISE COPY TO V2 */} -->
<!-- {/*TODO: Update links and internal navigation */} -->

When writing your frontend tests, having a "fake" Tauri environment to simulate windows or intercept IPC calls is common, so-called _mocking_.
The [`@tauri-apps/api/mocks`] module provides some helpful tools to make this easier for you:
Expand Down
1 change: 0 additions & 1 deletion src/content/docs/guides/test/webdriver/_category_.yml

This file was deleted.

2 changes: 0 additions & 2 deletions src/content/docs/guides/test/webdriver/example/_category_.yml

This file was deleted.

0 comments on commit 356a064

Please sign in to comment.