如何使用故事书和 github 操作在 ci 管道中设置运行测试

问题描述 投票:0回答:2
我一直在学习使用

交互插件在storykook中进行测试。 但我不知道如何在主分支推送之前运行测试(进行部署),我发现的一种方法是使用 git hook 运行所有测试(pre-puch),但是运行所有测试不是一个好的选择当我的应用程序长大后我想使用管道 ci/cd 而不是 git hooks

感谢阅读!

您可以在这里

找到该应用程序

reactjs testing continuous-integration storybook
2个回答
6
投票
我找到答案了

基本上,您需要在 package.json 中创建一个脚本来运行该代码

concurrently -k -s first -n \"SB,TEST\" -c \"magenta,blue\" \"npm run storybook:build --quiet && npx http-server storybook-static --port 6006 --silent\" \"wait-on tcp:6006 && npm run storybook:test\"
不要忘记同时安装 wait-on 和 http-server。
并在您的 ci 作业中运行此脚本。

您可以查看

that 存储库以查找示例

https://www.npmjs.com/package/@storybook/test-runner#running-in-ci


0
投票
仍在逐步解决问题

"test-storybook:ci": "npx concurrently -k -s first -n \"SB,TEST\" -c \"magenta,blue\" \"npx http-server storybook-static --port 6006 --silent\" \"npx wait-on tcp:127.0.0.1:6006 && yarn test-storybook --url http://127.0.0.1:6006\"",
[TEST] /bin/sh:测试故事书:未找到
[测试] 错误 命令失败,退出代码为 127。
我们还有其他解决办法吗

© www.soinside.com 2019 - 2024. All rights reserved.