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

chore: fix error assertions #264

Merged
merged 3 commits into from
Jun 4, 2024
Merged

chore: fix error assertions #264

merged 3 commits into from
Jun 4, 2024

Conversation

brc-dd
Copy link
Contributor

@brc-dd brc-dd commented Jun 4, 2024

Notable Changes

.catch + match/equals doesn't assert that a particular call throws error. It just asserts IF an error is thrown it will satisfy assertions inside. Consequently, it will pass the test even if something doesn't throw while it should.

Type

  • Test
  • Chore

SemVer

  • No bump needed

Checklist

  • Lint and unit tests pass with my changes
  • I have added tests that prove my fix is effective/works
  • I have added necessary documentation (if appropriate)
  • Any dependent changes are merged and published in downstream modules

Comment on lines 6 to 11
// FIXME: this is resolving to nearest postcss config (outside root)
// test('Loading Config - {Error}', async () => {
// await rejects(() => postcssrc({}, 'test/err'), {
// message: /^No PostCSS Config found in: (.*)$/
// })
// })
Copy link
Contributor Author

@brc-dd brc-dd Jun 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not fully sure what's the expected behavior here, but this is not throwing any error and resolving to test/postcss.config.mjs

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like this test never moved to match area (this is why rejects is better).

As I understand it should ignore error in broken config and return No PostCSS Config found in. What is current behaviour in this test?

Copy link
Contributor Author

@brc-dd brc-dd Jun 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, currently there is no postcssrc file directly inside test/err. Running postcssrc({}, 'test/err') is not failing and returning content from test/postcss.config.mjs (one directory up the passed directory). Should it fail if there is no config directly inside the specified path?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let’s remove test. It is rare case and test didn’t work for a while.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

test/rc.test.js Show resolved Hide resolved
@ai ai merged commit 824a7de into postcss:main Jun 4, 2024
3 checks passed
@ai
Copy link
Member

ai commented Jun 4, 2024

Thanks!

@brc-dd brc-dd deleted the fix-error-tests branch June 4, 2024 10:26
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

Successfully merging this pull request may close these issues.

2 participants