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

React enzyme tests #137

Closed
wants to merge 3 commits into
base: react
from

Conversation

Projects
None yet
3 participants
@shilman
Copy link

shilman commented May 20, 2016

Don't merge. This is the simplest possible unit test of TodoItem, just to see if I could get it working and it works. Most of the mocha/enzyme setup is borrowed from react-cdk.

How to try it out:

# using a 4.0+ version of node
npm install
npm run test-enzyme 

The code is hideous, but I wanted to share in case it helps move things forward. Feedback wanted:

  • systematic way to do the testdouble thing or import meteor packages?
  • way to do this from within meteor test?
  • better directory structure?
@meteor-bot

This comment has been minimized.

Copy link

meteor-bot commented May 20, 2016

@shilman: Thank you for submitting a pull request! Before we can merge it, you'll need to sign the Meteor Contributor Agreement here: https://contribute.meteor.com/

@shilman

This comment has been minimized.

Copy link

shilman commented May 24, 2016

@tmeasday @ffxsam I realize this is not a great PR, or perhaps shouldn't even be a PR since it doesn't build (though it should actually work when you run it on your machine in spite of the errors!). Nevertheless, any feedback or nudges in the right direction would be much appreciated.

@@ -0,0 +1,42 @@
import React from 'react';
import { shallow } from 'enzyme';

This comment has been minimized.

@tmeasday

tmeasday May 24, 2016

Contributor

Is there a reason you can't put this line inside a regular Meteor/mocha test (run via practicalmeteor:mocha etc?)

@tmeasday

This comment has been minimized.

Copy link
Contributor

tmeasday commented May 24, 2016

@shilman sorry, only just had a chance to look at it. I'm wondering why we can run Mocha via the Meteor build tool + testing infrastructure? Is there something special about the enzyme import that would stop that happening?

@shilman

This comment has been minimized.

Copy link

shilman commented May 25, 2016

@tmeasday per your encouragement, I gave it a try with the Meteor build tool + testing infrastructure and issued a new PR in #141, and indeed it's a lot cleaner. I'm closing this PR for now.

@shilman shilman closed this May 25, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment