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) => { it('should provide options to storybook', async () => {
storybookExecutor(options, context); const iterator = storybookExecutor(options, context);
setTimeout(() => { const { value } = await iterator.next();
expect(value).toEqual({ success: true });
expect(buildDevStandalone).toHaveBeenCalled(); expect(buildDevStandalone).toHaveBeenCalled();
done();
}, 0);
}); });
}); });

View File

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