Test-shopping.bats fails even when expected value matches actual value

Hi, I’m having some trouble figuring out why my tests are failing in the CLI but passing when I submit them:

When I run shopping.jq ($ jq -f shopping.jq shopping-list.json) my output is:

“Ingredients for pancakes”
8
0.25
{
“buttermilk”: “regular milk”,
“melted butter”: “vegetable oil”,
“blueberries”: “chopped apple”
}

Then I run $ bats test-shopping.bats and my output is:

test-shopping.bats
 ✗ Show shopping list name
   (from function `assert_line' in file bats-extra.bash, line 276,
    in test file test-shopping.bats, line 9)
     `assert_line --index 0 '"Ingredients for pancakes"'' failed
   
   -- line differs --
   index    : 0
   expected : "Ingredients for pancakes"
   actual   : "Ingredients for pancakes"
   --
   
 ✗ Count the ingredients
   (from function `assert_line' in file bats-extra.bash, line 276,
    in test file test-shopping.bats, line 16)
     `assert_line --index 1 '8'' failed
   
   -- line differs --
   index    : 1
   expected : 8
   actual   : 8
   --

 ✗ Show how much sugar is needed
   (from function `assert_line' in file bats-extra.bash, line 276,
    in test file test-shopping.bats, line 23)
     `assert_line --index 2 '0.25'' failed

   -- line differs --
   index    : 2
   expected : 0.25
   actual   : 0.25
   --

 ✓ Map of substitutions

4 tests, 3 failures

I don’t know why they’d fail if the “actual” values match the “expected” values.

When I submit my solution (exercism submit shopping.jq) it passes.

What’s your code look like?

It could also be caused by line endings of the jq output. I have no idea how to troubleshoot that, but it is a common source of problems with Windows vs. Linux usage. Maybe someone has an idea how to debug this?

I’m pretty sure the way the command output is captured strips all trailing whitespace so carriage returns should not be a factor.

bash command substitution strips trailing newlines but not carriage returns.

@kbirkenmayer what editor do you use? Please run this command and show us the output: od -c shopping.jq