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

Synchronous dev utilities #13

Closed
andyrichardson opened this issue Mar 13, 2020 · 3 comments · Fixed by react-cosmos/react-cosmos#1171
Closed

Synchronous dev utilities #13

andyrichardson opened this issue Mar 13, 2020 · 3 comments · Fixed by react-cosmos/react-cosmos#1171

Comments

@andyrichardson
Copy link

About

The dev utilities exported from the "react-cosmos" package are great but their async implementation can make basic usage tricky or impossible.

It would be awesome if a sync version of these packages could be provided.

Here's an example of how I'm currently using getFixtureUrls. Because the function is async, there's no way to make use of test.each.

Another example is a bash script which needs the fixture urls. There's no easy way to get them because something such as this would not work due to the async implementation URLS=$(node -x "require('react-cosmos').getFixtureUrls()")

Final example, this was a hack I had to do to make a backstop config that uses fixture URLs. Synchronously, I would have just done this:

// backstop.js

module.exports = {
  // ...
  scenarios: getFixtureUrls().map((url) => ({
    // ...
  )})
}
@ovidiuch
Copy link
Member

ovidiuch commented Mar 13, 2020

Quick note unrelated to the issue: I think you want to pass fullScreen: true to getFixtureUrls here.

@ovidiuch
Copy link
Member

ovidiuch commented Mar 13, 2020

You make a solid case. These alternative methods would indeed be useful:

  • getCosmosConfigSync Nevermind, getCosmosConfig is already sync
  • getFixtureUrlsSync
  • getFixturesSync

@ovidiuch ovidiuch transferred this issue from react-cosmos/react-cosmos Mar 13, 2020
@andyrichardson
Copy link
Author

Quick note unrelated to the issue: I think you want to pass fullScreen: true to getFixtureUrls here.

Hero!

You make a solid case

I'm humbled! This is pretty core to one of our projects so I'll see if I can spend some time on it today.

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 a pull request may close this issue.

2 participants