Skip to content

Commit 33f439c

Browse files
committed
refactor: cleaned up from last refactor
1 parent 14b4b46 commit 33f439c

File tree

11 files changed

+18
-17
lines changed

11 files changed

+18
-17
lines changed

Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
members = [
33
"packages/*",
44
"examples/*",
5+
"tests/*",
56
"website",
67
# We have the CLI subcrates as workspace members so we can actively develop on them
78
# They also can't be a workspace until nested workspaces are supported

docs/0.3.x/en-US/testing/checkpoints.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ This, and many similar problems, are easily solvable using one of Perseus' most
66

77
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.
88

9-
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)):
9+
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)):
1010

1111
```rust
12-
{{#include ../../../../examples/basic/tests/main.rs}}
12+
{{#include ../../../../tests/basic/tests/main.rs}}
1313
```
1414

1515
Note in particular the use of the `wait_for_checkpoint!` macro, which accepts three arguments:

docs/0.3.x/en-US/testing/fantoccini-basics.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

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

5-
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:
5+
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:
66

77
```rust
8-
{{#include ../../../../examples/basic/tests/main.rs}}
8+
{{#include ../../../../tests/basic/tests/main.rs}}
99
```
1010

1111
## Going to a Page

docs/0.3.x/en-US/testing/intro.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ It's that last type that Perseus is particularly concerned with, because that's
1010

1111
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.
1212

13-
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)):
13+
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)):
1414

1515
```rust
16-
{{#include ../../../../examples/basic/tests/main.rs}}
16+
{{#include ../../../../tests/basic/tests/main.rs}}
1717
```
1818

1919
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.

docs/next/en-US/reference/testing/checkpoints.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ This, and many similar problems, are easily solvable using one of Perseus' most
66

77
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.
88

9-
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)):
9+
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)):
1010

1111
```rust
12-
{{#include ../../../../examples/basic/tests/main.rs}}
12+
{{#include ../../../../tests/basic/tests/main.rs}}
1313
```
1414

1515
Note in particular the use of the `wait_for_checkpoint!` macro, which accepts three arguments:

docs/next/en-US/reference/testing/fantoccini-basics.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

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

5-
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:
5+
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:
66

77
```rust
8-
{{#include ../../../../examples/basic/tests/main.rs}}
8+
{{#include ../../../../tests/basic/tests/main.rs}}
99
```
1010

1111
## Going to a Page

docs/next/en-US/reference/testing/intro.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ It's that last type that Perseus is particularly concerned with, because that's
1010

1111
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.
1212

13-
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)):
13+
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)):
1414

1515
```rust
16-
{{#include ../../../../examples/basic/tests/main.rs}}
16+
{{#include ../../../../tests/basic/tests/main.rs}}
1717
```
1818

1919
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.

examples/i18n/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[package]
2-
name = "perseus-test-i18n"
2+
name = "perseus-example-i18n"
33
version = "0.1.0"
44
edition = "2018"
55

examples/plugins/Cargo.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
2-
name = "perseus-test-plugins"
3-
version = "0.3.2-beta.8"
2+
name = "perseus-example-plugins"
3+
version = "0.3.2"
44
edition = "2018"
55

66
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

examples/rx_state/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[package]
2-
name = "perseus-test-rx-state"
2+
name = "perseus-example-rx-state"
33
version = "0.3.2"
44
edition = "2018"
55

examples/showcase/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[package]
2-
name = "perseus-test-showcase"
2+
name = "perseus-example-showcase"
33
version = "0.1.0"
44
edition = "2018"
55

0 commit comments

Comments
 (0)