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

92
Views
express api para prueba con broma

¿Cómo escribir rest api con express para verificar el código js con broma?

 import shell from 'shelljs' import path from 'path' export const checkTask = (req, res) => { shell.touch('./task.test.js') shell.ShellString(`const getSum = (a, b) => a + b\ntest('sum of 4 and 5 expected to be 9', () => { const data = getSum(4, 5); expect(data).toBe(9); })`).to('./task.test.js') shell.exec('npm run test') res.status(200).json({ 'ok': true }) }

No devuelve nada, solo crea un archivo de prueba pero no ejecuta broma, por lo que no puedo obtener resultados. No hay mensajes de error en la terminal

si ejecuto por separado como a continuación, funciona

 export const checkTask = (req, res) => { shell.touch('./task.test.js') shell.ShellString(`const getSum = (a, b) => a + b\ntest('sum of 4 and 5 expected to be 9', () => { const data = getSum(4, 5); expect(data).toBe(9); })`).to('./task.test.js') res.status(200).json({ 'ok': true }) }

o así con el archivo de prueba ya creado, también funciona

 export const checkTask = (req, res) => { shell.exec('npm run test') res.status(200).json({ 'ok': true }) }
about 4 years ago · Juan Pablo Isaza
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!