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

Discussion about Jest for unit tests #33

Open
tobika opened this issue May 7, 2017 · 3 comments
Open

Discussion about Jest for unit tests #33

tobika opened this issue May 7, 2017 · 3 comments

Comments

@tobika
Copy link

tobika commented May 7, 2017

I just added a PR #32 to have an example of working unit tests with Jest.

Maybe we could use this issue for discussion if other people are interested in making jest usable with ionic. Also maybe there are good reasons not to use Jest with ionic. I would appreciate if someone could enlighten me in this case :)

Some advantages of Jest over Karma:

  • Only run tests on modified files
  • Only run tests for modified files since last commit

Article about testing with Jest in angular:
https://www.xfive.co/blog/testing-angular-faster-jest/

@datencia
Copy link
Contributor

datencia commented Jun 1, 2017

Cool, that's a good topic @tobika. IMHO Jest is awesome:

Some other advantages of Jest:

  • Very easy to setup (almost zero configuration)
  • Fast
  • Built-in code coverage reports
  • Less dependencies

I've been using karma long time but requires too much configuration and knowledge about the related tooling (karma conf, webpack, etc). Ability to test is a must have and I don't understand why Ionic does not add support for testing by default.

I'm really thinking to move from Karma to Jest soon.

I've got a simple example of testing Ionic2 with Jest. I hope everybody finds it useful.
image

@leifwells
Copy link
Contributor

Do you guys know if there is a way to have karma and jest exist in the same project?

I realize that might be an odd question, but I'm wondering if the best move would be to create a jest branch structured similarly but with only the items needed for jest. Thoughts?

@datencia
Copy link
Contributor

I don't know.

As I know, Jest sits on top of Jasmine, most of the API is similar but there are slight differences that require migrating some of Jasmine calls. Also, we need to remove @types/jasmine module (due to a duplicate TS declaration from @types/jest).

So tests are slightly different. Maybe it's best to create a different branch for now.

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

No branches or pull requests

3 participants