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

Include information on how to include server specs #27

Open
willclarktech opened this Issue Mar 12, 2016 · 6 comments

Comments

Projects
None yet
4 participants
@willclarktech
Copy link

willclarktech commented Mar 12, 2016

karma.conf.js excludes src/imports/**/server/**/*-spec.@(js|jsx) and commenting out that line leads to an error:

Uncaught Error: There is already a collection named 'accountHolders' at
[...]/src/.meteor/local/build/programs/web.browser/packages/mongo.js:312

I couldn't find any information in the docs on how to include the server-side tests. What's the best way?

@samhatoum

This comment has been minimized.

Copy link
Member

samhatoum commented Mar 13, 2016

They are not being run as part of Karma as it is a client-side only testing framework.

There was an older project that allowed server-side testing to happen:
https://github.com/mhevery/jasmine-node

Jasmine now has a node cli runner built-in so it's probably possible to wire it up so it runs as part of Karma. I haven't had time to look into this.

Currently wallaby.js is the only way to run the server tests. There's a ticket open to allow wallaby to run as a cli command, but it's not promised:
wallabyjs/public#72

@willclarktech

This comment has been minimized.

Copy link

willclarktech commented Mar 13, 2016

Ah of course, got so focused on isomorphism I forgot Karma is just client-side. What would be the benefit of running the server-side tests as part of Karma rather than separately though?

@samhatoum

This comment has been minimized.

Copy link
Member

samhatoum commented Mar 13, 2016

Common file watching when in dev mode so the tests rerun on file changes, and having the configuration to run all the tests in one place I guess

You can also setup something like Grunt/Gulp to do the file-watching and to run jasmine.

We're waiting on the final Meteor 1.3 release before seeing how the API works and how we might want to run the server-side tests.

@willclarktech

This comment has been minimized.

Copy link

willclarktech commented Mar 14, 2016

That makes sense. Thanks a lot for this repo by the way, really useful stuff.

@rjsmith

This comment has been minimized.

Copy link

rjsmith commented Apr 8, 2016

Hi @samhatoum, @Sanjo

I'm also very interested in trying to figure out what options I have to retain my 260+ Meteor v1.2.1 Velocity / Jasmine server integration tests in my project when I upgrade to Meteor v1.3, which is the only thing stopping me from making that move now. The ideas in this best practices repo all make a lot of sense to me, so I am looking forward to seeing an upgrade path to v1.3.

@Sanjo

This comment has been minimized.

Copy link

Sanjo commented Apr 8, 2016

The following instructions may contain small mistakes. Please point out the mistakes, so I can correct them. I currently have very limited time for this stuff.

How to execute tests with sanjo:jasmine and Meteor test runner

  1. Install: meteor add sanjo:jasmine
  2. Execute: meteor test --full-app --driver-package sanjo:jasmine and then visite your app in the browser. No CI support yet.

How to execute server tests with Jasmine CLI tool (without Wallaby)

  1. Copy the following files into your project
  1. Add the following devDependencies to package.json. Preferably outside of the meteor app. Inside the meteor app is untested:
    "babel-core": "^6.3.17",
    "babel-plugin-transform-decorators-legacy": "^1.2.0",
    "babel-plugin-transform-es2015-modules-commonjs": "^6.4.0",
    "babel-plugin-transform-runtime": "^6.3.13",
    "babel-plugin-transform-strict-mode": "^6.3.13",
    "babel-preset-es2015": "^6.3.13",
    "babel-preset-react": "^6.3.13",
    "babel-preset-stage-0": "^6.3.13",
    "babel-register": "^6.7.2",
    "jasmine": "https://github.com/xolvio/jasmine-npm/archive/29065151846755d6bbad369f506143ebf69b168f.tar.gz",
    "underscore": "^1.8.3"
  1. If your app does not use ES2015 modules (untested): remove the following lines of code. This will load all app files before tests execution. It's the same mechanism as meteor test --full-app

  2. Adjust the Jasmine options to your needs here: https://github.com/xolvio/automated-testing-best-practices/blob/master/.scripts/jasmine_server_unit/jasmine_server_unit.js#L349-L362. The Jasmine options are documented here: http://jasmine.github.io/2.4/node.html

  3. Run the tests with .scripts/jasmine_server_unit/jasmine_server_unit.sh. The same command can be used for CI.

How to execute server tests with with Wallaby

  1. Copy the following files into your project
  1. Add the following devDependencies to package.json. Preferably outside of the meteor app. Inside the meteor app is untested:
    "babel-core": "^6.3.17",
    "babel-plugin-transform-decorators-legacy": "^1.2.0",
    "babel-plugin-transform-es2015-modules-commonjs": "^6.4.0",
    "babel-plugin-transform-runtime": "^6.3.13",
    "babel-plugin-transform-strict-mode": "^6.3.13",
    "babel-preset-es2015": "^6.3.13",
    "babel-preset-react": "^6.3.13",
    "babel-preset-stage-0": "^6.3.13",
    "babel-register": "^6.7.2",
    "jasmine": "https://github.com/xolvio/jasmine-npm/archive/29065151846755d6bbad369f506143ebf69b168f.tar.gz",
    "underscore": "^1.8.3"
  1. Adjust the Wallaby options to your needs

  2. Install Node.js 0.10.40 with nvm nvm install 0.10.40 the version should match the version that is used by meteor in needs to be changed here: https://github.com/xolvio/automated-testing-best-practices/blob/master/wallaby_server.js#L276

  3. Configure the Wallaby runner with the wallaby_server.js config in your IDE and run it.

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