Code Monkey home page Code Monkey logo

minijasminenode's Introduction

minijasminenode2

Based on Jasmine-Node, but minus the fancy stuff. This node.js module makes Pivotal Lab's Jasmine (http://github.com/pivotal/jasmine) spec framework available in node.js or via the command line.

version notice

minijasminenode comes in two flavors.

This is the branch for minijasminenode2. Switch to minijasminenode.

Note that there have been breaking changes between Jasmine 1.3.1 and Jasmine 2.0. Notably, a different interface for reporters and custom matchers. Also, note that per-spec timeouts (e.g. it('does foo', fn, 1000)) no longer work in Jasmine 2.0.

features

MiniJasmineNode exports a library which

  • places Jasmine in Node's global namespace, similar to how it's run in a browser.
  • adds result reporters for the terminal.
  • adds the ability to load tests from file.
  • adds focused specs with iit and ddescribe.

The module also contains a command line wrapper.

installation

Get the library with

npm install minijasminenode2

Or, install globally

npm install -g minijasminenode2

If you install globally, you can use minijasminenode directly from the command line

minijasminenode2 mySpecFolder/mySpec.js

See more options

minijasminenode2 --help

usage

// Your test file - mySpecFolder/mySpec.js
describe('foo', function() {
  it('should pass', function() {
    expect(2 + 2).toEqual(4);
  });
});
    var miniJasmineLib = require('minijasminenode2');
    // At this point, jasmine is available in the global node context.

    // Add your tests by filename.
    miniJasmineLib.addSpecs('myTestFolder/mySpec.js');

    // If you'd like to add a custom Jasmine reporter, you can do so. Tests will
    // be automatically reported to the terminal.
    miniJasmineLib.addReporter(myCustomReporter);

    // Run those tests!
    miniJasmineLib.executeSpecs(options);

You can also pass an options object into executeSpecs

    var miniJasmineLib = require('minijasminenode2');

    var options = {
      // An array of filenames, relative to current dir. These will be
      // executed, as well as any tests added with addSpecs()
      specs: ['specDir/mySpec1.js', 'specDir/mySpec2.js'],
      // A function to call on completion.
      // function(passed)
      onComplete: function(passed) { console.log('done!'); },
      // If true, display suite and spec names.
      isVerbose: false,
      // If true, print colors to the terminal.
      showColors: true,
      // If true, include stack traces in failures.
      includeStackTrace: true,
      // Time to wait in milliseconds before a test automatically fails
      defaultTimeoutInterval: 5000
    };
    miniJasmineLib.executeSpecs(options);

to run the tests

./specs.sh

This will run passing tests as well as show examples of how failures look. To run only passing tests, use npm test or ./bin/minijn spec/*_spec.js

minijasminenode's People

Contributors

alanmyrvold avatar juliemr avatar kfishkin avatar knisterpeter avatar lebek avatar mrmusa avatar searls avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

minijasminenode's Issues

bump to jasmine 2.1.x

Why not using Jasmine 2.1.x instead of Jasmine 2.0.0, is there compatibility issues ?

โ€” and jasmine beforeAll would be very useful !

Feature request: Output formatting option to indicate success/failure of test spec

Copied from angular/protractor#1001

I want to use the output text and copy/paste the output straight into a code review comments if there are errors, but color/coding doesn't show up in that case and the Failure information is not connected to the summary section.

So the feature request is to add an option which can help make output more readable (IMHO) by putting results in text in the summary section.

jasmineNodeOpts.showErrorsOnSpec=1
"Something describing my suite
user should be able to use this option - FAILED"
user can have a taco - SUCCESS"

And a more verbose inline option
jasmineNodeOpts.showErrorsOnSpec=2
"Something describing my suite
user should be able to use this option - FAILED
Message:
Expected 0 to be greater than 0.
Stacktrace:
Error: Failed expectation
at null. (/Volumes/opt/src/dio/distillerizer/test/e2e/login-attempts.js:35:26)
user can have a taco - PASSED"

Show better reports with iit

When I run the single test case by using 'iit', it actually executes only one test case. I can say this from the assertions count and looking at the UI. But, the report shows that it did run all the tests in the suite.

for example: my report says "8 tests, 1 assertion, 0 failures" when I have a iit for one of the test case and "8 tests, 20 assertions, 0 failures" when I run all of them without having a iit. Is there any way that we could make the no of tests to be shown as "1 test, 1 assertion 0 failures" when we add a iit?

I have posted this on Stackoverflow as well.
http://stackoverflow.com/questions/24536572/how-to-run-a-single-specific-test-case-when-using-protractor/24536865?noredirect=1#comment38013523_24536865

Broken with npm v3

    Error: Cannot find module '../node_modules/jasmine-core/lib/jasmine-core/jasmine.js'
    at Function.Module._resolveFilename (module.js:339:15)
    at Function.Module._load (module.js:290:25)
    at Module.require (module.js:367:17)
    at require (internal/module.js:16:19)
    at Object.<anonymous> (./node_modules/minijasminenode2/lib/index.js:5:22)

The jasmine-core module is not in the place where minijasminenode2 tries to find it.
It breaks on this line: /lib/index.js#L5.

This helps:

- var jasmineRequire = require('../node_modules/jasmine-core/lib/jasmine-core/jasmine.js');
+ var jasmineRequire = require('jasmine-core/lib/jasmine-core/jasmine.js');

Cannot call method 'addReporter' of undefined

/**
 * Alias for jasmine.getEnv().addReporter
 */
exports.addReporter = jasmine.getEnv().addReporter;

When invoking addReporter for your module, the following error is reported: Cannot call method 'addReporter' of undefined. This is because addReporter is only an alias for the function definition and not the encapsulating object environment.

Proposed fix:

/**
 * Alias for jasmine.getEnv().addReporter
 */
exports.addReporter = function (reporter) {
  jasmine.getEnv().addReporter(reporter);
};

Additional reporter doesn't works

Hello Julie, I

I'm trying to add the jasmine-growl-reporter from here, but it doesn't works. The reporter should be compatible to Jasmine 2.0 Have I made something wrong? I enabled also the verbose output, but I don't see any errors.

var miniJasmineLib = require('minijasminenode');
var growlReporter = require('jasmine-growl-reporter');

miniJasmineLib.addReporter(growlReporter);

var options = {
  specs: ['./spec/calculator.spec.js'],
  onComplete: function (passed) {
    console.log('I\'m done with the tests...');
  },
  showColors: true,
  isVerbose: true
};

miniJasmineLib.executeSpecs(options);

Support it.only or iit

These features will be available in Jasmine 2.0, but it would be nice to have them in the meantime.

Feature Request - output failures as they occur

It would be nice to have an alternate output format that, instead of printing an "F", would print the error message and stack trace immediately, instead of after all of the tests have run.

This would allow me to start investigating an issue before the entire test suite has run.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.