test.mjs 629 B

123456789101112131415161718192021222324252627
  1. async function getRobotsTxt() {
  2. return fetch("http://localhost:8923/robots.txt", {
  3. headers: {
  4. "Accept-Language": "en",
  5. "User-Agent": "Mozilla/5.0",
  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 getRobotsTxt();
  18. if (page.includes(`<html>`)) {
  19. console.log(page);
  20. throw new Error("serve robots.txt smoke test failed");
  21. }
  22. console.log("serve-robots-txt serves robots.txt");
  23. process.exit(0);
  24. })();