Skip to content

sonicdoe/judge

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

60 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Judge

Deprecated

Judge has been deprecated. I recommend to simply use npm install. On Travis CI you can use environment variables, for example:

language: node_js
node_js:
  - "6"
env:
  matrix:
    - EXPRESS_VERSION=4
    - EXPRESS_VERSION=3
install:
  - npm install
  - npm install express@$EXPRESS_VERSION

Test your Node.js package against different versions of dependencies.

Note: Judge is a work in progress and may not work very well, yet. See Stability and limitations.

What is this good for?

Let’s say you wrote a middleware for Express which is compatible with both Express 3 and Express 4. You use Travis CI to ensure that your tests pass, even against multiple versions of Node.js. However, your tests won’t run against Express 3.

Using Judge, you can specify multiple “Judge cases” (a set of dependencies) to test your package against, so you can be sure that your Express middleware works with both Express 3 and Express 4.

Judge was heavily inspired by Appraisal which offers a similar solution for Ruby gems.

Getting started

Install Judge using:

$ npm install judge --save-dev

Declare Judge cases in your package.json:

{
  "name": "your-package",
  "version": "1.0.0",
  "dependencies": {
    "express": "^4.10.6 || ^3.18.6"
  },
  "judge": {
    "express-4": {
      "express": "^4.10.6"
    },
    "express-3": {
      "express": "^3.18.6"
    }
  }
}

Install all necessary dependencies using:

$ ./node_modules/.bin/judge install

You can now run any Node.js application against a specific Judge case:

$ ./node_modules/.bin/judge run express-3 grunt test
$ ./node_modules/.bin/judge run express-4 node test.js

Integration with Travis CI

You can configure Travis CI to use Judge when running your tests. Simply add judge install $JUDGE_CASE --overwrite to your install process. Then specify every Judge case you want to test against as an environment variable.

language: node_js
node_js:
  - "0.10"
  - "0.8"
install:
  - "npm install"
  - "./node_modules/.bin/judge install $JUDGE_CASE --overwrite"
env:
  - "JUDGE_CASE=express-3"
  - "JUDGE_CASE=express-4"

Stability and limitations

Judge is currently a work in progress. For example, you may encounter the following issues and annoyances:

  • No built-in help command
  • Undefined behavior when passing invalid or unexpected parameters
  • May not work well with Node addons
  • Does not work with non-Node.js commands
  • Judge has no test suite, yet

In general, the environment provided by judge run may not be exactly the same as if you start the program using node itself.

That said, using the --overwrite option, for example to improve your CI tests, should be unproblematic.

Release History

See CHANGELOG.md.

License

Judge is licensed under the BSD 2-clause license. See LICENSE for the full license text.

About

[Deprecated] Test your Node.js package against different versions of dependencies.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published