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

Upvotes: 2

Views: 3648

Answers (2)

D...
D...

Reputation: 1

still phasing the issue

"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: test-storybook: not found [TEST] error Command failed with exit code 127. Do we have any other solution

Upvotes: 0

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

Upvotes: 7

Related Questions