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

126
Views
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 answers
Answer question

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 Report

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 Report
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!