test.mjs 664 B

123456789101112131415161718192021222324252627
  1. async function getChallengePage() {
  2. return fetch("http://localhost:8923/reqmeta", {
  3. headers: {
  4. "Accept-Language": "en",
  5. "User-Agent": "CHALLENGE",
  6. },
  7. })
  8. .then((resp) => {
  9. if (resp.status !== 200) {
  10. throw new Error(`wanted status 200, got status: ${resp.status}`);
  11. }
  12. return resp;
  13. })
  14. .then((resp) => resp.text());
  15. }
  16. (async () => {
  17. const page = await getChallengePage();
  18. if (!page.includes(`<html lang="de">`)) {
  19. console.log(page);
  20. throw new Error("force language smoke test failed");
  21. }
  22. console.log("FORCED_LANGUAGE=de caused a page to be rendered in german");
  23. process.exit(0);
  24. })();