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

Make fixturesDir work again with new filesystem API and fileMatch #488

Closed
alp82 opened this issue Oct 31, 2017 · 4 comments
Closed

Make fixturesDir work again with new filesystem API and fileMatch #488

alp82 opened this issue Oct 31, 2017 · 4 comments

Comments

@alp82
Copy link

alp82 commented Oct 31, 2017

What's up?

The new filesystem API allows to change fileMatch to search for fixtures at arbitrary locations, which is awesome. But that currently deprecates fixturesDir which is sad in my opinion.

Mkay, tell me more...

Here is the default definition of fileMatch: https://github.com/react-cosmos/react-cosmos/blob/master/packages/react-cosmos-voyager2/src/server/find-fixture-files.js#L20-L21

I think this could use a placeholder for or which gets replace when the respective config property is set. That allows people to easily change fixtures folder names without recreating the whole glob schema.

If someone overwrites fileMatch, fixturesDir settings will naturally be ignored.

Does that make sense?

@ovidiuch
Copy link
Member

ovidiuch commented Oct 31, 2017

Approved. Also free for all since neither @alp82 nor me have the time to work on this at the moment.

Just to add more context, the new default value for fileMatch would look like this:

[
  '**/<fixturesDir>/**/*.{js,jsx,ts,tsx}',
  '**/?(*.)fixture?(s).{js,jsx,ts,tsx}'
]

Also notable, for this improvement I would change the findFixtureFiles args to receive a complete cosmosConfig object. This way it would have access to the new fixturesDir and any other config option in the future. Already improved on this in a different PR

@alp82
Copy link
Author

alp82 commented Oct 31, 2017

We could even go a step further and also introduce a fixturesSuffix property to use it in there:

[
  '**/<fixturesDir>/**/*.{js,jsx,ts,tsx}',
  '**/?(*.)<fixturesSuffix>.{js,jsx,ts,tsx}'
]

Or does fixturesName make more sense to use it in both positions?

[
  '**/<fixturesName>/**/*.{js,jsx,ts,tsx}',
  '**/?(*.)<fixturesName>.{js,jsx,ts,tsx}'
]

@ovidiuch
Copy link
Member

Good idea. I think keeping them separate is more flexible. So I'm a fan of both fixtureDir and fixtureSuffix options (just realized singular "fixture" sounds more natural). Even more accurate might be fixtureFileSuffix.

@ovidiuch
Copy link
Member

ovidiuch commented May 6, 2019

Both fixturesDir and fixtureFileSuffix are supported options in Cosmos Next. The defaults are __fixtures__ and fixture respectively.

@ovidiuch ovidiuch closed this as completed May 6, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants