Skip to content

Commit

Permalink
Merge pull request #147 from SVendittelli/test/coverage
Browse files Browse the repository at this point in the history
test: collect test coverage
  • Loading branch information
SVendittelli authored Dec 21, 2023
2 parents cb1aa59 + 6a723dc commit e9b055a
Show file tree
Hide file tree
Showing 8 changed files with 573 additions and 10 deletions.
21 changes: 17 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,24 @@ jobs:
run: npm run test:ci
- name: Smoke & Acceptance tests
run: |
npm run build-storybook --quiet
npx playwright install
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 && npm run test-storybook"
npm run test:storybook
- name: Upload jest coverage reports to Codecov
uses: codecov/codecov-action@v3
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
with:
fail_ci_if_error: true
flags: jest
directory: coverage/jest
- name: Upload storybook coverage reports to Codecov
uses: codecov/codecov-action@v3
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
with:
fail_ci_if_error: true
flags: storybook
directory: coverage/storybook

e2e-tests:
needs: lint-and-build
Expand Down
7 changes: 2 additions & 5 deletions .husky/pre-push
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,8 @@
npm run test:ci

# Storybook tests
npm run build-storybook -- --quiet
npx concurrently -k -s first -n "SB,TEST" \
"npx http-server storybook-static --port 6006 --silent" \
"npx wait-on tcp:127.0.0.1:6006 && npm run test-storybook"
npm run test:storybook

# e2e tests
npx playwright install
npx playwright install --with-deps
npm run e2e
1 change: 1 addition & 0 deletions .storybook/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const config: StorybookConfig = {
"@storybook/addon-interactions",
"@storybook/addon-themes",
"@storybook/addon-a11y",
"@storybook/addon-coverage",
],
framework: {
name: "@storybook/nextjs",
Expand Down
1 change: 1 addition & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"recommendations": [
"bradlc.vscode-tailwindcss",
"codecov.codecov",
"davidanson.vscode-markdownlint",
"dbaeumer.vscode-eslint",
"editorconfig.editorconfig",
Expand Down
15 changes: 15 additions & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
coverage:
status:
project:
default:
target: auto # auto compares coverage to the previous base commit
threshold: 1% # fail if coverage drops by more than 1%

flag_management:
default_rules: # the rules that will be followed for any flag added, generally
statuses:
- type: project
target: auto
threshold: 1%
- type: patch
target: 90%
9 changes: 9 additions & 0 deletions jest.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,15 @@ const config = {
moduleNameMapper: {
"^@/(.*)$": "<rootDir>/$1",
},
collectCoverage: true,
collectCoverageFrom: [
"./app/**",
"./components/**",
"./config/**",
"./libs/**",
"./middleware.ts",
],
coverageDirectory: "./coverage/jest",
};

// createJestConfig is exported this way to ensure that next/jest can load the Next.js config which is async
Expand Down
Loading

0 comments on commit e9b055a

Please sign in to comment.