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

fix: add tests to demonstrate that PostCSS configs are not reused across projects #1

Merged
merged 2 commits into from Jul 20, 2021

Conversation

fwouts
Copy link

@fwouts fwouts commented Jul 6, 2021

Description

This sets up two separate apps with conflicting PostCSS configs, along with tests to make sure that each gets only its own CSS applied.

Additional context

See vitejs#3906 for the original PR.


What is the purpose of this pull request?

  • Bug fix
  • New Feature
  • Documentation update
  • Other

Before submitting the PR, please make sure you do the following

  • Read the Contributing Guidelines.
  • Read the Pull Request Guidelines and follow the Commit Convention.
  • Check that there isn't already a PR that solves the problem the same way to avoid creating a duplicate.
  • Provide a description in this PR that addresses what the PR is solving, or reference the issue that it solves (e.g. fixes #123).
  • Ideally, include relevant tests that fail without this PR but pass with it.

@fwouts
Copy link
Author

fwouts commented Jul 6, 2021

@patak-js here are some tests for the PostCSS config caching PR. Let me know what you think about this approach, happy to reshuffle things around.

@y1d7ng
Copy link
Owner

y1d7ng commented Jul 16, 2021

@fwouts Thank you very much for the test. But I found that even if the original PR code is not included, the test can still be executed successfully in the current vite project.

@fwouts
Copy link
Author

fwouts commented Jul 16, 2021

Hey @OneNail, thanks for catching this. I could have sworn I had run these tests without your commit and confirmed they failed!

I've been debugging this for an hour and I can't figure out what's going on. It looks like Jest is reloading modules between tests and resetting the value of cachedPostcssConfig every time, even when running with --runInBand which I've confirmed reuses the same process.

I ended up implementing it with a different approach to guarantee that it won't happen.

@y1d7ng
Copy link
Owner

y1d7ng commented Jul 20, 2021

@fwouts Thank you very much for the test. If the original PR code isn't included, the test failed at

expect(await getColor(blueA)).toBe('blue')

is it supposed to failed at

expect(await getColor(greenB)).toBe('green')

?

@fwouts
Copy link
Author

fwouts commented Jul 20, 2021

@fwouts Thank you very much for the test. If the original PR code isn't included, the test failed at

expect(await getColor(blueA)).toBe('blue')

is it supposed to failed at

expect(await getColor(greenB)).toBe('green')

?

No, that's expected! That's because there's already another Vite server running (the one set up in https://github.com/vitejs/vite/blob/main/scripts/jestPerTestSetup.ts) so a null PostCSS config has already been cached. Therefore, even the first app fails.

I preferred to have both the blue and green app so we don't rely on this implicit behaviour :)

@y1d7ng y1d7ng merged commit 02fb297 into y1d7ng:hotfix/3902 Jul 20, 2021
@y1d7ng
Copy link
Owner

y1d7ng commented Jul 20, 2021

@fwouts Thank you very much, I merged the commit.

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