Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use yellow and red colors for suites with partial and no tests passing #129

Closed
jasikpark opened this issue Aug 7, 2021 · 10 comments
Closed

Comments

@jasikpark
Copy link

Would it be possible to add color-coding to the test output, so that a test suite with zero passing tests doesn't output in green?

image

It took me a bit to figure out that this didn't say that all tests were passing 😅 you might respond with "just read" but I feel like the color is misleading?

Would it be possible to at least add a section in red for Failed: X?

Thanks for the great tool btw!

@lukeed
Copy link
Owner

lukeed commented Aug 7, 2021

Can I see your full output?

Pass count is always green. Skipped is yellow because you purposefully write in .skip and so doesn't effect the exit code. Any errors will fill up your terminal with plenty of red that it shouldn't be unclear.

If you skip enough tests that you have 0 tests running, I would justifiably say that's a green 0 and and 0 exit code. You wrote that in & it behaved accordingly

@jasikpark
Copy link
Author

jasikpark commented Aug 7, 2021

image

full output 😅 from Astro Prettier Plugin

@jasikpark
Copy link
Author

Can I see your full output?

Pass count is always green. Skipped is yellow because you purposefully write in .skip and so doesn't effect the exit code. Any errors will fill up your terminal with plenty of red that it shouldn't be unclear.

If you skip enough tests that you have 0 tests running, I would justifiably say that's a green 0 and and 0 exit code. You wrote that in & it behaved accordingly

It might make sense to add a warning message if someone runs a test suite containing only skips 🤔 but I would agree that passing on having all tests skip makes sense.

@lukeed
Copy link
Owner

lukeed commented Aug 7, 2021

You should move your test-utils file into your fixtures so that it's not being loaded. Also don't think you need to have -i package.json in the cli usage

@lukeed
Copy link
Owner

lukeed commented Aug 7, 2021

I don't want to add a condition for such a rare and weird edge case tbh. Esp since the end result is expected and gonna be the same anyway.

It feels like your tests aren't being awaited correctly, and that may be the test-utils causing things to freak out. Not at my computer but will have to check later

@jasikpark
Copy link
Author

"test": "uvu test -i fixtures -i test-utils.js", left me with the same result as the above screenshot (without moving any of the files around)

@jasikpark
Copy link
Author

jasikpark commented Aug 7, 2021

Ah, so the reason why I'm getting "Passed: 0" with green output is

uvu/src/index.js

Lines 130 to 143 in d56753e

for (let test of group) {
let [errs, ran, skip, max] = await test();
total += max; done += ran; skips += skip;
if (errs.length) {
write('\n' + errs + '\n'); code=1;
if (bail) return isNode && process.exit(1);
}
}
}
write('\n Total: ' + total);
write((code ? kleur.red : kleur.green)('\n Passed: ' + done));
write('\n Skipped: ' + (skips ? kleur.yellow(skips) : skips));
write('\n Duration: ' + timer() + '\n\n');
that the tests aren't ending but also aren't throwing exceptions?

Maybe there needs to be a time requirement or something?

@jasikpark
Copy link
Author

jasikpark commented Aug 7, 2021

I've sorted out that https://github.com/snowpackjs/prettier-plugin-astro/blob/198bf46dd6b2ff5ecff9314ffadea2cf1db201a3/test/astro-prettier.test.js#L20-L27 seems to be the culprit - that test is failing in some way - commit 043a1070612eb2d38f14b3b0dbda03f986c8f49a messed things up

format() is silently failing it seems?

@jasikpark
Copy link
Author

jasikpark commented Aug 9, 2021

by altering the test to this:

Prettier('can format a basic Astro file', async () => {
  const [src, out] = await getFiles('basic');
  assert.not.fixture(src, out);
  console.log('before format');
  try {
    const formatted = format(src);
  } catch (e) {
    if (typeof e == 'Error') {
      throw e;
    }
    throw new Error(e);
  }
  console.log('after format');
  assert.fixture(formatted, out);
});

I can get the suite to run correctly.. I'm not sure why it's failing there.

@lukeed
Copy link
Owner

lukeed commented Aug 12, 2021

Can I close this? I don't really want to adjust the colorization & the actual issue you were running into is tracked by #130

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants