Skip to content

Commit

Permalink
update merge
Browse files Browse the repository at this point in the history
  • Loading branch information
Yen Truong committed Aug 3, 2022
1 parent e884ffc commit 045154f
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 8 deletions.
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,9 @@
"prepublishOnly": "npm run build",
"storybook": "start-storybook -p 6006",
"build-storybook": "build-storybook",
"test:unit": "jest --coverage --coverageDirectory=coverage/unit",
"test:visual": "./tests/scripts/visual-coverage.sh"
"test:unit": "./tests/scripts/unit-coverage.sh",
"test:visual": "./tests/scripts/visual-coverage.sh",
"test:all": "./tests/scripts/all-coverage.sh"
},
"devDependencies": {
"@babel/core": "^7.17.5",
Expand Down
11 changes: 11 additions & 0 deletions tests/scripts/all-coverage.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash

# run unit test and visual coverage test
npm run test:unit
npm run test:visual

# merge
mkdir -p coverage/merge
cp coverage/unit/coverage-final.json coverage/merge/coverage-final.json
cp coverage/visual/coverage-storybook.json coverage/merge/coverage-storybook.json
nyc report --reporter=lcov --reporter=text -t coverage/merge --report-dir coverage/merge
4 changes: 4 additions & 0 deletions tests/scripts/unit-coverage.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash

# run jest tests and generate lcov coverage
jest --coverage --coverageDirectory=coverage/unit
19 changes: 13 additions & 6 deletions tests/scripts/visual-coverage.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
#generate coverage from storybook test runner
#!/bin/bash

#generate coverage from storybook test-runner
start-storybook -p 6006 --ci &
echo $! #get the background job ID
JOB_ID=$(echo $!) #get the background job ID
sleep 10
test-storybook --coverage

#todo: kill the start-storybook command
# kill the start-storybook command
kill -9 $JOB_ID

#generate lcov coverage for visual tests from story book
rm -r coverage/visual
nyc report --reporter=lcov -t coverage/storybook --report-dir coverage/visual

#generate lcov coverage
cp coverage/storybook/coverage-storybook.json coverage/coverage-storybook.json
nyc report --reporter=lcov -t coverage --report-dir coverage/visual
#clean up
cp coverage/storybook/coverage-storybook.json coverage/visual/coverage-storybook.json
rm -r coverage/storybook

0 comments on commit 045154f

Please sign in to comment.