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

134
Vistas
JavaScript adding "·" character to endline

So I'm trying to run a tests.js for a python code I've written, everything seems fine however at the end of each line ("\n" character), the tests.js file is appending a "·" character. The file internally uses the toString() method to convert the python output to a string and then compares it with the expected string using toEqual().

My code:

def print_help():
    print("""Usage :-
$ ./task add 2 hello world    # Add a new item with priority 2 and text "hello world" to the list
$ ./task ls                   # Show incomplete priority list items sorted by priority in ascending order
$ ./task del INDEX            # Delete the incomplete item with the given index
$ ./task done INDEX           # Mark the incomplete item with the given index as complete
$ ./task help                 # Show usage
$ ./task report               # Statistics""", end="")

The output: error

The tests.js code:

test("prints help", () => {
  let received = execSync(tasksTxtCli("help")).toString("utf8");

  expect(received).toEqual(expect.stringContaining(usage));
});
about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

I don't know what you're using for your output in Node.js, but it's likely that this isn't actually a middle dot character, but an otherwise unprintable character by your terminal emulator.

In other words, what you're seeing isn't really there. It's just that something is there.

I expect that this is a difference between \r\n and \n for newline characters. Your comparison string probably doesn't have \r\n, but the Python output probably does.

If you want to be really sure as to what it is, pipe your Python output to a file and open it up with a hex editor. Or even, just don't convert to a string and use console.log() (or util.inspect()) to see a hex representation of the binary output.

about 4 years ago · Juan Pablo Isaza Denunciar

0

As per my solution modify your code as:

def print_help():
    help="""Usage :-
$ ./task add 2 hello world    # Add a new item with priority 2 and text "hello world" to the list
$ ./task ls                   # Show incomplete priority list items sorted by priority in ascending order
$ ./task del INDEX            # Delete the incomplete item with the given index
$ ./task done INDEX           # Mark the incomplete item with the given index as complete
$ ./task help                 # Show usage
$ ./task report               # Statistics"""
    sys.stdout.buffer.write(help.encode('utf8'))

In this way , the dot(.) won't appear on command line. Reference: https://github.com/nseadlc-2020/package-todo-cli-task/issues/12

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