Comments (4)
Note: Storybook instruments (monkey-patch) @testing-library
methods so they can intercept it.
from react-showroom.
Intention of trying to reuse code for interaction with tests feel clunky as we need to define the interactions outside of the markdown file, but the interactions is dependent on the rendered content.
Reference: https://github.com/malcolm-kee/react-showroom/tree/feature/run-fn
from react-showroom.
Thinking out loud: maybe parse jest tests and then run it in browser???
from react-showroom.
After playing around with esbuild
, now I have better idea how to do this:
- combining
acorn
andesbuild
, create a file from component test file that will export each test with a function name generated deterministically from the test name. The dependencies of the file will be prebundled (except few libraries, e.g.react
and@testing-library
and those listed inimports
.) (Possible improvement: if it's import the components, maybe just resolve to the component instead). - component metadata will include a key-value object of
{ [testName]: fnName }
that allows us to generate a path pointing to a specificfnName
associated with a test. - an
InteractionBlock
component will be exported fromreact-showroom/client
which will accepts atestName
props. The component will use the props in combination of the key-value object above to generates a path, e.g./_interactions/:componentId/:fnName
that will be used as url ofiframe
. - we will create another sub app - interaction app (in addition of current showroom app and preview app) that will parse the path and use it to import specific test file and run. This app will be run in
iframe
rendered byInteractionBlock
. The reason we want to run this asiframe
is to isolate as much as possible (although we can't do it fully). - For
build
, we also need to prerender the interaction app so the html will be generated for static site hosting. - [To explore] Inject
@testing-library/*
usage with custom code, that will allows us to send details about the interactions from interaction app to showroom app, thus enabling play/pause feature like storybookjs.
from react-showroom.
Related Issues (20)
- Intellisense HOT 1
- useMenu
- accessibility
- measure
- Create showroom for `@showroomjs/ui` package HOT 1
- Refactoring: Use web worker as search index service to improve performance
- Migrate from stitches HOT 1
- Prerender examples in iframe
- Auto inject component into iframe
- Render multiple screens in standalone view
- Add min height to iframe
- Allow user to specify initial height for the frame
- Allow add comment in standalone view HOT 1
- Improve File Selector
- Tweak design for NumberInput to differentiate with TextInput
- Handle enum with `| null` properly for `usePropsEditor`
- Support `date` control in playground
- Support admonition
- Highlight code
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-showroom.