Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

282
Views
Cómo ejecutar el script mocha para probar la URL a través del navegador (sin usar XMLHttpRequest)

Hola: aunque soy nuevo en nodejs y mocha y busco tu ayuda. Gracias de antemano.

Estoy tratando de ejecutar una prueba de mocha simple a través del navegador (no del terminal) para acceder a una URL y obtener el estado de respuesta.

Usando XMLHttpRequest funciona. Sin embargo, quiero usar una biblioteca de nodos (por ejemplo, request.js ). Para probar el script mocha desde el navegador, no puedo encontrar cómo cargar request.js correctamente. Por favor ayuda.

prueba.js (usando XMLHttpRequest)

 describe('suite', function(){ it('case using XMLHTTPREQUEST', function(done){ var url = "http://oss.sheetjs.com/js-xlsx/test_files/formula_stress_test_ajax.xlsx"; var xhr = new XMLHttpRequest(); xhr.open("GET", url, true); xhr.onload = function (e) { console.log("TEST RESPONSE STATUS IS: " + xhr.status); } xhr.send(); done(); }); it('case using AXIOS', function(done){ axios.get('http://www.google.com').then( function(response){ console.log(response.status); done(); }); }); });

testrunner.html

 <!DOCTYPE html> <html> <head> <title>Mocha Tests</title> <link rel="stylesheet" href="../node_modules/mocha/mocha.css"> </head> <body> <div id="mocha"></div> <script src="../node_modules/axios/dist/axios.js"></script> <script src="../node_modules/mocha/mocha.js"></script> <script>mocha.setup('bdd')</script> <script src="./test.js"></script> <script> mocha.run() </script> </body> </html>
over 4 years ago · Santiago Trujillo
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!