Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Track and report test coverage #1783

Merged
merged 10 commits into from
Jul 8, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
node_modules
# Directories/files that may be generated by this project
build
coverage
gutenberg.pot
.vscode
*.log
yarn.lock
gutenberg.zip
node_modules
storybook-static
gutenberg.zip

# Directories/files that may appear in your environment
.DS_Store
*.log
phpcs.xml
yarn.lock
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Gutenberg
[![Build Status](https://travis-ci.org/WordPress/gutenberg.svg?branch=master)](https://travis-ci.org/WordPress/gutenberg)
[![Build Status](https://img.shields.io/travis/WordPress/gutenberg/master.svg)](https://travis-ci.org/WordPress/gutenberg)
[![Coverage](https://img.shields.io/coveralls/WordPress/gutenberg/master.svg)](https://coveralls.io/github/WordPress/gutenberg)

Printing since 1440.

Expand Down
52 changes: 29 additions & 23 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
"babel-traverse": "^6.24.1",
"chai": "^3.5.0",
"concurrently": "^3.4.0",
"coveralls": "^2.13.1",
"cross-env": "^3.2.4",
"deep-freeze": "0.0.1",
"dirty-chai": "^1.2.2",
Expand Down Expand Up @@ -84,37 +85,26 @@
"tinymce": "^4.5.6",
"webpack": "^2.2.1"
},
"scripts": {
"build": "cross-env BABEL_ENV=default NODE_ENV=production webpack",
"gettext-strings": "cross-env BABEL_ENV=gettext webpack",
"lint": "eslint . .storybook",
"dev": "cross-env BABEL_ENV=default webpack --watch",
"test": "npm run lint && npm run test-unit",
"ci": "concurrently \"npm run build\" \"npm test\"",
"package-plugin": "./bin/build-plugin-zip.sh",
"storybook": "start-storybook -p 6006",
"build-storybook": "build-storybook",
"test-unit": "jest",
"test-unit:coverage": "jest --coverage",
"test-unit:watch": "jest --watch"
},
"jest": {
"collectCoverageFrom": [
"**/blocks/**/*.js",
"**/components/**/*.js",
"**/date/**/*.js",
"**/editor/**/*.js",
"**/element/**/*.js",
"**/i18n/**/*.js",
"**/utils/**/*.js"
"blocks/**/*.js",
"components/**/*.js",
"date/**/*.js",
"editor/**/*.js",
"element/**/*.js",
"i18n/**/*.js",
"utils/**/*.js"
],
"coveragePathIgnorePatterns": [
"<rootDir>/components/clipboard-button/index.js",
"<rootDir>/components/notice/index.js",
"<rootDir>/components/notice/list.js",
"<rootDir>/components/form-toggle/index.js",
"<rootDir>/components/form-token-field/token.js"
"<rootDir>/components/form-token-field/token.js",
"<rootDir>/[^/]+/build/index.js",
".*/story/[^/]+.js"
],
"coverageDirectory": "coverage",
"moduleNameMapper": {
"\\.scss$": "<rootDir>/test/style-mock.js"
},
Expand All @@ -133,12 +123,28 @@
"**/editor/**/test/*.js",
"**/element/**/test/*.js",
"**/i18n/**/test/*.js",
"**/utils/**/test/*.js" ],
"**/utils/**/test/*.js"
],
"timers": "fake",
"transform": {
"^.+\\.jsx?$": "babel-jest",
"\\.pegjs$": "<rootDir>/test/pegjs-transform.js"
},
"verbose": true
},
"scripts": {
"build": "cross-env BABEL_ENV=default NODE_ENV=production webpack",
"gettext-strings": "cross-env BABEL_ENV=gettext webpack",
"lint": "eslint . .storybook",
"dev": "cross-env BABEL_ENV=default webpack --watch",
"test": "npm run lint && npm run test-unit",
"ci": "concurrently \"npm run build\" \"npm run lint\" \"npm run test-unit:coverage-ci\"",
"package-plugin": "./bin/build-plugin-zip.sh",
"storybook": "start-storybook -p 6006",
"build-storybook": "build-storybook",
"test-unit": "jest",
"test-unit:coverage": "jest --coverage",
"test-unit:coverage-ci": "jest --coverage && coveralls < coverage/lcov.info",
"test-unit:watch": "jest --watch"
}
}
1 change: 1 addition & 0 deletions test/setup-test-framework.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// `babel-jest` should be doing this instead, but apparently it's not working.
require( 'core-js/modules/es7.object.values' );

// Chai plugins
Expand Down
18 changes: 7 additions & 11 deletions test/setup-wp-aliases.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
const lazySetupAlias = object =>
name =>
Object.defineProperty( object, name, {
get: () => require( name ),
} );
const lazySetupWpAlias = lazySetupAlias( global.wp );

const entryPointNames = [
// Set up `wp.*` aliases. Handled by Webpack outside of the test build.
[
'element',
'i18n',
'components',
'utils',
'blocks',
'date',
'editor',
];

entryPointNames.forEach( lazySetupWpAlias );
].forEach( entryPointName => {
Object.defineProperty( global.wp, entryPointName, {
get: () => require( entryPointName ),
} );
} );