Skip to content

Commit

Permalink
Add basic test server for serving model data
Browse files Browse the repository at this point in the history
  • Loading branch information
sigma-andex committed Jan 4, 2024
1 parent 896ad6d commit 5aac9b5
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,13 @@
"scripts": {
"build": "wasm-pack build -s text-yoga --dev",
"build:release": "wasm-pack build -s text-yoga --release",
"test:server": "npx http-server --cors -p 45678 ./tests/data",
"test": "wasm-pack test --chrome --chromedriver \"$(which chromedriver)\" --headless"
},
"keywords": [],
"author": "",
"license": "MIT"
"license": "MIT",
"devDependencies": {
"http-server": "^14.1.1"
}
}
3 changes: 3 additions & 0 deletions tests/data/test.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"hello": "🗺️"
}
6 changes: 1 addition & 5 deletions tests/web.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,10 @@ async fn pass() -> Result<(), JsValue> {
opts.method("GET");
opts.mode(RequestMode::Cors);

let url = "https://api.github.com/repos/text-yoga/transformers-wasm/branches/main";
let url = "http://localhost:45678/test.json";

let request = Request::new_with_str_and_init(&url, &opts)?;

request
.headers()
.set("Accept", "application/vnd.github.v3+json")?;

let window = web_sys::window().unwrap();
let resp_value = JsFuture::from(window.fetch_with_request(&request)).await?;

Expand Down

0 comments on commit 5aac9b5

Please sign in to comment.