Skip to content

Commit b00a8ce

Browse files
committed
Merge branch 'valentin/propagate-error-in-testing' of github.com:storybookjs/storybook into valentin/propagate-error-in-testing
2 parents e4697f9 + 758aaa1 commit b00a8ce

File tree

8 files changed

+418
-119
lines changed

8 files changed

+418
-119
lines changed

code/addons/test/package.json

+3
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,11 @@
7373
"@storybook/csf": "^0.1.11"
7474
},
7575
"devDependencies": {
76+
"@types/semver": "^7",
7677
"@vitest/browser": "^2.0.0",
78+
"boxen": "^8.0.1",
7779
"find-up": "^7.0.0",
80+
"semver": "^7.6.3",
7881
"tinyrainbow": "^1.2.0",
7982
"ts-dedent": "^2.2.0",
8083
"vitest": "^2.0.0"

code/addons/test/project.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@
55
"targets": {
66
"build": {}
77
}
8-
}
8+
}
+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import { colors, logger } from 'storybook/internal/node-logger';
2+
3+
import boxen, { type Options } from 'boxen';
4+
5+
const fancy =
6+
process.platform !== 'win32' || process.env.CI || process.env.TERM === 'xterm-256color';
7+
8+
export const step = colors.gray('›');
9+
export const info = colors.blue(fancy ? 'ℹ' : 'i');
10+
export const success = colors.green(fancy ? '✔' : '√');
11+
export const warning = colors.orange(fancy ? '⚠' : '‼');
12+
export const error = colors.red(fancy ? '✖' : '×');
13+
14+
const baseOptions: Options = {
15+
borderStyle: 'round',
16+
padding: 1,
17+
};
18+
19+
export const print = (message: string, options: Options) => {
20+
logger.line(1);
21+
logger.plain(boxen(message, { ...baseOptions, ...options }));
22+
};
23+
24+
export const printInfo = (title: string, message: string, options?: Options) =>
25+
print(message, { borderColor: 'blue', title, ...options });
26+
27+
export const printWarning = (title: string, message: string, options?: Options) =>
28+
print(message, { borderColor: 'yellow', title, ...options });
29+
30+
export const printError = (title: string, message: string, options?: Options) =>
31+
print(message, { borderColor: 'red', title, ...options });
32+
33+
export const printSuccess = (title: string, message: string, options?: Options) =>
34+
print(message, { borderColor: 'green', title, ...options });

0 commit comments

Comments
 (0)