Skip to content

Karma + Jasmine test runner #38

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

Merged
merged 3 commits into from
Oct 7, 2015
Merged

Karma + Jasmine test runner #38

merged 3 commits into from
Oct 7, 2015

Conversation

AdamBrodzinski
Copy link
Collaborator

Adds the karma / webpack config with a basic passing spec. Uses Jasmine but can easily be changed to Mocha, Tape, etc... (commented out karma-mocha added). Adds Chrome launcher. Copies over the client webpack config settings and omits some too.

helper files are stored in ./test. It's a bit empty now but I was going to use that to symlink integration test folders into meteor_core later.

Uses the new react-transform for hot-reloading:
https://github.com/gaearon/babel-plugin-react-transform

Note, transform does nothing when `process.env.NODE_ENV` is set to
`’production’`.

- removes react-hot-loader
- moves es stage settings to .babelrc
- adds react-transform settings to .babelrc
makes errors very nice to deal with, shows a red error container
over your app window, much like React native.

https://github.com/gaearon/react-transform-catch-errors
https://github.com/KeywordBrain/redbox-react
@AdamBrodzinski
Copy link
Collaborator Author

Oh btw, if you add all of these PRs this one is after react-transform and would conflict if applied before that (I think).

@AdamBrodzinski AdamBrodzinski mentioned this pull request Sep 10, 2015
4 tasks
);
}
});

Copy link
Owner

Choose a reason for hiding this comment

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

Ah, any way we could make the test have something to do with what's actually in the App stub instead of this?

@AdamBrodzinski
Copy link
Collaborator Author

Yea we could either add a react component that doesn't have meteor and the react mixin or stub them out in the test. There happens to be a lot going on in there.... mixin, collections.

Normally I just use slim controller-views and cover those with acceptance tests, then their children are stateless and are easy to unit test with minimal/no stubbing/mocking.

Either way would be fine with me, let me know.

@AdamBrodzinski
Copy link
Collaborator Author

Another thought.... we could make the contents of app a component that takes props (the X users X posts bit). I think that would also help guide people down the path of using the MeteorMixin in a maintainable way as well.

And/Or we could have an 'Add Post' button that increments the posts number.

I think that would be an improvement over the unused component above.

@jedwards1211
Copy link
Owner

@AdamBrodzinski I mean, the goal for the main branch was not to have much placeholder code for users to delete, right? :)

@AdamBrodzinski
Copy link
Collaborator Author

Lol yep, that's why I just added the un-used component in line since these will all be blown out anyway.
Perhaps having an empty spec or a (1 + 1) should equal 2 spec would be better than the example tests? Now that I think of it I guess everyone should now how to test React components by now.

We could even add unit-tests to another branch if that's not something that you think people will use.

@jedwards1211
Copy link
Owner

How about this: let's just test that various Meteor and React globals are available and working. It would be nice for a test to prove this app skeleton provides what it says it does

@AdamBrodzinski
Copy link
Collaborator Author

Yea i'll try but I think those globals will be undefined though since it's not a full integration test.

@jedwards1211
Copy link
Owner

Oh. There's a way to do integration tests with Karma right?

@AdamBrodzinski
Copy link
Collaborator Author

Yes and no... Velocity makes this turn key and is way easier. It's using Karma itself but in another weird way that ties in with Meteor closely.

Velocity also has unit tests but they're dog slow due to the meteor build system. Luckily running this way outside of Meteor is lightning fast.

Velocity's acceptance tests were always brittle for me so i'm just using Capybara instead which also uses a much nicer DSL.

Speaking of I have to figure out how to symlink /meteor_core/tests/jasmine/server/integration/ to tests/server_integration/.... every time I do it, it gives me a file (which I can't open) or some directory oesn't exist error.. You can symlink directories correct? Currently i'm just putting tests in meteor_core which is ok but not ideal.

@jedwards1211
Copy link
Owner

Yup, ln -s <relative path to target> <name for link file>

@AdamBrodzinski
Copy link
Collaborator Author

Just a heads up I won't be able to add anything else to this for quite some time, i'm really swamped. I might be able to do a separate PR for integration tests using velocity (symlinking) later.

@jedwards1211
Copy link
Owner

No worries, I'll just go ahead and merge this then. I realize, since there is some code one has to delete from this project any way to start fresh, it's not really a change in philosophy to integrate these tests (plus Tomit was looking for them) Sorry for being OCD at times... Once I have the new Webpack plugin approach worked out, it would be a lot easier to maintain your own skeleton project exactly to your liking :) You've always been more focused on teaching other people, which is great, I've been mostly focused on the getting the basics of using Meteor and Webpack together just right.

jedwards1211 added a commit that referenced this pull request Oct 7, 2015
@jedwards1211 jedwards1211 merged commit d792eea into jedwards1211:master Oct 7, 2015
@AdamBrodzinski
Copy link
Collaborator Author

👍 Being OCD about it is a good thing... don't want it to be grow into a tangled mess 😆 Thanks! I've found that making things easy to use (by great docs/comments) and having screenshots makes your # of stars/users go way up.

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.

2 participants