Skip to content

Commit

Permalink
chore: enable coverage
Browse files Browse the repository at this point in the history
Had to downgrade jest to v24. Coverage is broken for non-js files in
v2: jestjs/jest#9490
  • Loading branch information
joelmukuthu committed Mar 21, 2020
1 parent 0557b8e commit 6d5b401
Show file tree
Hide file tree
Showing 6 changed files with 770 additions and 975 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
node_modules
public/bundle.*
public/images/
/coverage/
7 changes: 6 additions & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,17 @@ module.exports = {
// The directory where Jest should output its coverage files
coverageDirectory: "coverage",

// Only cover *.svelte files
collectCoverageFrom: [
'<rootDir>/src/**/*.svelte'
],

// preprocess *.ts test files with ts-jest
preset: 'ts-jest',

// look for tests in *.spec.ts files
testMatch: [
'**/*.spec.ts'
'<rootDir>/src/**/*.spec.ts'
],

// preprocess *.svelte files with svelte-processor (configured via svelte.config.js)
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"cross-env": "^5.2.0",
"css-loader": "^2.1.1",
"file-loader": "^6.0.0",
"jest": "^25.1.0",
"jest": "24",
"mini-css-extract-plugin": "^0.6.0",
"serve": "^11.0.0",
"style-loader": "^0.23.1",
Expand All @@ -26,6 +26,7 @@
"scripts": {
"build": "cross-env NODE_ENV=production webpack",
"dev": "webpack-dev-server --content-base public",
"test": "jest"
"test": "jest",
"coverage": "jest --coverage"
}
}
2 changes: 1 addition & 1 deletion src/App.svelte
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script>
import Button from './Button';
import Button from './Button.svelte';
export let name;
</script>
Expand Down
4 changes: 4 additions & 0 deletions src/Button.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
function handleClick() {
buttonText = 'Button Clicked'
}
// These lines are not covered by tests:
const add = (a:number, b:number) => a+b;
add(1,2)
</script>

<h1>Hello {name}!</h1>
Expand Down

0 comments on commit 6d5b401

Please sign in to comment.