Mat*_*újo 1 testing continuous-integration reactjs storybook
我一直在学习使用交互插件在 Storykook 中进行测试。但我不知道如何在主分支推送之前运行测试(进行部署),我发现的一种方法是使用 git hook(pre-puch)运行所有测试,但是当我的应用程序长大了,我想使用管道 ci/cd 而不是 git hooks
感谢您的阅读!
你可以在这里找到该应用程序
我找到答案
基本上你需要在 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\"
Run Code Online (Sandbox Code Playgroud)
不要忘记同时安装 wait-on 和 http-server。并在您的 ci 作业中运行此脚本。
您可以查看该存储库以查找示例
https://www.npmjs.com/package/@storybook/test-runner#running-in-ci