Skip to content

Commit

Permalink
refactor: cleaned up from last refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
arctic-hen7 committed Jan 26, 2022
1 parent 14b4b46 commit 33f439c
Show file tree
Hide file tree
Showing 11 changed files with 18 additions and 17 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
members = [
"packages/*",
"examples/*",
"tests/*",
"website",
# We have the CLI subcrates as workspace members so we can actively develop on them
# They also can't be a workspace until nested workspaces are supported
Expand Down
4 changes: 2 additions & 2 deletions docs/0.3.x/en-US/testing/checkpoints.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ This, and many similar problems, are easily solvable using one of Perseus' most

Note that checkpoints will never be reached if your app is not run with `perseus test`. If you use `--no-run` and then execute the server binary manually, be sure to provide the `PERSEUS_TESTING=true` environment variable.

You can wait for a Perseus checkpoint to be reached like so (taken from [here](https://github.com/arctic-hen7/perseus/blob/main/examples/basic/tests/main.rs)):
You can wait for a Perseus checkpoint to be reached like so (taken from [here](https://github.com/arctic-hen7/perseus/blob/main/tests/basic/tests/main.rs)):

```rust
{{#include ../../../../examples/basic/tests/main.rs}}
{{#include ../../../../tests/basic/tests/main.rs}}
```

Note in particular the use of the `wait_for_checkpoint!` macro, which accepts three arguments:
Expand Down
4 changes: 2 additions & 2 deletions docs/0.3.x/en-US/testing/fantoccini-basics.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

Now that you know a bit more about how Perseus tests work, it's time to go through how to write them!

Remember, you're controlling an actual browser, so you basically have everything available to you that a user can do (mostly). You can even take screenshots! All this is achieved with [Fantoccini](https://github.com/jonhoo/fantoccini), which you can learn more about [here](https://docs.rs/fantoccini). For now though, here's a quick tutorial on the basics, using [this](https://github.com/arctic-hen7/perseus/blob/main/examples/basic/tests/main.rs) example:
Remember, you're controlling an actual browser, so you basically have everything available to you that a user can do (mostly). You can even take screenshots! All this is achieved with [Fantoccini](https://github.com/jonhoo/fantoccini), which you can learn more about [here](https://docs.rs/fantoccini). For now though, here's a quick tutorial on the basics, using [this](https://github.com/arctic-hen7/perseus/blob/main/tests/basic/tests/main.rs) example:

```rust
{{#include ../../../../examples/basic/tests/main.rs}}
{{#include ../../../../tests/basic/tests/main.rs}}
```

## Going to a Page
Expand Down
4 changes: 2 additions & 2 deletions docs/0.3.x/en-US/testing/intro.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ It's that last type that Perseus is particularly concerned with, because that's

In terms of unit tests, these can be done for normal logic (that doesn't render something) with Rust's own testing system. Any integration tests, as well as unit tests that do render things, should be done with [`wasm-bindgen-test`](https://rustwasm.github.io/wasm-bindgen/wasm-bindgen-test/index.html). This module provides a custom _test harness_ macro (alternative to `#[test]`) that spins up a _headless browser_ (browser without a GUI) that can be used to render your code. Note that this should be done for testing Sycamore components, and not for testing integrated Perseus systems.

When you want to test logic flows in your app, like the possibilities of how a user will interact with a login form, the best way is to use end-to-end testing, which Perseus supports with a custom test harness macro that can be used like so (taken from [here](https://github.com/arctic-hen7/perseus/blob/main/examples/basic/tests/main.rs)):
When you want to test logic flows in your app, like the possibilities of how a user will interact with a login form, the best way is to use end-to-end testing, which Perseus supports with a custom test harness macro that can be used like so (taken from [here](https://github.com/arctic-hen7/perseus/blob/main/tests/basic/tests/main.rs)):

```rust
{{#include ../../../../examples/basic/tests/main.rs}}
{{#include ../../../../tests/basic/tests/main.rs}}
```

The first thing to note is the module that this test imports. It's called [Fantoccini](https://github.com/jonhoo/fantoccini), and it basically lets you control a web browser with code. We'll get to exactly how this works soon. This test goes to <http://localhost:8080> (where a Perseus app is hosted) and then clicks a link on it and makes sure that it's been taken to the correct new URL.
Expand Down
4 changes: 2 additions & 2 deletions docs/next/en-US/reference/testing/checkpoints.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ This, and many similar problems, are easily solvable using one of Perseus' most

Note that checkpoints will never be reached if your app is not run with `perseus test`. If you use `--no-run` and then execute the server binary manually, be sure to provide the `PERSEUS_TESTING=true` environment variable.

You can wait for a Perseus checkpoint to be reached like so (taken from [here](https://github.com/arctic-hen7/perseus/blob/main/examples/basic/tests/main.rs)):
You can wait for a Perseus checkpoint to be reached like so (taken from [here](https://github.com/arctic-hen7/perseus/blob/main/tests/basic/tests/main.rs)):

```rust
{{#include ../../../../examples/basic/tests/main.rs}}
{{#include ../../../../tests/basic/tests/main.rs}}
```

Note in particular the use of the `wait_for_checkpoint!` macro, which accepts three arguments:
Expand Down
4 changes: 2 additions & 2 deletions docs/next/en-US/reference/testing/fantoccini-basics.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

Now that you know a bit more about how Perseus tests work, it's time to go through how to write them!

Remember, you're controlling an actual browser, so you basically have everything available to you that a user can do (mostly). You can even take screenshots! All this is achieved with [Fantoccini](https://github.com/jonhoo/fantoccini), which you can learn more about [here](https://docs.rs/fantoccini). For now though, here's a quick tutorial on the basics, using [this](https://github.com/arctic-hen7/perseus/blob/main/examples/basic/tests/main.rs) example:
Remember, you're controlling an actual browser, so you basically have everything available to you that a user can do (mostly). You can even take screenshots! All this is achieved with [Fantoccini](https://github.com/jonhoo/fantoccini), which you can learn more about [here](https://docs.rs/fantoccini). For now though, here's a quick tutorial on the basics, using [this](https://github.com/arctic-hen7/perseus/blob/main/tests/basic/tests/main.rs) example:

```rust
{{#include ../../../../examples/basic/tests/main.rs}}
{{#include ../../../../tests/basic/tests/main.rs}}
```

## Going to a Page
Expand Down
4 changes: 2 additions & 2 deletions docs/next/en-US/reference/testing/intro.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ It's that last type that Perseus is particularly concerned with, because that's

In terms of unit tests, these can be done for normal logic (that doesn't render something) with Rust's own testing system. Any integration tests, as well as unit tests that do render things, should be done with [`wasm-bindgen-test`](https://rustwasm.github.io/wasm-bindgen/wasm-bindgen-test/index.html). This module provides a custom _test harness_ macro (alternative to `#[test]`) that spins up a _headless browser_ (browser without a GUI) that can be used to render your code. Note that this should be done for testing Sycamore components, and not for testing integrated Perseus systems.

When you want to test logic flows in your app, like the possibilities of how a user will interact with a login form, the best way is to use end-to-end testing, which Perseus supports with a custom test harness macro that can be used like so (taken from [here](https://github.com/arctic-hen7/perseus/blob/main/examples/basic/tests/main.rs)):
When you want to test logic flows in your app, like the possibilities of how a user will interact with a login form, the best way is to use end-to-end testing, which Perseus supports with a custom test harness macro that can be used like so (taken from [here](https://github.com/arctic-hen7/perseus/blob/main/tests/basic/tests/main.rs)):

```rust
{{#include ../../../../examples/basic/tests/main.rs}}
{{#include ../../../../tests/basic/tests/main.rs}}
```

The first thing to note is the module that this test imports. It's called [Fantoccini](https://github.com/jonhoo/fantoccini), and it basically lets you control a web browser with code. We'll get to exactly how this works soon. This test goes to <http://localhost:8080> (where a Perseus app is hosted) and then clicks a link on it and makes sure that it's been taken to the correct new URL.
Expand Down
2 changes: 1 addition & 1 deletion examples/i18n/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "perseus-test-i18n"
name = "perseus-example-i18n"
version = "0.1.0"
edition = "2018"

Expand Down
4 changes: 2 additions & 2 deletions examples/plugins/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "perseus-test-plugins"
version = "0.3.2-beta.8"
name = "perseus-example-plugins"
version = "0.3.2"
edition = "2018"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
Expand Down
2 changes: 1 addition & 1 deletion examples/rx_state/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "perseus-test-rx-state"
name = "perseus-example-rx-state"
version = "0.3.2"
edition = "2018"

Expand Down
2 changes: 1 addition & 1 deletion examples/showcase/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "perseus-test-showcase"
name = "perseus-example-showcase"
version = "0.1.0"
edition = "2018"

Expand Down

0 comments on commit 33f439c

Please sign in to comment.