@@ -64,33 +64,57 @@ describe('@nx/storybook/plugin', () => {
64
64
context
65
65
) ;
66
66
67
- expect ( nodes . at ( 0 ) ?. [ 0 ] ) . toStrictEqual ( 'my-app/.storybook/main.ts' ) ;
68
- expect ( nodes . at ( 0 ) ?. [ 1 ] ?. [ 'projects' ] ?. [ 'my-app' ] ?. targets ) . toBeDefined ( ) ;
69
- expect (
70
- nodes . at ( 0 ) ?. [ 1 ] ?. [ 'projects' ] ?. [ 'my-app' ] ?. targets [ 'build-storybook' ]
71
- ) . toMatchObject ( {
72
- command : 'storybook build' ,
73
- options : {
74
- cwd : 'my-app' ,
75
- } ,
76
- cache : true ,
77
- outputs : [
78
- '{projectRoot}/storybook-static' ,
79
- '{options.output-dir}' ,
80
- '{options.outputDir}' ,
81
- '{options.o}' ,
82
- ] ,
83
- inputs : [
84
- 'production' ,
85
- '^production' ,
86
- { externalDependencies : [ 'storybook' ] } ,
87
- ] ,
88
- } ) ;
89
- expect (
90
- nodes . at ( 0 ) ?. [ 1 ] ?. [ 'projects' ] ?. [ 'my-app' ] ?. targets [ 'serve-storybook' ]
91
- ) . toMatchObject ( {
92
- command : 'storybook dev' ,
93
- } ) ;
67
+ expect ( nodes ) . toMatchInlineSnapshot ( `
68
+ [
69
+ [
70
+ "my-app/.storybook/main.ts",
71
+ {
72
+ "projects": {
73
+ "my-app": {
74
+ "root": "my-app",
75
+ "targets": {
76
+ "build-storybook": {
77
+ "cache": true,
78
+ "command": "storybook build",
79
+ "inputs": [
80
+ "production",
81
+ "^production",
82
+ {
83
+ "externalDependencies": [
84
+ "storybook",
85
+ ],
86
+ },
87
+ ],
88
+ "options": {
89
+ "cwd": "my-app",
90
+ },
91
+ "outputs": [
92
+ "{projectRoot}/storybook-static",
93
+ "{options.output-dir}",
94
+ "{options.outputDir}",
95
+ "{options.o}",
96
+ ],
97
+ },
98
+ "serve-storybook": {
99
+ "command": "storybook dev",
100
+ "options": {
101
+ "cwd": "my-app",
102
+ },
103
+ },
104
+ "static-storybook": {
105
+ "executor": "@nx/web:file-server",
106
+ "options": {
107
+ "buildTarget": "build-storybook",
108
+ "staticFilePath": "my-app/storybook-static",
109
+ },
110
+ },
111
+ },
112
+ },
113
+ },
114
+ },
115
+ ],
116
+ ]
117
+ ` ) ;
94
118
} ) ;
95
119
96
120
it ( 'should create angular nodes' , async ( ) => {
@@ -115,49 +139,63 @@ describe('@nx/storybook/plugin', () => {
115
139
context
116
140
) ;
117
141
118
- expect ( nodes . at ( 0 ) ?. [ 0 ] ) . toStrictEqual ( 'my-ng-app/.storybook/main.ts' ) ;
119
- expect (
120
- nodes . at ( 0 ) ?. [ 1 ] ?. [ 'projects' ] ?. [ 'my-ng-app' ] ?. targets
121
- ) . toBeDefined ( ) ;
122
- expect (
123
- nodes . at ( 0 ) ?. [ 1 ] ?. [ 'projects' ] ?. [ 'my-ng-app' ] ?. targets ?. [
124
- 'build-storybook'
125
- ]
126
- ) . toMatchObject ( {
127
- executor : '@storybook/angular:build-storybook' ,
128
- options : {
129
- outputDir : 'my-ng-app/storybook-static' ,
130
- configDir : 'my-ng-app/.storybook' ,
131
- browserTarget : 'my-ng-app:build-storybook' ,
132
- compodoc : false ,
133
- } ,
134
- cache : true ,
135
- outputs : [
136
- '{projectRoot}/storybook-static' ,
137
- '{options.output-dir}' ,
138
- '{options.outputDir}' ,
139
- '{options.o}' ,
140
- ] ,
141
- inputs : [
142
- 'production' ,
143
- '^production' ,
144
- {
145
- externalDependencies : [ 'storybook' , '@storybook/angular' ] ,
146
- } ,
147
- ] ,
148
- } ) ;
149
- expect (
150
- nodes . at ( 0 ) ?. [ 1 ] ?. [ 'projects' ] ?. [ 'my-ng-app' ] ?. targets ?. [
151
- 'serve-storybook'
142
+ expect ( nodes ) . toMatchInlineSnapshot ( `
143
+ [
144
+ [
145
+ "my-ng-app/.storybook/main.ts",
146
+ {
147
+ "projects": {
148
+ "my-ng-app": {
149
+ "root": "my-ng-app",
150
+ "targets": {
151
+ "build-storybook": {
152
+ "cache": true,
153
+ "executor": "@storybook/angular:build-storybook",
154
+ "inputs": [
155
+ "production",
156
+ "^production",
157
+ {
158
+ "externalDependencies": [
159
+ "storybook",
160
+ "@storybook/angular",
161
+ ],
162
+ },
163
+ ],
164
+ "options": {
165
+ "browserTarget": "my-ng-app:build-storybook",
166
+ "compodoc": false,
167
+ "configDir": "my-ng-app/.storybook",
168
+ "outputDir": "my-ng-app/storybook-static",
169
+ },
170
+ "outputs": [
171
+ "{projectRoot}/storybook-static",
172
+ "{options.output-dir}",
173
+ "{options.outputDir}",
174
+ "{options.o}",
175
+ ],
176
+ },
177
+ "serve-storybook": {
178
+ "executor": "@storybook/angular:start-storybook",
179
+ "options": {
180
+ "browserTarget": "my-ng-app:build-storybook",
181
+ "compodoc": false,
182
+ "configDir": "my-ng-app/.storybook",
183
+ },
184
+ },
185
+ "static-storybook": {
186
+ "executor": "@nx/web:file-server",
187
+ "options": {
188
+ "buildTarget": "build-storybook",
189
+ "staticFilePath": "my-ng-app/storybook-static",
190
+ },
191
+ },
192
+ },
193
+ },
194
+ },
195
+ },
196
+ ],
152
197
]
153
- ) . toMatchObject ( {
154
- executor : '@storybook/angular:start-storybook' ,
155
- options : {
156
- browserTarget : 'my-ng-app:build-storybook' ,
157
- configDir : 'my-ng-app/.storybook' ,
158
- compodoc : false ,
159
- } ,
160
- } ) ;
198
+ ` ) ;
161
199
} ) ;
162
200
163
201
it ( 'should support main.js' , async ( ) => {
@@ -186,39 +224,57 @@ describe('@nx/storybook/plugin', () => {
186
224
context
187
225
) ;
188
226
189
- expect ( nodes . at ( 0 ) ?. [ 0 ] ) . toStrictEqual ( 'my-react-lib/.storybook/main.js' ) ;
190
- expect (
191
- nodes . at ( 0 ) ?. [ 1 ] ?. [ 'projects' ] ?. [ 'my-react-lib' ] ?. targets
192
- ) . toBeDefined ( ) ;
193
- expect (
194
- nodes . at ( 0 ) ?. [ 1 ] ?. [ 'projects' ] ?. [ 'my-react-lib' ] ?. targets ?. [
195
- 'build-storybook'
196
- ]
197
- ) . toMatchObject ( {
198
- command : 'storybook build' ,
199
- options : {
200
- cwd : 'my-react-lib' ,
201
- } ,
202
- cache : true ,
203
- outputs : [
204
- '{projectRoot}/storybook-static' ,
205
- '{options.output-dir}' ,
206
- '{options.outputDir}' ,
207
- '{options.o}' ,
208
- ] ,
209
- inputs : [
210
- 'production' ,
211
- '^production' ,
212
- { externalDependencies : [ 'storybook' ] } ,
213
- ] ,
214
- } ) ;
215
- expect (
216
- nodes . at ( 0 ) ?. [ 1 ] ?. [ 'projects' ] ?. [ 'my-react-lib' ] ?. targets ?. [
217
- 'serve-storybook'
227
+ expect ( nodes ) . toMatchInlineSnapshot ( `
228
+ [
229
+ [
230
+ "my-react-lib/.storybook/main.js",
231
+ {
232
+ "projects": {
233
+ "my-react-lib": {
234
+ "root": "my-react-lib",
235
+ "targets": {
236
+ "build-storybook": {
237
+ "cache": true,
238
+ "command": "storybook build",
239
+ "inputs": [
240
+ "production",
241
+ "^production",
242
+ {
243
+ "externalDependencies": [
244
+ "storybook",
245
+ ],
246
+ },
247
+ ],
248
+ "options": {
249
+ "cwd": "my-react-lib",
250
+ },
251
+ "outputs": [
252
+ "{projectRoot}/storybook-static",
253
+ "{options.output-dir}",
254
+ "{options.outputDir}",
255
+ "{options.o}",
256
+ ],
257
+ },
258
+ "serve-storybook": {
259
+ "command": "storybook dev",
260
+ "options": {
261
+ "cwd": "my-react-lib",
262
+ },
263
+ },
264
+ "static-storybook": {
265
+ "executor": "@nx/web:file-server",
266
+ "options": {
267
+ "buildTarget": "build-storybook",
268
+ "staticFilePath": "my-react-lib/storybook-static",
269
+ },
270
+ },
271
+ },
272
+ },
273
+ },
274
+ },
275
+ ],
218
276
]
219
- ) . toMatchObject ( {
220
- command : 'storybook dev' ,
221
- } ) ;
277
+ ` ) ;
222
278
} ) ;
223
279
224
280
function mockStorybookMainConfig (
0 commit comments