-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Setup coverage #245
Setup coverage #245
Changes from all commits
8e5b523
d4ec4bd
f2dd1ef
ba8fbf4
ae97dd8
0f26719
fa21e37
f1ca2c7
dfd0bfa
b79a4ec
c80781f
a8ce290
f7dc0b6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,5 +6,33 @@ | |
], | ||
"plugins": [ | ||
"lodash" | ||
] | ||
], | ||
"env": { | ||
"development": { | ||
"plugins": [ | ||
["react-transform", { | ||
"transforms": [{ | ||
"transform": "react-transform-hmr", | ||
"imports": [ | ||
"react" | ||
], | ||
"locals": [ | ||
"module" | ||
] | ||
}, { | ||
"transform": "react-transform-catch-errors", | ||
"imports": [ | ||
"react", | ||
"redbox-react" | ||
] | ||
}] | ||
}] | ||
] | ||
}, | ||
"test": { | ||
"plugins": [ | ||
["__coverage__", { "ignore": "test/" }] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since isparta is no longer maintained, we use the new |
||
] | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,7 @@ | |
npm-debug.log* | ||
node_modules/ | ||
bower_components/ | ||
coverage/ | ||
dist/ | ||
docs/build | ||
docs/app/docgenInfo.json |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,8 @@ | ||
# Stardust [![Code Climate](https://img.shields.io/codeclimate/github/TechnologyAdvice/stardust.svg?style=flat-square)](https://codeclimate.com/github/TechnologyAdvice/stardust) [![Gemnasium](https://img.shields.io/gemnasium/TechnologyAdvice/stardust.svg?style=flat-square)](https://gemnasium.com/TechnologyAdvice/stardust) [![Circle CI](https://img.shields.io/circleci/project/TechnologyAdvice/stardust/master.svg?style=flat-square)](https://circleci.com/gh/TechnologyAdvice/stardust/tree/master) | ||
# Stardust | ||
[![Circle CI](https://img.shields.io/circleci/project/TechnologyAdvice/stardust/master.svg?style=flat-square)](https://circleci.com/gh/TechnologyAdvice/stardust/tree/master) | ||
[![Codecov](https://img.shields.io/codecov/c/github/TechnologyAdvice/stardust/master.svg?style=flat-square)](https://codecov.io/gh/TechnologyAdvice/stardust) | ||
[![Code Climate](https://img.shields.io/codeclimate/github/TechnologyAdvice/stardust.svg?style=flat-square)](https://codeclimate.com/github/TechnologyAdvice/stardust) | ||
[![Gemnasium](https://img.shields.io/gemnasium/TechnologyAdvice/stardust.svg?style=flat-square)](https://gemnasium.com/TechnologyAdvice/stardust) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added coverage badge. |
||
|
||
The (soon to be) [official][8] integration between [Semantic UI][5] and [React][3]. | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
import { argv } from 'yargs' | ||
import webpack from 'webpack' | ||
|
||
import config from '../config' | ||
import webpackConfig from './webpack.config' | ||
|
@@ -11,7 +10,7 @@ module.exports = (karmaConfig) => { | |
basePath: process.cwd(), | ||
browsers: ['PhantomJS'], | ||
singleRun: !argv.watch, | ||
reporters: ['mocha'], | ||
reporters: ['mocha', 'coverage'], | ||
files: [ | ||
'./test/tests.bundle.js', | ||
], | ||
|
@@ -23,7 +22,16 @@ module.exports = (karmaConfig) => { | |
// exit on ResourceError, useful if karma exits without killing phantom | ||
exitOnResourceError: true, | ||
}, | ||
coverageReporter: { | ||
reporters: [ | ||
{ type: 'lcov', dir: 'coverage', subdir: '.' }, | ||
{ type: 'text-summary' }, | ||
], | ||
includeAllSources: true, | ||
}, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We report |
||
preprocessors: { | ||
// do not include 'coverage' preprocessor for karma-coverage | ||
// code is already instrumented by babel-plugin-__coverage__ | ||
'**/*.bundle.js': ['webpack'], | ||
}, | ||
client: { | ||
|
@@ -45,7 +53,7 @@ module.exports = (karmaConfig) => { | |
], | ||
}, | ||
plugins: [ | ||
new webpack.DefinePlugin(config.compiler_globals), | ||
...webpackConfig.plugins, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Plugins are conditionally set in webpack config, use all available plugins. |
||
], | ||
resolve: { | ||
...webpackConfig.resolve, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -51,6 +51,7 @@ | |
"babel-core": "^6.5.2", | ||
"babel-eslint": "^6.0.4", | ||
"babel-loader": "^6.2.0", | ||
"babel-plugin-__coverage__": "^0.111111.11", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Lol, is that version for real? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yea, I wish this said |
||
"babel-plugin-lodash": "^3.1.4", | ||
"babel-plugin-react-transform": "^2.0.2", | ||
"babel-preset-es2015": "^6.5.0", | ||
|
@@ -85,6 +86,7 @@ | |
"json-loader": "^0.5.3", | ||
"karma": "^0.13.22", | ||
"karma-cli": "^1.0.0", | ||
"karma-coverage": "^1.0.0", | ||
"karma-mocha": "^1.0.1", | ||
"karma-mocha-reporter": "^2.0.0", | ||
"karma-phantomjs-launcher": "^1.0.0", | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,7 +9,7 @@ import Dropdown from '../../modules/Dropdown/Dropdown' | |
* A <Select /> is sugar for <Dropdown selection />. | ||
* @see Dropdown | ||
*/ | ||
const Select = ({ className, ...rest }) => { | ||
function Select({ className, ...rest }) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This issue was raised and fixed. Automated conformance testing depends on the constructor name. Arrow functions are anonymous. Added a conformance check to ensure all components have names. Updated all stateless functional components to have function names. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If you were to rely on the component's const Select = () => { ... }
Select.displayName = 'Select' |
||
const classes = cx('sd-select', className) | ||
|
||
return <Dropdown {...rest} className={classes} selection /> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
let debug | ||
const noop = () => undefined | ||
|
||
if (process.env.NODE_ENV !== 'production') { | ||
if (process.env.NODE_ENV !== 'production' && process.env.NODE_ENV !== 'test') { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Debug messages crowd test output heavily, silenced debug logs in testing. |
||
debug = require('debug') | ||
localStorage.debug = 'stardust:*' | ||
} else { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,11 +21,11 @@ const wrapperMount = (node, opts) => { | |
attachTo = document.createElement('div') | ||
document.body.appendChild(attachTo) | ||
|
||
wrapper = global.mount(node, { ...opts, attachTo }) | ||
wrapper = mount(node, { ...opts, attachTo }) | ||
return wrapper | ||
} | ||
const wrapperShallow = (...args) => (wrapper = global.shallow(...args)) | ||
const wrapperRender = (...args) => (wrapper = global.render(...args)) | ||
const wrapperShallow = (...args) => (wrapper = shallow(...args)) | ||
const wrapperRender = (...args) => (wrapper = render(...args)) | ||
|
||
// ---------------------------------------- | ||
// Options | ||
|
@@ -52,9 +52,6 @@ const dropdownMenuIsOpen = () => { | |
menu.should.have.className('visible') | ||
} | ||
|
||
options = getOptions() | ||
defaultProps = { options } | ||
|
||
describe('Dropdown Component', () => { | ||
beforeEach(() => { | ||
attachTo = undefined | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. cruft |
||
|
@@ -720,12 +717,15 @@ describe('Dropdown Component', () => { | |
}) | ||
|
||
it('still allows moving selection after blur/focus', () => { | ||
// open, first item is selected | ||
const search = wrapperMount(<Dropdown {...defaultProps} search />) | ||
.find('input.search') | ||
.simulate('focus') | ||
|
||
domEvent.keyDown(document, { key: 'ArrowDown' }) | ||
dropdownMenuIsOpen() | ||
|
||
// open, first item is selected | ||
const items = wrapper | ||
.simulate('click') | ||
.find('DropdownItem') | ||
|
||
items | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,6 +39,8 @@ describe('extending AutoControlledComponent', () => { | |
}) | ||
|
||
it('sets state for autoControlledProps', () => { | ||
consoleUtil.disableOnce() | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These test throw auto controlled prop warnings due to randomly generated props. Silenced logs to silence the warnings. |
||
const autoControlledProps = _.keys(makeProps()) | ||
const randomProp = _.sample(autoControlledProps) | ||
const randomValue = faker.hacker.verb() | ||
|
@@ -70,6 +72,8 @@ describe('extending AutoControlledComponent', () => { | |
}) | ||
|
||
it('does not set state for props defined by the parent', () => { | ||
consoleUtil.disableOnce() | ||
|
||
const props = makeProps() | ||
const autoControlledProps = _.keys(props) | ||
|
||
|
@@ -95,6 +99,8 @@ describe('extending AutoControlledComponent', () => { | |
|
||
describe('initial state', () => { | ||
it('is derived from autoControlledProps in props', () => { | ||
consoleUtil.disableOnce() | ||
|
||
const props = makeProps() | ||
const autoControlledProps = _.keys(props) | ||
|
||
|
@@ -114,6 +120,8 @@ describe('extending AutoControlledComponent', () => { | |
|
||
describe('default props', () => { | ||
it('are applied to state for props in autoControlledProps', () => { | ||
consoleUtil.disableOnce() | ||
|
||
const props = makeProps() | ||
const autoControlledProps = _.keys(props) | ||
const defaultProps = makeDefaultProps(props) | ||
|
@@ -134,6 +142,8 @@ describe('extending AutoControlledComponent', () => { | |
}) | ||
|
||
it('allows trySetState to work on non-default autoControlledProps', () => { | ||
consoleUtil.disableOnce() | ||
|
||
const props = makeProps() | ||
const autoControlledProps = _.keys(props) | ||
const defaultProps = makeDefaultProps(props) | ||
|
@@ -155,6 +165,8 @@ describe('extending AutoControlledComponent', () => { | |
|
||
describe('changing props', () => { | ||
it('sets state for props in autoControlledProps', () => { | ||
consoleUtil.disableOnce() | ||
|
||
const props = makeProps() | ||
const autoControlledProps = _.keys(props) | ||
|
||
|
@@ -189,6 +201,8 @@ describe('extending AutoControlledComponent', () => { | |
}) | ||
|
||
it('does not set state for default props when changed', () => { | ||
consoleUtil.disableOnce() | ||
|
||
const props = makeProps() | ||
const autoControlledProps = _.keys(props) | ||
const defaultProps = makeDefaultProps(props) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved all babel config into
babelrc
. Thedevelopment
section was previously in the loader query.