cmorten / superoak

HTTP assertions for Oak made easy via SuperDeno. 🐿 🦕
https://cmorten.github.io/superoak/
MIT License
121 stars 8 forks source link

Need a FAQ section in README.md #13

Closed Ding-Fan closed 3 years ago

Ding-Fan commented 3 years ago

Issue

Setup:

Details

Use the same superoak instance multiple times in a same test

// ...
Deno.test("app", async () => {
  const testClient = await superoak(app);
  await testClient.get("/").expect("Hello GET!");
  await testClient.post("/").expect("Hello POST!");
});
// ...

leads to vague error message like below:

Error: Request has been terminated
Possible causes: the network is offline, Origin is not allowed by Access-Control-Allow-Origin, the page is being unloaded, etc.
    at Test.Request.crossDomainError (https://dev.jspm.io/npm:superagent@5.3.1/lib/client.dew.js:680:15)
    at XMLHttpRequestSham.xhr.onreadystatechange (https://dev.jspm.io/npm:superagent@5.3.1/lib/client.dew.js:783:21)
    at XMLHttpRequestSham.xhrReceive (https://deno.land/x/superdeno@2.4.1/src/xhrSham.js:105:29)
    at XMLHttpRequestSham.send (https://deno.land/x/superdeno@2.4.1/src/xhrSham.js:64:12)

I'm not sure is this a bug or not. Maybe add this to a FAQ section in README.md would save people's time. 🙂

asos-craigmorten commented 3 years ago

Hey @Ding-Fan 👋

This is indeed a big gotcha, and something I'm hoping could be changed in a future major version, but sadly don't have the time right now!

We do briefly note on this issue in the second bullet point of the README.md notes section (https://github.com/asos-craigmorten/superoak#notes), though isn't perhaps all that clear!

Would you be open to raising a pull request and starting an FAQs section (and / or updating the existing notes section) to try and make this clearer? Welcome any suggestions 😄

Ding-Fan commented 3 years ago

I don't know the logic under the hood so I didn't change the second bullet point of Notes.

I've read the Notes before

you cannot re-use a SuperOak instance once the chained .end() method has been called.

However, in my case, there isn't any explicit .end() call.

cmorten commented 3 years ago

Closed by https://github.com/asos-craigmorten/superoak/pull/14/.