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

test: replace karma with jest #302

Merged
merged 1 commit into from
Mar 14, 2019

Conversation

nolanlawson
Copy link

@nolanlawson nolanlawson commented Mar 14, 2019

This moves our tests from karma to jest. This offers a few benefits:

  • no need for a browser or even a headless browser or jsdom; our tests can run in pure Node
  • alignment with React community
  • fewer deps, faster tests

I had to make some small tweaks to get this to work, but I managed to preserve our existing tests.

"start": "npm run watch",
"stats": "webpack --config ./spec/webpack.config.js --json > spec/stats.json",
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I could not find a way to keep this stats script without maintaining a webpack config merely to generate it... seems not worth it.

)
let tree = component.toJSON()
expect(tree).toMatchSnapshot()
})
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added a test for the <NotFound> component for the heck of it

this.top = 0
this.maxMargin = 0
return
}
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes me wince; maybe eventually we can use NODE_ENV to remove this

@@ -28,7 +28,8 @@ export default class Search extends React.PureComponent {

componentDidMount() {
// in some cases (e.g. preact) the input may already be pre-populated
if (this.input.value) {
// this.input is undefined in Jest tests
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant