Search code examples
reactjstestingcontinuous-integrationstorybook

how to set up run tests at ci pipeline with storybook and github actions


I have been learning to work with tests in storykook using interaction addon. But i don't know how to run tests before push at main branch(make deploy), A way i found is running all the tests using git hook(pre-puch), but run all test isn't a good choice when my app grow up and i want to use pipeline ci/cd instead git hooks

Thanks for read!

you can found that app here


Solution

  • i find an answer

    basically you need create a script in your package.json thats run that code

    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\"
    

    dont forget to install concurrently wait-on and http-server. And run this script in your ci job.

    you can check out that repository to find an example

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