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

Allow fixture files and directories with the same name #25

Open
angelikatyborska opened this issue Aug 31, 2021 · 1 comment
Open

Allow fixture files and directories with the same name #25

angelikatyborska opened this issue Aug 31, 2021 · 1 comment

Comments

@angelikatyborska
Copy link

What's wrong?

This is how I structure my projects:

src/Feature.tsx
src/Feature/InternalComponent1.tsx
src/Feature/InternalComponent2.tsx

With fixtures, it looks like this:

src/Feature.tsx
src/Feature.fixture.tsx
src/Feature/InternalComponent1.tsx
src/Feature/InternalComponent1.fixture.tsx
src/Feature/InternalComponent2.tsx
src/Feature/InternalComponent2.fixture.tsx

With such a structure, React Cosmos loads and displays for me the fixtures Feature/InternalComponent1 and Feature/InternalComponent2, but it doesn't display the fixture Feature. I assume that's because the other fixtures are picked up first and "block" the name Feature, preventing another fixture from being called like that.

If I rename the file from src/Feature.fixture.tsx to something else, like src/Feature_.fixture.tsx, then the fixture loads.

I can use that fact as a workaround but I would match rather have all filenames match.

User info

React Cosmos version 5.6.3, Webpack version 5.38.1.

@ovidiuch ovidiuch transferred this issue from react-cosmos/react-cosmos Sep 6, 2021
@ovidiuch ovidiuch changed the title Fixture not loaded if other fixtures exist in a directory with the same name Allow fixture files and directories with the same name Sep 6, 2021
@ovidiuch
Copy link
Member

ovidiuch commented Sep 6, 2021

Hi @angelikatyborska,

Thanks for pointing this out. I can't be 100% sure without checking, but I believe this is by design. Another pattern that Cosmos supports is index files – src/Feature/index.tsx, which shows up as src/Feature in Cosmos. This is possibly the reason why Cosmos doesn't work as you'd want to in your case, but it doesn't necessarily mean it can't accommodate both cases with some refactor.

I've moved your issue in the RFCs repo because this sounds more like a feature request. If anyone is interested in looking into this I'm happy to help with finding the relevant code and test files.

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