-
Notifications
You must be signed in to change notification settings - Fork 1
/
fix-storybook-tsconfig.spec.ts
83 lines (73 loc) · 2.33 KB
/
fix-storybook-tsconfig.spec.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
import { readJson, Tree, writeJson } from '@nrwl/devkit';
import { createTreeWithEmptyWorkspace } from '@nrwl/devkit/testing';
import updateStorybookTsconfig from './fix-storybook-tsconfig';
describe('Fix Storybook TSConfig to avoid VSCode error', () => {
let tree: Tree;
describe('when project has valid configuration and targets', () => {
beforeEach(async () => {
tree = createTreeWithEmptyWorkspace();
writeJson(tree, 'workspace.json', {
projects: {
['home-ui-react']: {
projectType: 'library',
root: 'libs/home/ui-react',
sourceRoot: 'libs/home/ui-react/src',
targets: {
storybook: {
builder: '@nrwl/storybook:storybook',
options: {
uiFramework: '@storybook/react',
port: 4400,
config: {
configFolder: 'libs/home/ui-react/.storybook',
},
},
},
},
},
},
});
writeJson(tree, 'libs/home/ui-react/.storybook/tsconfig.json', {
extends: '../tsconfig.json',
compilerOptions: {
emitDecoratorMetadata: true,
},
});
});
it(`should add outDir to the storybook tsconfig to avoid VSCode errors`, async () => {
await updateStorybookTsconfig(tree);
expect(
readJson(tree, 'libs/home/ui-react/.storybook/tsconfig.json')
).toMatchObject({
extends: '../tsconfig.json',
compilerOptions: {
emitDecoratorMetadata: true,
outDir: '',
},
});
});
});
describe('when project has no targets', () => {
beforeEach(async () => {
tree = createTreeWithEmptyWorkspace();
writeJson(tree, 'workspace.json', {
projects: {
['home-ui-react']: {
projectType: 'library',
root: 'libs/home/ui-react',
sourceRoot: 'libs/home/ui-react/src',
},
},
});
writeJson(tree, 'libs/home/ui-react/.storybook/tsconfig.json', {
extends: '../tsconfig.json',
compilerOptions: {
emitDecoratorMetadata: true,
},
});
});
it(`should not throw errors`, async () => {
await expect(updateStorybookTsconfig(tree)).resolves.not.toThrow();
});
});
});