-
-
Notifications
You must be signed in to change notification settings - Fork 9.5k
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
[Bug]: Test runner doesn't find stories when using custom function #30597
Comments
** Disclaimer** This information might be inaccurate, due to it being generated automatically
|
This looks useful. I'll try this and report back. However I'll keep this open as I still think it's a bug and couldn't find anything similar to it already logged. EDIT: No, this doesn't appear to work although I'm not certain why. I've made my function non-async so it can sit on a top level: function getStoryEntries() {
// Do an async thing - my real code uses the value of this
fs.readdirSync(path.resolve(__dirname));
return [
{
directory: "../src/stories",
titlePrefix: "fake/directory/",
},
];
} I've added this: const storiesForTestRunner = getStoryEntries();
fs.writeFileSync(
".storybook/main.test.ts",
`export default { stories: ${JSON.stringify(storiesForTestRunner)} }`
); And whilst that file is created, when I run
EDIT 2: After more debugging, I think this issue is |
Describe the bug
I'm using a custom function to define the
StoriesEntry
array that defines where stories are to be found. However, the storybook test runner doesn't appear to be working alongside this as I receive an error when running the test runner:Reproduction link
https://stackblitz.com/edit/github-y1neym5w
Reproduction steps
I've not been able to run the test runner against a stackblitz URL, but the above code should be the replication.
npm run storybook
npx test-storybook --url http://localhost:6006/
stories: async () => [...(await getStoryEntries())],
npm run storybook
npx test-storybook --url http://localhost:6006/
This is the function used which is a simpler version of what I'm actually intending to use:
System
Additional context
The purpose of the story function is to flatten the directory structure displayed so that whilst it is similar to the file structure, it has fewer levels.
The text was updated successfully, but these errors were encountered: