fix(storybook): do not infer a test-storybook task if @storybook/test-runner is not installed (#23034)
This commit is contained in:
parent
521d417a16
commit
9077ae8abb
@ -21,6 +21,7 @@ describe('@nx/storybook/plugin', () => {
|
||||
workspaceRoot: tempFs.tempDir,
|
||||
configFiles: [],
|
||||
};
|
||||
tempFs.createFileSync('package.json', JSON.stringify({ name: 'repo' }));
|
||||
tempFs.createFileSync(
|
||||
'my-app/project.json',
|
||||
JSON.stringify({ name: 'my-app' })
|
||||
@ -89,11 +90,6 @@ describe('@nx/storybook/plugin', () => {
|
||||
).toMatchObject({
|
||||
command: 'storybook dev',
|
||||
});
|
||||
expect(
|
||||
nodes?.['projects']?.['my-app']?.targets?.['test-storybook']
|
||||
).toMatchObject({
|
||||
command: 'test-storybook',
|
||||
});
|
||||
});
|
||||
|
||||
it('should create angular nodes', async () => {
|
||||
@ -158,11 +154,6 @@ describe('@nx/storybook/plugin', () => {
|
||||
compodoc: false,
|
||||
},
|
||||
});
|
||||
expect(
|
||||
nodes?.['projects']?.['my-ng-app']?.targets?.['test-storybook']
|
||||
).toMatchObject({
|
||||
command: 'test-storybook',
|
||||
});
|
||||
});
|
||||
|
||||
it('should support main.js', async () => {
|
||||
@ -217,11 +208,6 @@ describe('@nx/storybook/plugin', () => {
|
||||
).toMatchObject({
|
||||
command: 'storybook dev',
|
||||
});
|
||||
expect(
|
||||
nodes?.['projects']?.['my-react-lib']?.targets?.['test-storybook']
|
||||
).toMatchObject({
|
||||
command: 'test-storybook',
|
||||
});
|
||||
});
|
||||
|
||||
function mockStorybookMainConfig(
|
||||
|
||||
@ -148,7 +148,9 @@ async function buildStorybookTargets(
|
||||
configFilePath
|
||||
);
|
||||
|
||||
targets[options.testStorybookTargetName] = testTarget(projectRoot);
|
||||
if (isStorybookTestRunnerInstalled()) {
|
||||
targets[options.testStorybookTargetName] = testTarget(projectRoot);
|
||||
}
|
||||
|
||||
targets[options.staticStorybookTargetName] = serveStaticTarget(
|
||||
options,
|
||||
@ -324,3 +326,12 @@ function buildProjectName(
|
||||
}
|
||||
return name;
|
||||
}
|
||||
|
||||
function isStorybookTestRunnerInstalled(): boolean {
|
||||
try {
|
||||
require.resolve('@storybook/test-runner');
|
||||
return true;
|
||||
} catch (e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user