Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

184
Vistas
Custom commands or utility classes/functions?

I'm working with a team that has a project in Nightwatch.js. They are defining commands for almost everything:

  • Datetime functions as commands (return current day, array of days in a period, etc.)
  • SQL queries to get data as commands

To me, some of these fit better to utility classes, but they prefer to have them as commands, so they can access them via browser.Command.

What's the correct approach or recommendation? All in commands looks odd to me, but also the codes look more clean, as you don't need to do imports.

Thanks,

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

This question will probably get closed for being opinion based, but anyway.

I would agree that not all utilities should be commands. I would generally see the scope of command to be more to do with acting on things in the browser as the user would, or a way to group user actions, e.g. in a typical system I would see commands like -

  • login(), which would group the clicking into text fields and entering the username password and eventually clicking the login button.
  • addUser(), which would maybe be a small, but repetitive group of commands to add a user to an admin panel for example.
  • dragTo(x), which would maybe handle some drag and drop functionality.

etc.

I wouldn't see date utils etc as commands, but as you say, just utility functions, that are more about the underlying implementation of the test, and not how the user would interact with the system.

Although not Nightwatch, maybe take some advice from the Best Practices of Custom Commands from Cypress - https://docs.cypress.io/api/cypress-api/custom-commands#Best-Practices

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda