lukeed / uvu

uvu is an extremely fast and lightweight test runner for Node.js and the browser
MIT License
2.98k stars 99 forks source link

print trailing "\n" in multiline diff #110

Open alexanderniebuhr opened 3 years ago

alexanderniebuhr commented 3 years ago

assert.fixture fails even if the actual result is equal to the expected

is there any way to debug more, why the test fails, even the result is correct?

const formatT = suite("FORMAT")
formatT("correct format", () => {
  let input = `
  <div
    class="bg-red-500"
  >
  Test
  </div>
  `
  fixture(
    new Magician(new Processor(), input, "src/App.svelte").format().getCode(),
    `<div class="bg-red-500">Test</div>`
  )
})
formatT.run()
   FAIL  FORMAT  "correct format"
    Expected value to match fixture:  (fixture)

        Actual:
        L1 --<div·class="bg-red-500">Test</div>
        Expected:
        L1 ++<div·class="bg-red-500">Test</div>

    at assert (C:/Users/Alexander/Documents/projects/windicss/svelte-windicss-preprocess/node_modules/uvu/assert/index.js:31:8)
    at fixture (C:/Users/Alexander/Documents/projects/windicss/svelte-windicss-preprocess/node_modules/uvu/assert/index.js:77:2)
    at Object.handler (C:/Users/Alexander/Documents/projects/windicss/svelte-windicss-preprocess/tests/magician.ts:28:19)
    at Number.runner (C:/Users/Alexander/Documents/projects/windicss/svelte-windicss-preprocess/node_modules/uvu/dist/index.js:77:16)
    at exec (C:/Users/Alexander/Documents/projects/windicss/svelte-windicss-preprocess/node_modules/uvu/dist/index.js:131:39)
    at async Object.exports.run (C:/Users/Alexander/Documents/projects/windicss/svelte-windicss-preprocess/node_modules/uvu/run/index.js:12:2)
    at async C:/Users/Alexander/Documents/projects/windicss/svelte-windicss-preprocess/node_modules/uvu/bin.js:28:5
alexanderniebuhr commented 3 years ago

new line at the end, i guess it was. maybe show that in the expected and actual result on failure?

lukeed commented 3 years ago

Thanks – yeah it's just the trailing \n on the input side.