Skip to content

Commit

Permalink
Merge pull request #413 from MuckRock/jest-coverage
Browse files Browse the repository at this point in the history
Testing improvements
  • Loading branch information
allanlasser authored Jan 25, 2024
2 parents 026077d + a6fba13 commit 0baf0dc
Show file tree
Hide file tree
Showing 7 changed files with 179 additions and 40 deletions.
22 changes: 22 additions & 0 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Coverage Report

on:
pull_request:
branches: [master]

jobs:
coverage:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Use Node.js 18.x
uses: actions/setup-node@v3
with:
node-version: "18.x"
- run: npm ci
- run: npm run build
env:
NODE_ENV: production
- uses: ArtiomTr/jest-coverage-report-action@v2
with:
test-script: npm run test-coverage
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public/assets/
.env.*
playwright-report
test-results
coverage

# local fixtures, everyone should generate their own
tests/fixtures/development.json
Expand Down
8 changes: 5 additions & 3 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
/** @type {import('jest').Config} */
export default {
extensionsToTreatAsEsm: [".svelte"],
extensionsToTreatAsEsm: [".svelte", ".ts"],
moduleNameMapper: {
"^@/(.*)$": "<rootDir>/$1",
},
moduleFileExtensions: ["js", "svelte"],
moduleFileExtensions: ["js", "ts", "svelte"],
rootDir: "src",
setupFiles: ["dotenv/config"],
testEnvironment: "jsdom",
transform: {
"^.+\\.svelte$": ["svelte-jester", { preprocess: true }],
"^.+\\.ts$": ["ts-jest", { useESM: true }],
},

transformIgnorePatterns: ["/node_modules/(?!svue).+\\.js$"],
collectCoverageFrom: ["./**/*.{js,ts,svelte}"],
coverageReporters: ["html", "text-summary"],
};
175 changes: 143 additions & 32 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
"@storybook/svelte": "^7.6.4",
"@storybook/svelte-webpack5": "^7.6.4",
"@storybook/testing-library": "^0.2.2",
"@types/lucene": "^2.1.7",
"chromatic": "^9.1.0",
"eslint": "^7.32.0",
"jest": "^29.6.3",
Expand All @@ -81,7 +82,8 @@
"storybook": "7.6.4",
"storybook-mock-date-decorator": "^1.0.1",
"svelte-jester": "^3.0.0",
"tape": "^5.7.2"
"tape": "^5.7.2",
"ts-jest": "^29.1.2"
},
"scripts": {
"build": "webpack",
Expand All @@ -97,7 +99,8 @@
"serve": "serve public -l 80 --single",
"storybook": "storybook dev -p 6006",
"test": "NODE_OPTIONS=--experimental-vm-modules jest",
"test-watch": "jest --watchAll",
"test-watch": "NODE_OPTIONS=--experimental-vm-modules jest --watchAll",
"test-coverage": "NODE_OPTIONS=--experimental-vm-modules jest --coverage",
"test:browser": "playwright test",
"watch": "concurrently npm:serve npm:dev-embed npm:watch-app",
"watch-app": "cross-env NODE_ENV=development webpack watch --config webpack.app.config.js"
Expand Down
2 changes: 1 addition & 1 deletion src/api/test/fixtures/empty.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Page } from "../types/common";
import type { Page } from "../../types/common";

export const emptyList: Page<never> = {
count: 0,
Expand Down
4 changes: 2 additions & 2 deletions src/api/test/fixtures/project.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Page } from "../types/common";
import { Project } from "../types/project";
import type { Page } from "../../types/common";
import type { Project } from "../../types/project";

export const project: Project = {
id: 200006,
Expand Down

0 comments on commit 0baf0dc

Please sign in to comment.