Skip to content

Commit ad86441

Browse files
Merge pull request #1037 from storybookjs/next
Create a new pull request by comparing changes across two branches.
2 parents 1b2b73a + e7445ef commit ad86441

File tree

3,531 files changed

+113068
-100682
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

3,531 files changed

+113068
-100682
lines changed

.circleci/config.yml

Lines changed: 91 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ executors:
2525
default: "small"
2626
working_directory: /tmp/storybook
2727
docker:
28-
- image: cimg/node:22.13.1
28+
- image: cimg/node:22.15.0
2929
environment:
3030
NODE_OPTIONS: --max_old_space_size=6144
3131
resource_class: <<parameters.class>>
@@ -51,7 +51,7 @@ executors:
5151
default: "small"
5252
working_directory: /tmp/storybook
5353
docker:
54-
- image: cimg/node:22.13.1-browsers
54+
- image: cimg/node:22.15.0-browsers
5555
environment:
5656
NODE_OPTIONS: --max_old_space_size=6144
5757
resource_class: <<parameters.class>>
@@ -115,15 +115,15 @@ jobs:
115115
- restore_cache:
116116
name: Restore Yarn cache
117117
keys:
118-
- prettydocs-yarn-2-cache-v7--{{ checksum "code/yarn.lock" }}--{{ checksum "scripts/yarn.lock" }}
118+
- prettydocs-yarn-2-cache-v8--{{ checksum "code/yarn.lock" }}--{{ checksum "scripts/yarn.lock" }}
119119
- run:
120120
name: Install
121121
command: |
122122
cd scripts
123123
yarn install
124124
- save_cache:
125125
name: Save Yarn cache
126-
key: prettydocs-yarn-2-cache-v7--{{ checksum "code/yarn.lock" }}--{{ checksum "scripts/yarn.lock" }}
126+
key: prettydocs-yarn-2-cache-v8--{{ checksum "code/yarn.lock" }}--{{ checksum "scripts/yarn.lock" }}
127127
paths:
128128
- ~/.yarn/berry/cache
129129
- run:
@@ -141,7 +141,7 @@ jobs:
141141
- restore_cache:
142142
name: Restore Yarn cache
143143
keys:
144-
- build-yarn-2-cache-v4--{{ checksum "code/yarn.lock" }}--{{ checksum "scripts/yarn.lock" }}
144+
- build-yarn-2-cache-v5--{{ checksum "code/yarn.lock" }}--{{ checksum "scripts/yarn.lock" }}
145145
- run:
146146
name: Compile
147147
command: |
@@ -158,7 +158,7 @@ jobs:
158158
path: code/bench/esbuild-metafiles
159159
- save_cache:
160160
name: Save Yarn cache
161-
key: build-yarn-2-cache-v4--{{ checksum "code/yarn.lock" }}--{{ checksum "scripts/yarn.lock" }}
161+
key: build-yarn-2-cache-v5--{{ checksum "code/yarn.lock" }}--{{ checksum "scripts/yarn.lock" }}
162162
paths:
163163
- ~/.yarn/berry/cache
164164
- persist_to_workspace:
@@ -170,7 +170,6 @@ jobs:
170170
- code/bench
171171
- code/examples
172172
- code/frameworks
173-
- code/deprecated
174173
- code/lib
175174
- code/core
176175
- code/builders
@@ -195,7 +194,7 @@ jobs:
195194
- cancel-workflow-on-failure
196195
knip:
197196
executor:
198-
class: medium
197+
class: large
199198
name: sb_node_22_classic
200199
steps:
201200
- git-shallow-clone/checkout_advanced:
@@ -271,7 +270,7 @@ jobs:
271270
- restore_cache:
272271
name: Restore Yarn cache
273272
keys:
274-
- build-yarn-2-cache-v4--{{ checksum "code/yarn.lock" }}--{{ checksum "scripts/yarn.lock" }}
273+
- build-yarn-2-cache-v5--{{ checksum "code/yarn.lock" }}--{{ checksum "scripts/yarn.lock" }}
275274
- run:
276275
name: Compile
277276
command: |
@@ -314,9 +313,9 @@ jobs:
314313
- cancel-workflow-on-failure
315314
unit-tests:
316315
executor:
317-
class: large
316+
class: xlarge
318317
name: sb_playwright
319-
parallelism: 4
318+
parallelism: 2
320319
steps:
321320
- git-shallow-clone/checkout_advanced:
322321
clone_options: "--depth 1 --verbose"
@@ -368,10 +367,10 @@ jobs:
368367
- report-workflow-on-failure
369368
chromatic-internal-storybook:
370369
executor:
371-
class: medium
370+
class: large
372371
name: sb_node_22_browsers
373372
environment:
374-
NODE_OPTIONS: --max_old_space_size=6144
373+
NODE_OPTIONS: --max_old_space_size=4096
375374
steps:
376375
# switched this to the CircleCI helper to get the full git history for TurboSnap
377376
- checkout
@@ -399,8 +398,14 @@ jobs:
399398
- attach_workspace:
400399
at: .
401400
- run:
402-
name: Enable Corepack
403-
command: sudo corepack enable yarn
401+
name: Setup Corepack
402+
command: |
403+
# Enable corepack
404+
sudo corepack enable
405+
406+
# Verify yarn is working
407+
which yarn
408+
yarn --version
404409
- run:
405410
name: Starting Event Collector
406411
command: yarn jiti ./event-log-collector.ts
@@ -475,7 +480,7 @@ jobs:
475480
parallelism:
476481
type: integer
477482
executor:
478-
class: large
483+
class: xlarge
479484
name: sb_playwright
480485
parallelism: << parameters.parallelism >>
481486
steps:
@@ -621,7 +626,33 @@ jobs:
621626
command: yarn upload-bench $(yarn get-template --cadence << pipeline.parameters.workflow >> --task bench) << pipeline.parameters.ghPrNumber >> << pipeline.parameters.ghBaseBranch >>
622627
- report-workflow-on-failure:
623628
template: $(yarn get-template --cadence << pipeline.parameters.workflow >> --task bench)
624-
test-empty-init:
629+
test-init-features:
630+
executor:
631+
class: small
632+
name: sb_node_22_browsers
633+
steps:
634+
- git-shallow-clone/checkout_advanced:
635+
clone_options: "--depth 1 --verbose"
636+
- attach_workspace:
637+
at: .
638+
- run:
639+
name: Storybook init for features
640+
command: |
641+
cd code
642+
yarn local-registry --open &
643+
yarn wait-on tcp:127.0.0.1:6001
644+
cd ../../
645+
mkdir features-1
646+
cd features-1
647+
npm set registry http://localhost:6001
648+
npx create-storybook --yes --package-manager npm --features dev docs test
649+
npx vitest
650+
environment:
651+
IN_STORYBOOK_SANDBOX: true
652+
STORYBOOK_INIT_EMPTY_TYPE: react-vite-ts
653+
STORYBOOK_DISABLE_TELEMETRY: true
654+
655+
test-init-empty:
625656
executor:
626657
class: small
627658
name: sb_node_22_browsers
@@ -853,13 +884,17 @@ workflows:
853884
parallelism: 5
854885
requires:
855886
- create-sandboxes
856-
- bench-sandboxes:
857-
parallelism: 5
858-
requires:
859-
- create-sandboxes
887+
# TODO: don't forget to reenable this
888+
# - bench-sandboxes:
889+
# parallelism: 5
890+
# requires:
891+
# - create-sandboxes
860892
- test-ui-testing-module:
861893
requires:
862894
- build
895+
- test-init-features:
896+
requires:
897+
- build
863898
- test-portable-stories:
864899
requires:
865900
- build
@@ -902,23 +937,23 @@ workflows:
902937
requires:
903938
- unit-tests
904939
- create-sandboxes:
905-
parallelism: 20
940+
parallelism: 18
906941
requires:
907942
- build
908943
- chromatic-sandboxes:
909-
parallelism: 17
944+
parallelism: 15
910945
requires:
911946
- create-sandboxes
912947
- e2e-production:
913-
parallelism: 15
948+
parallelism: 13
914949
requires:
915950
- create-sandboxes
916951
- e2e-dev:
917952
parallelism: 1
918953
requires:
919954
- create-sandboxes
920955
- test-runner-production:
921-
parallelism: 15
956+
parallelism: 13
922957
requires:
923958
- create-sandboxes
924959
- vitest-integration:
@@ -934,15 +969,19 @@ workflows:
934969
- test-ui-testing-module:
935970
requires:
936971
- build
937-
- bench-sandboxes:
938-
parallelism: 5
972+
- test-init-features:
939973
requires:
940-
- create-sandboxes
941-
# TODO: reenable once we find out the source of flakyness
942-
# - test-runner-dev:
943-
# parallelism: 4
944-
# requires:
945-
# - create-sandboxes
974+
- build
975+
# TODO: don't forget to reenable this
976+
# - bench-sandboxes:
977+
# parallelism: 5
978+
# requires:
979+
# - create-sandboxes
980+
# TODO: reenable once we find out the source of flakyness
981+
# - test-runner-dev:
982+
# parallelism: 4
983+
# requires:
984+
# - create-sandboxes
946985
daily:
947986
when:
948987
equal: [daily, << pipeline.parameters.workflow >>]
@@ -972,30 +1011,30 @@ workflows:
9721011
requires:
9731012
- build
9741013
- create-sandboxes:
975-
parallelism: 37
1014+
parallelism: 31
9761015
requires:
9771016
- build
9781017
# - smoke-test-sandboxes: # disabled for now
9791018
# requires:
9801019
# - create-sandboxes
9811020
- chromatic-sandboxes:
982-
parallelism: 34
1021+
parallelism: 28
9831022
requires:
9841023
- create-sandboxes
9851024
- e2e-production:
986-
parallelism: 32
1025+
parallelism: 26
9871026
requires:
9881027
- create-sandboxes
9891028
- e2e-dev:
9901029
parallelism: 1
9911030
requires:
9921031
- create-sandboxes
9931032
- test-runner-production:
994-
parallelism: 32
1033+
parallelism: 26
9951034
requires:
9961035
- create-sandboxes
9971036
- vitest-integration:
998-
parallelism: 11
1037+
parallelism: 9
9991038
requires:
10001039
- create-sandboxes
10011040
- test-portable-stories:
@@ -1007,7 +1046,10 @@ workflows:
10071046
- test-ui-testing-module:
10081047
requires:
10091048
- build
1010-
- test-empty-init:
1049+
- test-init-features:
1050+
requires:
1051+
- build
1052+
- test-init-empty:
10111053
requires:
10121054
- build
10131055
matrix:
@@ -1025,13 +1067,14 @@ workflows:
10251067
# --smoke-test is not supported for the angular builder right now
10261068
# - "angular-cli"
10271069
- "lit-vite-ts"
1028-
- bench-sandboxes:
1029-
parallelism: 5
1030-
requires:
1031-
- create-sandboxes
1070+
# TODO: don't forget to reenable this
1071+
# - bench-sandboxes:
1072+
# parallelism: 5
1073+
# requires:
1074+
# - create-sandboxes
10321075

1033-
# TODO: reenable once we find out the source of flakyness
1034-
# - test-runner-dev:
1035-
# parallelism: 4
1036-
# requires:
1037-
# - create-sandboxes
1076+
# TODO: reenable once we find out the source of flakyness
1077+
# - test-runner-dev:
1078+
# parallelism: 4
1079+
# requires:
1080+
# - create-sandboxes

.cursor/rules/spy-mocking.mdc

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
---
2+
description: Rules for consistent and type-safe mocking in Vitest tests
3+
globs: "**/*.test.{ts,tsx,js,jsx}"
4+
alwaysApply: true
5+
---
6+
7+
# Spy Mocking Rules for Vitest Tests
8+
9+
## Mocking Approach
10+
11+
When mocking packages or files in Vitest-based tests, follow these rules:
12+
13+
1. Use `vi.mock()` with the `spy: true` option for all package and file mocks
14+
2. Place all mocks at the top of the test file before any test cases
15+
3. Use `vi.mocked()` to type and access the mocked functions
16+
4. Implement mock behaviors in `beforeEach` blocks
17+
5. Mock all required dependencies that the test subject uses
18+
19+
## Mock Implementation Rules
20+
21+
1. Mock implementations should be placed in `beforeEach` blocks
22+
2. Each mock implementation should return a Promise for async functions
23+
3. Mock implementations should match the expected return type of the original function
24+
4. Use `vi.mocked()` to access and implement mock behaviors
25+
5. Mock all required properties and methods that the test subject uses
26+
27+
## Avoided Patterns
28+
29+
The following mocking patterns should be avoided:
30+
31+
1. Direct function mocking without `vi.mocked()`
32+
2. Mock implementations outside of `beforeEach` blocks
33+
3. Mocking without the `spy: true` option
34+
4. Inline mock implementations within test cases
35+
5. Mocking only a subset of required dependencies
36+
37+
## Best Practices
38+
39+
1. Mock at the highest level of abstraction needed
40+
2. Keep mock implementations simple and focused
41+
3. Use type-safe mocking with `vi.mocked()`
42+
4. Document complex mock behaviors
43+
5. Group related mocks together

0 commit comments

Comments
 (0)