react-cosmos / rfcs

Change requests for React Cosmos
MIT License
1 stars 2 forks source link

Synchronous dev utilities #13

Closed andyrichardson closed 4 years ago

andyrichardson commented 4 years ago

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 commented 4 years ago

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

ovidiuch commented 4 years ago

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

andyrichardson commented 4 years ago

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.