fix(storybook): emit a value from storybook executor so that e2e tests work (#4845)

This commit is contained in:
Jason Jean 2021-02-19 18:05:42 -05:00 committed by GitHub
parent 0fc729c5ad
commit 35049dcdef
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 8 deletions

View File

@ -44,11 +44,10 @@ describe('@nrwl/storybook:storybook', () => {
};
});
it('should provide options to storybook', (done) => {
storybookExecutor(options, context);
setTimeout(() => {
expect(buildDevStandalone).toHaveBeenCalled();
done();
}, 0);
it('should provide options to storybook', async () => {
const iterator = storybookExecutor(options, context);
const { value } = await iterator.next();
expect(value).toEqual({ success: true });
expect(buildDevStandalone).toHaveBeenCalled();
});
});

View File

@ -33,7 +33,7 @@ try {
require('dotenv').config();
} catch (e) {}
export default async function storybookExecutor(
export default async function* storybookExecutor(
options: StorybookExecutorOptions,
context: ExecutorContext
) {
@ -43,8 +43,10 @@ export default async function storybookExecutor(
const option = storybookOptionMapper(options, frameworkOptions, context);
await runInstance(option);
yield { success: true };
// This Promise intentionally never resolves, leaving the process running
return new Promise<{ success: boolean }>(() => {});
await new Promise<{ success: boolean }>(() => {});
}
function runInstance(options: StorybookExecutorOptions) {