Giter Club home page Giter Club logo

jasmine-node's Introduction

jasmine-node

LICENSE npm contributors

This node.js module makes the wonderful Pivotal Lab's jasmine spec framework (version 1) available in node.js.

Project status

This project is now in maintenance mode. It is recommended to use the jasmine or jasmine-npm package whenever possible.

jasmine

Version 1.3.1 of Jasmine is currently included with node-jasmine. This is a forked version from the Karma project, which allows you to use the ddescribe and iit functions to run individual suites or specs.

NOTICE: BETA 2.0.0 Support in the Jasmine2.0 branch (with rewrite in CoffeeScript) is now abandoned and no longer supported.

Supported Node.js versions

  • Current:
    • 10
    • 12
  • Deprecated:
    • 8 (EOL in December 2019)
    • 6 (already past EOL)
    • 4 (already past EOL)

Older versions of Node.js are no longer supported. It is highly recommended to upgrade to a supported version of Node.js.

what's new

  • Growl notifications with the --growl flag (requires Growl to be installed)
  • Ability to test specs written in Literate CoffeeScript
  • Teamcity Reporter reinstated.
  • Ability to specify multiple files to test via list in command line
  • Ability to suppress stack trace with --noStack
  • Async tests now run in the expected context instead of the global one
  • --config flag that allows you to assign variables to process.env
  • Terminal Reporters are now available in the Jasmine Object #184
  • Done is now available in all timeout specs #199
  • afterEach is available in requirejs #179
  • Editors that replace instead of changing files should work with autotest #198
  • Jasmine Mock Clock now works!
  • Autotest now works!
  • Using the latest Jasmine!
  • Verbose mode tabs describe blocks much more accurately!
  • --coffee now allows specs written in Literate CoffeeScript (.litcoffee)

install

To install the latest official version, use NPM:

npm install jasmine-node -g

To install the latest bleeding edge version, clone this repository and check out the beta branch.

usage

Write the specifications for your code in *.js and *.coffee files in the spec/ directory. You can use sub-directories to better organise your specs. In the specs use describe(), it() etc. exactly as you would in client-side jasmine specs.

Note: your specification files must be named as *spec.js, *spec.coffee or *spec.litcoffee, which matches the regular expression /spec\.(js|coffee|litcoffee)$/i; otherwise jasmine-node won't find them! For example, sampleSpecs.js is wrong, sampleSpec.js is right.

If you have installed the npm package, you can run it with:

jasmine-node spec/

If you aren't using npm, you should add pwd/lib to the $NODE_PATH environment variable, then run:

node lib/jasmine-node/cli.js

You can supply the following arguments:

  • --autotest, provides automatic execution of specs after each change
  • --watch, when used with --autotest, paths after --watch will be watched for changes, allowing to watch for changes outside of specs directory
  • --coffee, allow execution of .coffee and .litcoffee specs
  • --color, indicates spec output should uses color to indicates passing (green) or failing (red) specs
  • --noColor, do not use color in the output
  • -m, --match REGEXP, match only specs containing "REGEXPspec"
  • --matchall, relax requirement of "spec" in spec file names
  • --verbose, verbose output as the specs are run
  • --junitreport, export tests results as junitreport xml format
  • --output FOLDER, defines the output folder for junitreport files
  • --teamcity, converts all console output to teamcity custom test runner commands. (Normally auto detected.)
  • --growl, display test run summary in a growl notification (in addition to other outputs)
  • --runWithRequireJs, loads all specs using requirejs instead of node's native require method
  • --requireJsSetup, file run before specs to include and configure RequireJS
  • --test-dir, the absolute root directory path where tests are located
  • --nohelpers, does not load helpers
  • --forceexit, force exit once tests complete
  • --captureExceptions, listen to global exceptions, report them and exit (interferes with Domains in NodeJs, so do not use if using Domains as well
  • --config NAME VALUE, set a global variable in process.env
  • --noStack, suppress the stack trace generated from a test failure

Individual files to test can be added as bare arguments to the end of the args.

Example:

jasmine-node --coffee spec/AsyncSpec.coffee spec/CoffeeSpec.coffee spec/SampleSpec.js

async tests

jasmine-node includes an alternate syntax for writing asynchronous tests. Accepting a done callback in the specification will trigger jasmine-node to run the test asynchronously waiting until the done() callback is called.

var request = require('request');

it("should respond with hello world", function(done) {
  request("http://localhost:3000/hello", function(error, response, body){
    expect(body).toEqual("hello world");
    done();
  });
});

An asynchronous test will fail after 5000 ms if done() is not called. This timeout can be changed by setting jasmine.getEnv().defaultTimeoutInterval or by passing a timeout interval in the specification.

var request = require('request');

it("should respond with hello world", function(done) {
  request("http://localhost:3000/hello", function(error, response, body){
    done();
  });
}, 250); // timeout after 250 ms

or

var request = require('request');

jasmine.getEnv().defaultTimeoutInterval = 500;

it("should respond with hello world", function(done) {
  request("http://localhost:3000/hello", function(error, response, body){
    done();
  });  // timeout after 500 ms
});

Checkout spec/SampleSpecs.js to see how to use it.

requirejs

There is a sample project in /spec-requirejs. It is comprised of:

  1. requirejs-setup.js, this pulls in our wrapper template (next)
  2. requirejs-wrapper-template, this builds up requirejs settings
  3. requirejs.sut.js, this is a __SU__bject To __T__est, something required by requirejs
  4. requirejs.spec.js, the actual jasmine spec for testing

To run it:

node lib/jasmine-node/cli.js --runWithRequireJs --requireJsSetup ./spec-requirejs/requirejs-setup.js ./spec-requirejs/

exceptions

Often you'll want to capture an uncaught exception and log it to the console, this is accomplished by using the --captureExceptions flag. Exceptions will be reported to the console, but jasmine-node will attempt to recover and continue. It was decided to not change the current functionality until 2.0. So, until then, jasmine-node will still return 0 and continue on without this flag.

Scenario

You require a module, but it doesn't exist, ie require('Q') instead of require('q'). Jasmine-Node reports the error to the console, but carries on and returns 0. This messes up Travis-CI because you need it to return a non-zero status while doing CI tests.

Mitigation

Before --captureExceptions

> jasmine-node --coffee spec
> echo $status
0

Run jasmine node with the --captureExceptions flag.

> jasmine-node --coffee --captureExceptions spec
> echo $status
1

growl notifications

Jasmine node can display Growl notifications of test run summaries in addition to other reports. Growl must be installed separately, see node-growl for platform-specific instructions. Pass the --growl flag to enable the notifications.

development

Install the dependent packages by running:

npm install

Run the specs before you send your pull request:

specs.sh

Note: Some tests are designed to fail in the specs.sh. After each of the individual runs completes, there is a line that lists what the expected Pass/Assert/Fail count should be. If you add/remove/edit tests, please be sure to update this with your PR.

changelog

  • 1.16.2 Back to jasmine-growl-reporter@~0.2.0 (needed by Node.js pre-4.0)
  • 1.16.1 Use ~ instead of ^ in dependencies (may be needed by some really old npm versions)
  • 1.16.0 Fix dependencies to prevent major package updates
  • 1.15.0 Switch to coffeescript package
  • 1.14.6 Update dependencies to resolve npm audit issues
  • 1.14.5 Using ~ instead of ^ for reporter version (thanks to Maxim-Filimonov)
  • 1.14.4 Rolled back jasmine reporter version (thanks to tjmcduffie)
  • 1.14.3 Added 'onComplete' callback to TeamCityReporter (thanks to JoergFiedler)
  • 1.14.2 Uhhh...not sure what happened here.
  • 1.14.1 Default to noColors if not in a TTY
  • 1.14.0 Add support for iit, ddescribe (thanks to mgcrea)
  • 1.13.1 Add coffee-script support for 1.7.x (thanks to nathancarter)
  • 1.13.0 Added timing to the verbose reporter (thanks to rick-kilgore)
  • 1.12.1 Fixed an issue where an undefined variable caused an unhelpful exception in --watch Resolves #278
  • 1.12.0
    • Changed util.print to stdout.write (thanks to nrstott)
    • Don’t affect line numbers with --requireJsSetup (thanks to daviddaurelio)
    • Catch errors when loading helpers (thanks to pimterry)
    • Keep autotesting until all tests have passed (thanks to notclive)
  • 1.11.0 Added Growl notification option --growl (thanks to AlphaHydrae)
  • 1.10.2 Restored stack filter which was accidentally removed (thanks to kevinsawicki)
  • 1.10.1 beforeEach and afterEach now properly handle the async-timeout function
  • 1.10.0 Skipped tests now show in the terminal reporter's output (thanks to kevinsawicki)
  • 1.9.1 Timeout now consistent between Async and Non-Async Calls (thanks to codemnky)
  • 1.9.0 Now re-throwing the file-not-found error, added info to README.md, printing version with --version
  • 1.8.1 Fixed silent failure due to invalid REGEX (thanks to pimterry)
  • 1.8.0 Fixed bug in autotest with multiple paths and added --watch feature (thanks to davegb3)
  • 1.7.1 Removed unneeded fs dependency (thanks to kevinsawicki) Fixed broken fs call in node 0.6 (thanks to abe33)
  • 1.7.0 Literate CoffeeScript now testable (thanks to magicmoose)
  • 1.6.0 Teamcity Reporter Reinstated (thanks to bhcleek)
  • 1.5.1 Missing files and require exceptions will now report instead of failing silently
  • 1.5.0 Now takes multiple files for execution. (thanks to abe33)
  • 1.4.0 Optional flag to suppress stack trace on test failure (thanks to Lastalas)
  • 1.3.1 Fixed context for async tests (thanks to omryn)
  • 1.3.0 Added --config flag for changeable testing environments
  • 1.2.3 Fixed #179, #184, #198, #199. Fixes autotest, afterEach in requirejs, terminal reporter is in jasmine object, done function missing in async tests
  • 1.2.2 Revert Exception Capturing to avoid Breaking Domain Tests
  • 1.2.1 Emergency fix for path reference missing
  • 1.2.0 Fixed #149, #152, #171, #181, #195. --autotest now works as expected, jasmine clock now responds to the fake ticking as requested, and removed the path.exists warning
  • 1.1.1 Fixed #173, #169 (Blocks were not indented in verbose properly, added more documentation to address #180
  • 1.1.0 Updated Jasmine to 1.3.1, fixed fs missing, catching uncaught exceptions, other fixes

jasmine-node's People

Contributors

abe33 avatar adomokos avatar alphahydrae avatar asalant avatar booo avatar bruderstein avatar codingfabian avatar daomry avatar eboto avatar flygsand avatar jeffwatkins avatar ken39arg avatar kevinnio avatar kevinoid avatar kevinsawicki avatar manishgarg-m avatar matthiasg avatar mcollina avatar mhevery avatar mikelehen avatar mtscout6 avatar nrstott avatar pimterry avatar ralf-cestusio avatar tebriel avatar theraven avatar theycallmeswift avatar timbertson avatar tiye avatar vojtajina 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  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  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  avatar  avatar  avatar  avatar

Watchers

 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  avatar  avatar

jasmine-node's Issues

Saving test output to text file

I tried to pipe output to a file and didn't get the actual test output, I get just the following:
Started
�[32m.�[0m

I have a app on git hub that can be used to replicate problem:

You'll see that the test output doesn't contain the specification.

Running Node on Win7 with cygwin

Run in test environment

Hey,

Would it not be better for the process.env.NODE_ENV to run in test mode. This then allows for configuring tests settings in an app like express specifically for the test runner

result code == 0 even if some specs failed

This is directly from jasmine-node suite.

$ jasmine-node spec; echo $?

....................................F

Failures:

  1) should report failure (THIS IS EXPECTED)
   Message:
     Expected true to be falsy.
   Stacktrace:
     Error: Expected true to be falsy.
    at new <anonymous> (/home/matteo/.nvm/v0.6.7/lib/node_modules/jasmine-node/lib/jasmine-node/jasmine-2.0.0.rc1.js:102:32)
    at [object Object].toBeFalsy (/home/matteo/.nvm/v0.6.7/lib/node_modules/jasmine-node/lib/jasmine-node/jasmine-2.0.0.rc1.js:1171:29)
    at [object Object].<anonymous> (/home/matteo/repository/jasmine-node/spec/nested/uber-nested/UberNestedSpec.js:8:20)
    at [object Object].execute (/home/matteo/.nvm/v0.6.7/lib/node_modules/jasmine-node/lib/jasmine-node/jasmine-2.0.0.rc1.js:1001:15)
    at [object Object].next_ (/home/matteo/.nvm/v0.6.7/lib/node_modules/jasmine-node/lib/jasmine-node/jasmine-2.0.0.rc1.js:1790:31)
    at [object Object].start (/home/matteo/.nvm/v0.6.7/lib/node_modules/jasmine-node/lib/jasmine-node/jasmine-2.0.0.rc1.js:1743:8)
    at [object Object].execute (/home/matteo/.nvm/v0.6.7/lib/node_modules/jasmine-node/lib/jasmine-node/jasmine-2.0.0.rc1.js:2070:14)
    at [object Object].next_ (/home/matteo/.nvm/v0.6.7/lib/node_modules/jasmine-node/lib/jasmine-node/jasmine-2.0.0.rc1.js:1790:31)
    at [object Object].start (/home/matteo/.nvm/v0.6.7/lib/node_modules/jasmine-node/lib/jasmine-node/jasmine-2.0.0.rc1.js:1743:8)
    at [object Object].execute (/home/matteo/.nvm/v0.6.7/lib/node_modules/jasmine-node/lib/jasmine-node/jasmine-2.0.0.rc1.js:2215:14)

Finished in 1.124 seconds
37 tests, 68 assertions, 1 failure

0

As 1 spec failed, the status code should be 1, not 0.

jasmine-node cannot run on Teamcity

When attempting to run on Teamcity, it fails due to the jasmine.TeamcityReporter not being present.
Apparently, the version of jasmine-reporters currently on npm is not the version that includes the correct reporter.

Proposed solutions:
1 - Get jasmine-reporters project to put their current version on npm, and update dependency for this project.
2 - Use git submodule to clone the current version of jasmine-reporters into node_modules

When manually updating the jasmine-reporters module, I could get it running no problems, but I would really like to be able to use the pure npm version of jasmine-node.

waitsFor() timeout reporting fails with attempt to .split() undefined

If your code runs past a timeout, the reporter logic in index.js will explode. This is with the current version of jasmine-node in NPM, at least as of yesterday or so. I decided to file this bug on jasmine-node rather than jasmine itself, because the exception occurs in jasmine-node's reporter component.

Another aspect of the observed behaviour is puzzling, though. Notice that below that the test is printed as failing and then the exception occurs, but only once my timeout overbudget code completes (therefore, if my code waited forever, the test would never finish and fail, the timeout setting notwithstanding).

What actually is the intended behaviour? I would expect that jasmine would mark the test as failing and continue once the timeout was up (even if the code under test did continue to run and do things through the event queue).

F
/home/orospakr/code/mine/cardscience/node_modules/jasmine-node/lib/jasmine-node/index.js:52
  text.split(/\n/).forEach(function(line){
       ^
TypeError: Cannot call method 'split' of undefined
    at Object.removeJasmineFrames [as stackFilter] (/home/orospakr/code/mine/cardscience/node_modules/jasmine-node/lib/jasmine-node/index.js:52:8)
    at /home/orospakr/code/mine/cardscience/node_modules/jasmine-node/lib/jasmine-node/reporter.js:81:50
    at Array.forEach (native)
    at /home/orospakr/code/mine/cardscience/node_modules/jasmine-node/lib/jasmine-node/reporter.js:79:21
    at Array.forEach (native)
    at Object.reportSuiteResults (/home/orospakr/code/mine/cardscience/node_modules/jasmine-node/lib/jasmine-node/reporter.js:74:24)
    at [object Object].reportSuiteResults (/home/orospakr/code/mine/cardscience/node_modules/jasmine-node/lib/jasmine-node/jasmine-2.0.0.rc1.js:1508:39)
    at [object Object].finish (/home/orospakr/code/mine/cardscience/node_modules/jasmine-node/lib/jasmine-node/jasmine-2.0.0.rc1.js:2169:21)
    at [object Object].onComplete (/home/orospakr/code/mine/cardscience/node_modules/jasmine-node/lib/jasmine-node/jasmine-2.0.0.rc1.js:2216:10)
    at [object Object].next_ (/home/orospakr/code/mine/cardscience/node_modules/jasmine-node/lib/jasmine-node/jasmine-2.0.0.rc1.js:1800:14)

Clarify install / run procedure, especially around relocation

I'm trying to get up and running with jasmine-node (I am not using npm), and can't quire figure out the intended use of various files. If I end up using it, I plan to package it as a zero install (www.0install.net) feed. The requirements for this are pretty simple, and mostly about relocation:

  • some path or file that can be Inserted into $NODE_PATH, such that require("jasmine") will work
  • a main .js file that can run without caring where it is relocated

Right now it looks like putting pwd/lib into $NODE_PATH will satisfy the first requirement. For the second one, it seems like it should either be cli.js or specs.js. cli.js didn't work for me, but isn't mentioned in the readme so maybe it's not meant as a front-end for running jasmine. I also tried running specs.js, but it does not do well at being run from anything but the current location, because:

  • it puts "./lib" in require.paths
  • it runs specs from __dirname + '/spec'

This actually seems backwards to what I would expect - I would have thought you'd want to add __dirname + '/lib' to require.paths (although this should be unnecessary if you set $NODE_PATH appropriately), and that you'd run specs from "./spec", rather than the spec directory from wherever jasmine is installed.

To clarify what I'd like, imagine I have jasmine-node checked out into /some/random/path/jasmine-node. I would like to be able to run something like the following, from ~/dev/my-project (which has a spec directory):

~/dev/my-project $ export $NODE_PATH=/some/random/path/jasmine-node/lib
~/dev/my-project $ node /some/random/path/specs.js

Is this or something like it possible?

Node 0.5 compatibility

When trying to run jasmine-node with node 0.5.x it throws a fit.

        throw e; // process.nextTick error, or 'error' event on first tick
              ^
Error: require.paths is removed. Use node_modules folders,
 or the NODE_PATH environment variable instead.```

No way to control the ordering of suites across files

To try to keep my tests manageable, I wanted to split them across files. I tried naming those files things like 000_... 001_... to try to get them to execute in a specific order, but looking at the code, it seems like the filenames of the specs become irrelevant once they've been loaded.

Is there any way to control the ordering of suite execution that I'm not aware of? If not, this would be a nice feature to have.

Can't run jasmine-node on the console

I've installed jasmine-node with npm but there is no jasmine-node command available.

I've looked at the package.json. Seems that there is no "bin" file.

How do I use jasmine-node?

Truncated console output

jasmine-node seems really keen on truncating any output going to the console, it seems there's a hard limit on how much it can print or perhaps there's some kind of async issue that means that it doesn't have time to finish printing output.

Can something be done about this, it becomes frustrating when not able print the information needed to debug specs.

It also does this for the stack traces printed when any test fails, perhaps this is so it doesn't print out a massive stack trace for the entire running jasmine suite, but perhaps that means we need a different approach to executing the specs so can get sensible traces. I had a quick look around the code but couldn't see how to fix this myself, sorry. Any ideas?

Feature request: Run one spec file

In the test folder I have a lot of spec files.

When adding a new one it would be nice if I could just run that one instead of all of the specs I have.

Consider bundling jasmine 2.0.0rc1

Currently, the jasmine backtraces on failed tests are more noise than signal; there has been a patch for that in jasmine master which according to jasmine/jasmine#5 should have been included in the jasmine 1.1.0 release.

However the maintainers seem to have jumped from 1.1.0rc4 to 2.0.0rc1, and in the meantime the missing signal in the backtraces is rather annoying.

Please consider updating the bundled jasmine, unless of course it breaks something :).

Testing AMD Modules

jasmine-node unfortunately doesn't come as a module (var jasmine = require('jasmine-node');) so the only option is to the use command line tool. And the command line tool blows up when when your specs are themselves AMD modules. I created a sample project to try to figure out how to test AMD modules with jasmine-node, if anyone wants to help out.

Thanks

Error: Cannot find module 'underscore'

After launched this command "jasmine-node --runWithRequireJs ."
Error: Cannot find module 'underscore' [...]

Done on global fresh install via npm.
It seems the underscore depedency is missing...

(nodejs v0.6.2, npm v1.1.0-beta-7)

Nice tool, thanks in advance!

Naming of helpers, consistency

I can name my specs xx_spec.js and xxSpec.coffee, but the helper files have to include an underscore. This is not consistent.
Also, I would like to just accumulate all my helpers in a helpers.js file, that is not possible either.

Working with DOM

Do you guys think it's also a good idea to run DOM related specs in jasmine-node? I am currently working on a fork to use jsdom and run specs in "its" context. In turn I can have a more coherent test environment not requiring the browser and also being able to use autotest/guard.

Feature request: could asyncSpecDone() be called before asyncSpecWait()

Seems logical to me to write asyncSpecWait() at the end of the spec - meaning I finished everything and now I am waiting for async function. But I may not know whether function is async or not and still want to keep the same spec.

I added simple spec to demonstrate my requirements:

describe('async spec', function () {
    it('finishes when wait is called before done', function () {
        jasmine.asyncSpecWait();
        jasmine.asyncSpecDone();
    });

    it('should finish when done is called before wait', function () {
        jasmine.asyncSpecDone();
        jasmine.asyncSpecWait(); //will timeout
    });
});

What do you think? Should this order matter?

v1.0.19 does not run any test

I'm currently on my windows machine with node version 0.6.7 and npm 1.1.0-beta-10. I installed jasmine-node with:

npm install jasmine-node -g

when i run command

jasmine-node spec

the output looks like:

Finished in 0 seconds
0 tests, 0 assertions, 0 failures

When uninstalled and installed version 1.0.17 (which i used few days ago on linux) i got:

..........

Finished in 0.012 seconds
10 tests, 16 assertions, 0 failures

I have three specs in spec folder, named *.spec.js

Are there any changes so my old spec files are not recognized?

Is there reason, why bin isn't declared?

I just installed jasmine-node with npm and I noticed that bin wasn't linked to my bin folder. I did some research and it requires bin declaration in package.json. I tried that and it worked. So what is the reason, why this isn't declared by default? I'm quite new to node and npm, so I also want to learn this kind of details :)

--coffee argument missing in npm version

I installed the package through npm, but kept getting Error: Cannot find module when running coffeescript specs. I managed to fix the issue by adding the --coffee argument which was missing from the cli.js file's switch statement.

The code is correct in the master branch so I haven't attached a pull request. Could this be related to the invalid package.json? See ticket #29.

Debugging?

This isn't so much an issue as a question - have you tried to debug into tests with node-inspector or something similar?

test that loops over vaules fails if it's the first one

Using version 1.0.9 installed via npm, I have found that if I iterate over a list of values to test (for example, invalid email or url characters), this test fails if it is the first or only test in the spec file. If it is second, then it works. Am I doing something wrong or is this a bug? I created gist 1212065 ( https://gist.github.com/1212065 ) which shows both the broken version and the working version that uses a fake test to "prime" jasmine.

removeJasminFrames function throws TypeError: Cannot call method 'split' of undefined

In some cases when spec fails I get this error and node process exits (using node v0.4.8).

Started
........F.
/usr/local/lib/node/.npm/jasmine-node/1.0.8/package/lib/jasmine-node/index.js:52
  text.split(/\n/).forEach(function(line){
       ^
TypeError: Cannot call method 'split' of undefined
    at Object.removeJasmineFrames [as stackFilter] (/usr/local/lib/node/.npm/jasmine-node/1.0.8/package/lib/jasmine-node/index.js:52:8)
    at /usr/local/lib/node/.npm/jasmine-node/1.0.8/package/lib/jasmine-node/reporter.js:80:48
    at Array.forEach (native)
    at /usr/local/lib/node/.npm/jasmine-node/1.0.8/package/lib/jasmine-node/reporter.js:79:21
    at Array.forEach (native)
    at Object.reportSuiteResults (/usr/local/lib/node/.npm/jasmine-node/1.0.8/package/lib/jasmine-node/reporter.js:74:24)
    at [object Object].finish (/usr/local/lib/node/.npm/jasmine-node/1.0.8/package/lib/jasmine-node/jasmine-1.0.1.js:2117:21)
    at [object Object].onComplete (/usr/local/lib/node/.npm/jasmine-node/1.0.8/package/lib/jasmine-node/jasmine-1.0.1.js:2164:10)
    at [object Object].next_ (/usr/local/lib/node/.npm/jasmine-node/1.0.8/package/lib/jasmine-node/jasmine-1.0.1.js:1749:14)
    at [object Object].start (/usr/local/lib/node/.npm/jasmine-node/1.0.8/package/lib/jasmine-node/jasmine-1.0.1.js:1692:8)

This bug is introduced in v1.0.8. It makes hard to identify the error...

The same spec with v1.0.7 returns:

Started
........F.

answer
  it calls answer method on the right channel
  undefined

  undefined

  Error: TypeError: Object [object Object] has no method 'toBeTruthly'
    at new <anonymous> (/usr/local/lib/node/.npm/jasmine-node/1.0.7/package/lib/jasmine-node/jasmine-1.0.1.js:94:50)
    at [object Object].fail (/usr/local/lib/node/.npm/jasmine-node/1.0.7/package/lib/jasmine-node/jasmine-1.0.1.js:1963:27)
    at [object Object].execute (/usr/local/lib/node/.npm/jasmine-node/1.0.7/package/lib/jasmine-node/jasmine-1.0.1.js:970:15)
    at [object Object].next_ (/usr/local/lib/node/.npm/jasmine-node/1.0.7/package/lib/jasmine-node/jasmine-1.0.1.js:1739:31)
    at [object Object].start (/usr/local/lib/node/.npm/jasmine-node/1.0.7/package/lib/jasmine-node/jasmine-1.0.1.js:1692:8)
    at [object Object].execute (/usr/local/lib/node/.npm/jasmine-node/1.0.7/package/lib/jasmine-node/jasmine-1.0.1.js:2018:14)
    at [object Object].next_ (/usr/local/lib/node/.npm/jasmine-node/1.0.7/package/lib/jasmine-node/jasmine-1.0.1.js:1739:31)
    at [object Object].start (/usr/local/lib/node/.npm/jasmine-node/1.0.7/package/lib/jasmine-node/jasmine-1.0.1.js:1692:8)
    at [object Object].execute (/usr/local/lib/node/.npm/jasmine-node/1.0.7/package/lib/jasmine-node/jasmine-1.0.1.js:2163:14)
    at [object Object].next_ (/usr/local/lib/node/.npm/jasmine-node/1.0.7/package/lib/jasmine-node/jasmine-1.0.1.js:1739:31)

Finished in 0.006 seconds
5 tests, 17 assertions, 1 failure

I believe this is related to using waitsFor method, I have noticed it in async specs only...

Simple spec to reproduce:

describe('throwing spec', function () {
    it('is bad', function () {
        var completed = false;
        var obj = { func: function() {
            expect(completed).toBeFalsy();
            completed = true;
        }};
        obj.func();
        waitsFor(function () { return completed });
        expect(function () { return false }).toBeThere(); //will throw
    });
});

invalid package.json file in npm

The package.json file in NPM is:

{
    "name" : "jasmine-node",
    "version" : "1.0.1",
    "description" : "DOM-less simple JavaScript BDD testing framework for Node",
    "homepage" : [
        "http://pivotal.github.com/jasmine" ,
        "https://github.com/mhevery/jasmine-node"
    ],
    "repository" : {
        "type" : "git" ,
        "url" : "https://github.com/mhevery/jasmine-node.git" 
    },
    "keywords" : [
        "testing",
        "bdd"
    ],
    "author" : "Misko Hevery <[email protected]>",
    "contributors" : [
        "Rajan Agaskar <[email protected]" ,
        "Christian Williams <[email protected]" ,
        "Davis W. Frank <[email protected]>",
        ,
        "Matteo Collina <[email protected]>" 
    ],
    "maintainers" : "Martin Häger <[email protected]>",
    "licenses" : [
        "MIT"
    ],
    "dependencies" : {
        "coffee-script" : ">=1.0.0"
    },
    "bin" : "./bin/jasmine-node",
    "main" : "./lib/jasmine-node"
}

There are two commas after Davis W. Frank's contributor entry, which makes the json file invalid.

--include tag for CLI

Hello,

I've another thing how we could improve jasmine-node, but first want to discuss it with you. How about to add to CLI tag --include PATH, which will first for you add the PATH to the node libraries?

Then you can more easily reference components, you are testing in the jasmine suite. The idea comes from expresso, also quite popular way how to test node.js apps. Let me know what do you think. Its kind of easy to add.

Guidance for jasmine-node developers on how to run specs

I'm doing a decently significant refactor job relating to #51 (indirectly #46), and I want to make sure not to break any existing functionality. I see that there's already a spec folder in the project, but attempting to run it with jasmine-node (./bin/jasmine-node ./spec) produces an error.

Can I (and other developers) have some guidance in the README on how to properly run the tests for the project?

FWIW the error generated in my fork is:

>./bin/jasmine-node ./spec

node.js:134
        throw e; // process.nextTick error, or 'error' event on first tick
        ^
Error: Cannot find module 'test'
    at Function._resolveFilename (module.js:317:11)
    at Function._load (module.js:262:25)
    at require (module.js:346:19)
    at Object.<anonymous> (/Users/eboto/jasmine-node/jasmine-node/spec/include/include_spec.js:1:74)
    at Module._compile (module.js:402:26)
    at Object..js (module.js:408:10)
    at Module.load (module.js:334:31)
    at Function._load (module.js:293:12)
    at require (module.js:346:19)
    at Object.executeSpecsInFolder (/Users/eboto/jasmine-node/jasmine-node/lib/jasmine-node/index.js:149:5)

Please document asyncSpecWait() and asyncSpecDone()

I'm currently using jasmine-node with zombiejs to run some async tests.

In some cases, I have nested async calls, for example :
it('displays the page correctly', function() {
zombie.visit(myUrl, function(err, browser, status) {
//a- Title on the page is correct
expect(browser.text('title')).toEqual('first page');

  //b- There is an 'Add product' link      
  var addButton = browser.css('#addButton').length;
  expect(addButton).toEqual(1);

  //c- A click on the Add button links to the New Page
  browser.clickLink('#addButton', function(err, browser, status) {
    expect(browser.text('title')).toEqual('New Page')
    jasmine.asyncSpecDone();
  }) 
  jasmine.asyncSpecWait()
})

})

In other cases, I have several async tests in the same suite :

describe('home page', function() {
it('loads the page correctly', function() {
zombie.visit(thisUrl, function(err, browser, status) {
expect(err).toBeNull();
expect(status).toBe(200);
jasmine.asyncSpecDone();
})
})

it('displays correctly', function(){
zombie.visit(thisUrl, function(err, browser, status){
//a- There is one form on the page
var theForm = browser.css("form");
expect(theForm.length).toBe(1);
expect(browser.css("#name").length).toBe(1);
jasmine.asyncSpecDone();
})
})

it('has the right interactions', function() {
zombie.visit(thisUrl, function(err, browser, status) {
//expect ...
jasmine.asyncSpecDone();
})
})
})
jasmine.asyncSpecWait()

Both snippets run fine, but I really need to better understand how to use asyncSpecDone() and asyncSpecWait(). A little documentation on it would be very nice (where to place each call, how many calls are needed, wha

Install documentation needs improvement

The installation documentation should be a little bit more detailed. Even with installation via npm people have issues configuring their NODE_PATH and seem confused at how the cli should be run.

Perhaps add some notes about how to setup a basic project including a sample Spec, a sample javascript file under test, including all the necessary requires, as well as how this would be run from the command line.

Add ability to run tests in Node.js instead of the browser

I really like jasmine-node as it adds some much-needed usability to my tests. Thank you for creating it!

When I began using it, I had sort of assumed that jasmine-node would run the tests in node.js itself. I discovered that this is not the case when I went to use require and some other stuff, finding that it caused errors. This fact was further reinforced by the failure of code which relies on certain ES5 features present in V8 but not in other JS implementations which caused the tests to pass in Chrome but fail in other browsers.

I am filing this to request that a change be made to allow tests to be run inside node.js itself instead of the browser. Can such a thing be done? Thanks!

1.0.10 Asks for test folder when requiring, and doesn't install CLI

I just tried to install the latest npm install jasmine-node -g and I got -bash: /Users/Craig/local/node/bin/jasmine-node: No such file or directory when trying to run jasmine-node at the command line.

Also using jasmine = require('jasmine-node') in a Cakefile threw No such file or directory '/Users/Craig/inertia/test'

nested describe produces "it undefined" output

Running the following spec

describe('root', function () {

  describe('nested', function () {

    it('nested statement', function () {
      expect(1).toBeTruthy();
    });

  });

  it('root statement', function () {
    expect(1).toBeTruthy();
  });

});

Produces the following output

  Started
  ..

  Spec root nested
    it nested statement
  Spec root
    it undefined
    it root statement
  Finished in 0.002 seconds
  2 tests, 2 assertions, 0 failures

Which means it's counting the correct number of specs (2) but it's producing 3 it statements. It seems like the second one "it undefined" is being generated due to the nested describe.

Can someone try to reproduce it?

Thanks
-w

It is unclear that "spec" must be in the filename

I'm new to Jasmine and BDD, but I just wanted to leave a note to say that it was unclear to me that I needed the word "spec" in the .coffee or .js filename. I figured since the specs where in the spec folder that would be enough. Took me a while to figure it out too. Thanks.

Creating a matcher for equals-method

I don't know if you do this, but I build my ValueObjects with an equals-method. So I can define my own conditions to the equality of two objects. These are to be compared by

obj1.equals(obj2)
As the standard matcher from jasmine doesn't check for this method, I wrote my own matcher:

toBeEqualTo: function(expected) {
    return this.acutal.equals(expected);
}

TypeError: Cannot call method 'equals' of undefined

Really? I was quite sure about the rest of the code, so I reversed it:

toBeEqualTo: function(expected) {
    return expected.equals(this.acutal);
}

Error: Expected { method : Function, equals : Function, ... } to be equal to { method : Function, equals : Function, ... } at ... bla

Huh? So now I'm confused. Are these objects undefined or equal but not equal?

Also, my objects have a toString/toJSON method, I like those to be used if I see them printed out.

find fail() function?

Hi, when I run jasmine-node over tests and attempt to call the fail() method, I get this:

ReferenceError: fail is not defined

fail() is defined in Jasmine, though I'm not sure of jasmine-node is supporting that part of the API yet? I have yet to look at this in any depth though I intend to, and I'll follow up with additional info as I get it.

I use it like this, preferring the second case

describe('thing', function() {

  it('should fail', function() {
    fail();
  });

  it('should also fail', fail());

});

CLI: Object #<Object> has no method 'loadHelpersInFolder'

I just tried to run from HEAD, but I get this error:
TypeError: Object # has no method 'loadHelpersInFolder'
at Object. (/home/tim/gnome-shell/shellshape/jasmine-node/lib/jasmine/cli.js:30:9)
at Module._compile (module.js:404:26)
at Object..js (module.js:410:10)
at Module.load (module.js:336:31)
at Function._load (module.js:297:12)
at Array. (module.js:423:10)
at EventEmitter._tickCallback (node.js:126:26)

Is there a dependency I'm missing? (I'm not using npm or anything). The function doesn't seem to be defined anywhere in this repo:

$ ack -u loadHelpersInFolder
lib/jasmine/cli.js
30:jasmine.loadHelpersInFolder(SPEC_FOLDER, HELPER_MATCHER_REGEX);

Rename the shell command to simply 'jasmine'?

Can we rename the shell command to simply 'jasmine'? Possible? jasmine-node is pretty ugly. Is there some kind of conflict with another tool?
If there is a conflict, jasmine-test would be preferable to jasmine-node, since the 'node' part is pretty redundant. Imagine if every node commandline tool had -node at the end. yuck.

Report as the html runner

Jasmine-node reports assertions failed/succeded, not number of tests, like the html report. Both could be more complete, but, in particular, node version could also report the number of tests.

Refactor object-literal reporter into jasmine.NodeReporter

It would significantly help anyone who wants to run jasmine-node programmatically if the custom reporter implemented on index.js:65 were refactored into its own class: perhaps NodeReporter?

without said refactor, it's still possible to run the test runner, but difficult to get useful input!

Best way to auto-restart, on file changes?

Any way to add a 'watch' feature? where the tests auto restarts on file-spec / directory changes?

There's modules like nodemon and supervisor but I haven't figured out how to use it with jasmine-node yet...

Is there a generic unix command that execute a certain command on file/directory changes?

Thanks.

Node 0.6.0 compatibility

Jasmine-node fails for me when using node 0.6.0 with this error:

NODE_ENV=test node_modules/jasmine-node/bin/jasmine-node spec/controllers
The "sys" module is now called "util". It should have a similar interface.
... a few lines of output from my initialization code
Started
FATAL ERROR: v8::HandleScope::Close() Local scope has already been closed

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.