mirror of
https://github.com/yewstack/yew.git
synced 2025-12-08 21:26:25 +00:00
Wasm doc tests (#2651)
* don't use wasm-pack for wasm tests * use proper version of wasm-bindgen-cli * also run with chrome driver * use cargo pkgid * wasm doc tests * setup web drivers * temp workaround * fix failures * remove debug info * don't be dumb * specific ref for benchmark workflow so it doesn't fail * Revert "specific ref for benchmark workflow so it doesn't fail" This reverts commit c32ad8264fbb4a182892f52f789dbd9822015849. This should be no longer needed: https://github.com/krausest/js-framework-benchmark/issues/1032#issuecomment-1114303988
This commit is contained in:
parent
653aa542b3
commit
8d9ecf2d20
@ -1,2 +1,5 @@
|
||||
[target.'cfg(target_arch = "wasm32")']
|
||||
runner = 'wasm-bindgen-test-runner'
|
||||
|
||||
[unstable]
|
||||
doctest-xcompile = true
|
||||
|
||||
60
.github/workflows/main-checks.yml
vendored
60
.github/workflows/main-checks.yml
vendored
@ -67,43 +67,60 @@ jobs:
|
||||
cargo clippy --release --all-features --all-targets -- --deny=warnings
|
||||
working-directory: packages/yew
|
||||
|
||||
|
||||
doc_tests:
|
||||
name: Documentation Tests
|
||||
spell_check:
|
||||
name: spellcheck
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
toolchain: stable
|
||||
target: wasm32-unknown-unknown
|
||||
override: true
|
||||
profile: minimal
|
||||
|
||||
- uses: Swatinem/rust-cache@v1
|
||||
|
||||
- name: Check spelling
|
||||
run: |
|
||||
sudo apt-get install aspell
|
||||
ci/spellcheck.sh list
|
||||
|
||||
doc_tests:
|
||||
name: Documentation Tests
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: Swatinem/rust-cache@v1
|
||||
|
||||
- uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
toolchain: stable
|
||||
override: true
|
||||
profile: minimal
|
||||
|
||||
- name: Install wasm-bindgen-test-runner
|
||||
run: cargo install --git https://github.com/hamza1311/wasm-bindgen --branch respect-rustdoc-tmp-paths wasm-bindgen-cli
|
||||
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
toolchain: nightly
|
||||
target: wasm32-unknown-unknown
|
||||
override: true
|
||||
profile: minimal
|
||||
|
||||
- uses: browser-actions/setup-geckodriver@latest
|
||||
- uses: nanasess/setup-chromedriver@v1
|
||||
|
||||
- name: Run doctest
|
||||
uses: actions-rs/cargo@v1
|
||||
with:
|
||||
command: test
|
||||
args: --doc
|
||||
args: --doc --workspace --exclude yew --exclude changelog --exclude website-test --target wasm32-unknown-unknown
|
||||
|
||||
- name: Run website code snippet tests
|
||||
uses: actions-rs/cargo@v1
|
||||
with:
|
||||
command: test
|
||||
args: -p website-test
|
||||
args: -p website-test --target wasm32-unknown-unknown
|
||||
|
||||
- name: Run doctest - yew with features
|
||||
uses: actions-rs/cargo@v1
|
||||
with:
|
||||
command: test
|
||||
args: --doc --features doc_test --features wasm_test
|
||||
args: -p yew --doc --features doc_test --target wasm32-unknown-unknown
|
||||
|
||||
integration_tests:
|
||||
name: Integration Tests on ${{ matrix.toolchain }}
|
||||
@ -139,19 +156,6 @@ jobs:
|
||||
VERSION=`cargo pkgid --frozen wasm-bindgen | cut -d ":" -f 3`
|
||||
cargo install --version $VERSION wasm-bindgen-cli
|
||||
|
||||
- name: debug
|
||||
run: |
|
||||
geckodriver --version
|
||||
echo ""
|
||||
which geckodriver
|
||||
chromedriver --version
|
||||
echo ""
|
||||
which chromedriver
|
||||
echo ""
|
||||
wasm-bindgen --version
|
||||
echo ""
|
||||
which wasm-bindgen
|
||||
|
||||
- name: Run tests - yew
|
||||
run: |
|
||||
cd packages/yew
|
||||
|
||||
@ -18,7 +18,7 @@ wasm-bindgen-futures = "0.4"
|
||||
weblog = "0.3.0"
|
||||
yew = { path = "../../packages/yew/", features = ["ssr", "csr"] }
|
||||
yew-router = { path = "../../packages/yew-router/" }
|
||||
tokio = { version = "1.15.0", features = ["full"] }
|
||||
tokio = { version = "1.15.0", features = ["rt", "macros"] }
|
||||
|
||||
[dev-dependencies.web-sys]
|
||||
version = "0.3"
|
||||
|
||||
@ -39,8 +39,12 @@ fn App() -> Html {
|
||||
html! {<div>{"Hello, World!"}</div>}
|
||||
}
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() {
|
||||
// we use `flavor = "current_thread"` so this snippet can be tested in CI,
|
||||
// where tests are run in a WASM environment. You likely want to use
|
||||
// the (default) `multi_thread` favor as:
|
||||
// #[tokio::main]
|
||||
#[tokio::main(flavor = "current_thread")]
|
||||
async fn no_main() {
|
||||
let renderer = ServerRenderer::<App>::new();
|
||||
|
||||
let rendered = renderer.render().await;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user