Only Ember
Stories are <template> tags with your own imports, compiled by your
app's own Embroider build. No renderer adapter, no second build, no webpack.
A component workshop for Ember
A jig holds one part while you work on it. Jig does that for your components: write a
.story.gts file, and see the component alone, in an isolated canvas, with
typed controls, an actions log, accessibility checks and a docs page. The same stories
run as QUnit tests and as screenshots. Embroider and Vite, nothing else.
npx @jig-ts/cli init
Why
.gts fileimport { createStoryActions, createStoryProps } from '@jig-ts/ember'
import Counter from 'my-app/components/counter'
import { CounterHarness } from 'my-app/components/counter.harness'
export const story = {
name: 'UI/Counter/Adds twice',
harness: CounterHarness,
props: createStoryProps({
step: { type: 'number', label: 'Step', defaultValue: 2, min: 1, max: 10 },
}),
actions: createStoryActions({
onChange: (count: number) => `count is ${count}`,
}),
play: async ({ harness }) => {
await harness.add(2)
},
}
export const template = <template>
<Counter @step={{story.props.step}} @onChange={{story.actions.onChange}} />
</template>
Stories are <template> tags with your own imports, compiled by your
app's own Embroider build. No renderer adapter, no second build, no webpack.
The canvas runs your app's services, components and styles in an iframe, without its routes. Mock a service for one story, and Jig blocks every request you did not mock.
createStoryProps declares each control and its type. The Controls panel
is a Formwright form, and every
change is in the URL, so a link opens the same state.
Panels
Change an arg and the story updates in place: the component keeps its state. Each action call goes to the log.
Each harness call of a play function is a step, with its status. Run it again with one click.
axe-core checks the story when it is ready and after each change. Point at a problem and Jig marks the element in the canvas.
Each folder gets a docs page with its stories, controls and source. A
.docs.md file adds prose.
The toolbar sets the canvas size, the app theme, the background and a grid. The shell has light and dark themes, your brand colours and translatable strings. Open the live demo →
Testing
// tests/stories-test.ts: one QUnit test for each story
import { jigStoryTests } from '@jig-ts/test'
import { harnessed } from '@jig-ts/harnessed'
jigStoryTests({
stories: import.meta.glob('../app/**/*.story.gts', { eager: true }),
plugins: [harnessed()],
block: [/^\/api\//],
})
A story test fails when the story throws, when a play step fails, or when it sends a
request with no mock. A harness with static states gives the Controls panel a
"Harness state" control. jig-snapshot dist-jig compares a screenshot of each
story with its baseline. JigHarness drives Jig itself, for tests of the
workshop.
Examples
A story for each Joinery component and add-on: dialogs, menus, the data table, charts, the calendar and the rich text editor.
A story for each Formwright component, control and add-on, each one in a real form.
Each library keeps its stories next to its own test app, and builds them with
JIG_BUILD=1 vite build, as your app would.
vs Storybook
| Jig | Storybook | |
|---|---|---|
| Build | Your app's Vite build, one plugin | Its own builder and config |
| Story format | .story.gts with <template> |
CSF, with an Ember renderer adapter |
| Your services and DI | The real app container | An owner that you supply |
| Arg change | Updates in place | Remounts the component |
| Play functions | harnessed harnesses, one step per call | Testing Library, or harnessed's adapter |
| Stories as tests | In your QUnit run | Vitest or the test runner |
| Addons | The built-in panels | A large ecosystem |
Storybook is the right choice for many frameworks in one place, and for its addons. Jig is for an Ember team that wants the workshop to be part of the app.
Packages
| Package | For |
|---|---|
@jig-ts/ember |
The shell, the canvas, story helpers, docs pages |
@jig-ts/vite |
The Jig page on the dev server, the static build, story sources |
@jig-ts/core |
Controls, the registry, the shell and canvas machines (Switchyard) |
@jig-ts/harnessed |
Play functions through harnesses, harness states, shell harnesses |
@jig-ts/test |
One QUnit test for each story |
@jig-ts/snapshot |
jig-snapshot: screenshots compared with baselines |
@jig-ts/showcase |
<jig-showcase>: a story that plays itself, in any page |