Giter Site home page Giter Site logo

jasmine-npm's Introduction

The Jasmine Package

The jasmine package is a command line interface and supporting code for running Jasmine specs under Node.

The core of jasmine lives at https://github.com/jasmine/jasmine and is jasmine-core in npm.

Contents

This package allows you to run Jasmine specs for your Node.js code. The output will be displayed in your terminal by default.

Documentation

https://jasmine.github.io/setup/nodejs.html

Quick Start

Installation:

npm install --save-dev jasmine

To initialize a project for Jasmine:

npx jasmine init

To seed your project with some examples:

npx jasmine examples

To run your test suite:

npx jasmine

ES and CommonJS module compatibility

Jasmine is compatible with both ES modules and CommonJS modules. See the setup guide for more information.

Node version compatibility

Jasmine supports Node 18, 20, and 22.

Support

Documentation: jasmine.github.io Please file issues here at GitHub.

Copyright (c) 2014-2019 Pivotal Labs Copyright (c) 2014-2023 The Jasmine developers This software is licensed under the MIT License.

License

FOSSA Status

jasmine-npm's People

Contributors

amavisca avatar amilajack avatar battk avatar bcaudan avatar briandipalma avatar cancerberosgx avatar claudiosdc avatar coyoteecd avatar dflynn15 avatar ffortier avatar flore77 avatar fossabot avatar hankduan avatar just-boris avatar liuxh0 avatar lonelyelk avatar lucaswerkmeister avatar marcioj avatar mauricioborges avatar mikaturunen avatar olemchls avatar sgravrock avatar strager avatar strama4 avatar susisu avatar tharvik avatar tomv564 avatar uzitech avatar wendorf avatar ybian 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

jasmine-npm's Issues

Impossible to rerun in the same runtime because of require cache

Hello,
This is really related to #5
We are integrating this lib as a grunt task at the moment. Everything works great except for one thing.
We try to rerun specs every time something changes in the same runtime env. (so, in terms of grunt watch task it's options: {spawn: false} which mean there is no new node process. We need this to keep in our case webdriver client.
The problem is when we try to create and run jasmine-npm second time. Internally it uses require(spec) to load and register all the describe, it etc. Second time it doesn't do this, because require will use internal cache and never execute describe second time, hence won't register it and jasmine will report 0 specs found.
Our current solution is pretty hacky:

    /**
     * Invalidate require internal cache for modules that contains provided
     * path part in it's full name.
     * @param path
     */
    var invalidateRequireCacheByPath = function (path) {
        for (var name in require.cache) {
            if (name.indexOf(path) >= 0) {
                delete require.cache[name];
            }
        }
    };

//..... 

            // jasmine-npm uses require() to load specs, during which time
            // all the "describe" "it" etc. register them self.
            // If we try to create second instance of jasmine-npm in the same runtime,
            // cached version of specs is taken and
            // 1) New test code is not loaded and not executed
            // 2) "describe" and other method are not called, hence specs are not registered
            invalidateRequireCacheByPath(options.spec_dir); 

So I was hoping we can think on better solution.

Question about output

After trying to get jasmine-node to work and google-ing for all sorts of info about nodejs and jasmine-node i ran in to jasmine-npm and it just works :)

After combining it in to our build on a bamboo build server it sort of works, when i check the logs i see that non of my tests failed, but how can i change the output. Bamboo can handle test outputs in a junitreport format but how can i do this using jasmine-npm (if at all)?

Unknown options are silently accepted.

It seems the jasmine command silently ignores any incorrect option.
A concrete example that wasted me hours: I was passing --stop-on-failure which had no effect; turns out I must pass --stop-on-failure=true.
Even --help is ignored and the tests just run! (jasmine help works but I only discovered that by peeking at the source, which kinda misses the point of having a help option...)

I think the standard behavior of exiting with error message would be better for users.

Cannot run jasmine via `./node_modules/.bin/jasmine`

I'm unable to run jasmine via ./node_modules/.bin/jasmine. This used to work in the past.

I get the following error:

$ ./node_modules/.bin/jasmine

module.js:340
    throw err;
          ^
Error: Cannot find module '../lib/command.js'
    at Function.Module._resolveFilename (module.js:338:15)
    at Function.Module._load (module.js:280:25)
    at Module.require (module.js:364:17)
    at require (module.js:380:17)
    at Object.<anonymous> (/vagrant/node_modules/.bin/jasmine:4:15)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Function.Module.runMain (module.js:497:10)

I'm on jasmine 2.1.1 Here's the relevant partial output of npm ls

โ”œโ”€โ”ฌ [email protected]
โ”‚ โ”œโ”€โ”ฌ [email protected]
โ”‚ โ”‚ โ”œโ”€โ”€ [email protected]
โ”‚ โ”‚ โ””โ”€โ”ฌ [email protected]
โ”‚ โ”‚   โ”œโ”€โ”€ [email protected]
โ”‚ โ”‚   โ””โ”€โ”€ [email protected]
โ”‚ โ””โ”€โ”€ [email protected]

Fails due to timeout before jasmine.DEFAULT_TIMEOUT_INTERVAL

I'm using jasmine 2.4.1
When I do this:

    describe('tests content controller', function(){
        beforeAll(function(done) {
        jasmine.DEFAULT_TIMEOUT_INTERVAL= 120000;
        //...
    });

    fit('/content GET should return 200',function(done){
        request(app)
        .get('/content')
        .set('Authorization', "bearer " + requestor.token)
        .set('Accept', 'application/json')
        .expect(200)
        .end(function (err, res) {
             console.log('timeout',jasmine.DEFAULT_TIMEOUT_INTERVAL); //prints 120000
             if (err) done.fail(err);
             expect(res.statusCode).toBe(200);
             done();
        })
    })

I get this:

1) tests content controller /content GET should return 200
  Message:
    Error: Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL.
  Stack:
    Error: Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL.
        at Timer.listOnTimeout [as ontimeout] (timers.js:110:15)

Ran 1 of 365 specs
1 spec, 1 failure
Finished in 101.042 seconds
1..365
#365 specs, 1 failure, 0 skipped, 364 disabled in 101.042s.

120s > 101s right? So it seems like this test shouldn't be timing out.

Please add --fail-fast support

It would be great to be able to exit on the first spec failure and see its output. It would greatly speed up my testing workflow.

onComplete() is never fired in a Grunt task

I've built a very simple Grunt task for Jasmine (Node) based on the task example. But onComplete() callback is never fired in the Grunt task (so does the done() method). Am I missing something?

module.exports = function (grunt) {
    'use strict';

    var Jasmine = require('jasmine');

    grunt.registerTask('jasmine_task', function () {
        var jasmine = new Jasmine(),
            done = this.async();

        jasmine.configureDefaultReporter({
            print: function () {
                grunt.log.writeln.apply(this, arguments);
            },
            onComplete: function (passed) {
                done(passed);
            }
        });

        var specFiles = grunt.file.expand('test/node/unit/**/*spec.js');
        jasmine.execute(specFiles);
    });
};

If not inside a Grunt task, this code works as expected.

Mac OS X Yosemite (10.10.2)
Node v0.10.22
grunt-cli v0.1.13
grunt v0.4.5

Option spec_dir

I was curious what the motivation for specifying the spec_dir option was.
Note: Most observations are based on a cursory look through the code base and not someone who has created it.

It appears to me as if the spec_dir is a convenient abstraction from adding spec/ to the files/helpers/config. Could this not be an optional parameter for developers who have full paths and do not necessarily need the spec_dir option?

I realize that I am more than likely simplifying the necessity of the parameter, but it feels odd that you cannot run jasmine with only just the spec_filesin Node.

Adding jasmine reporters to boot file.

The latest version of jasmine-npm does not support adding a reporter in a boot file (see #32). This appears to be fixed in master; is there any way a new release can be cut to make the fix available?

Custom boot for Node

The custom boot.js file introduced in 2.0 is a great addition, however I am trying to figure out how to use jasmine with Node with a custom boot.js file, and so far the only way I seem to be able to get this to work is to invoke the Jasmine Runner directly from a Grunt script as opposed to using the jasmine command line script.

I have worked around this issue easily when running the entire test suite using helpers, however when I run a single spec such as jasmine spec/whatever.spec.js the helpers are not loaded.

I have also tried adding a boot_files option to my jasmine.json file without luck.

Is there a recommended way with node to inject your own custom boot?

On a slightly separate note, I see in https://github.com/jasmine/jasmine-npm/blob/master/lib/jasmine.js#L45-L46 that you automatically add the default console reporter. If I want to use a different reporter, it seems unfortunately there is no way to do that because the API only exposes an addReporter method. Any thoughts on how to address that?

spyOn issue

test

  • test 1 success
  • test 2 failed (same test)

error

  Message:
    Expected spy failed to have been called.
  Stack:
    Error: Expected spy failed to have been called.
        at Object.<anonymous> (/home/project/jasmine-issue/spec/testSpec.js:49:26)

version

[email protected]
โ”œโ”€โ”€ [email protected]
โ”œโ”€โ”€ [email protected]
โ””โ”€โ”€ [email protected] ([email protected], [email protected])
CentOS 7

code:

  1 describe("Jasmine", function() {
  2
  3         function test(mockObject, res) {
  4                 mockObject.test(function() {
  5                         res.failed();
  6                 });
  7         };
  8
  9         function fn_proxy(cb) {
 10                 cb();
 11         }
 12
 13         var resFailed;
 14         var mock = {
 15                 test : function(cb,res) {
 16                         cb();   // function() { res.faled();}
 17                 }
 18         };
 19         var resMock = {
 20                 failed : function(){
 21                         resFailed = true;
 22                 }
 23         };
 24
 25         beforeEach(function() {
 26                 resFailed = false;
 27         });
 28
 29         it("should call function 'res.failed()' without spyOn", function() {
 30                 expect(resFailed).toEqual(false);
 31                 fn_proxy(function() {
 32                         test(mock,resMock);
 33                 });
 34                 expect(resFailed).toEqual(true);
 35         });
 36
 37         it("should call function 'res.failed()'", function() {
 38                 expect(resFailed).toEqual(false);
 39
 40                 spyOn(mock,'test');
 41                 spyOn(resMock, 'failed');
 42
 43                 fn_proxy(function() {
 44                         test(mock,resMock);
 45                 });
 46
 47                 expect(resFailed).toEqual(true);
 48                 expect(mock.test).toHaveBeenCalled();
 49                 expect(resMock.failed).toHaveBeenCalled();
 50         });
 51 });

Running with harmony enabled

It's currently possible to run jasmine in harmony mode with node --harmony node_modules/jasmine/bin/jasmine.js but it would be convenient to be able to run jasmine --harmony. Is this a feature you'd like?

How do you remote debug Jasmine tests?

With jasmine-node, you can execute:

node --debug-brk node_modules/jasmine-node/lib/jasmine-node/cli.js spec/codec_spec.js

Then, from the IDE I can open a remote Node.js debug session on port 5858.

Is it possible to do something similar with jasmine/jasmine-npm ?

2.3.0 seems to return wrong exit code

I use gulp-jasmine to run my unit-test.

Since the update 2.3.0 in jasmine, which is installed in gulp-jasmine due to caret version binding, the process simply ends after running the unit tests.

It doesn't matter wether all unit tests are green or none unit tests are executed at all. The process simply stops.

I did not have time to isolate the specific code part responsible for this behaviour so far, but as exit behaviour was changed in the last update it seems likely to be connected to this issue.
I try to investigate further to provide more details.

I'll add the environments were I experienced the behaviour, as the commit mentioned above seems to deal with platform related code.

OS: OS X 10.10.13
NodeJS: 0.10.38 & 0.12.2
gulp-jasmine: 2.0.1

If needed I'll provide further details

Jasmine + Supertest

I'm using supertest for testing Express applications. I found that jasmine totally breaks supertest's expect matchers โ€” there are no errors, everything just passes with green, even when the assertion is false. When I replaced jasmine with mocha, supertest started working as expected.

"express": "^4.11.2",
"supertest": "^0.15.0"`

How to get list of tests run?

Running jasmine-node has a verbose option to list all tests it ran. However, that doesn't list pending tests.

I'd actually prefer to run the jasmine CLI which lists the pending tests, but I can't find a way to list the specs that were run, I only see
....
which doesn't tell me what sorts of tests were run.

Is there a way to do this? Thanks

Will not run all files and crashes on final spec

Operating System: Mac OS X 10.10 (Yosemite)
Jasmine Version: 2.2.1
Problem:
When running my specs, which I have compiled from Cofeescript in to Javascript, I always seem to get this error for my final spec, if I disable it xit then it completes fine but does not run the other files in my spec directory. I don't use spies at all in my code so this error has me stumped.

Warning: Command failed: 
TypeError: Cannot read property 'spies' of undefined
    at Env.j$.SpyRegistry.currentSpies (/usr/local/lib/node_modules/jasmine/node_modules/jasmine-core/lib/jasmine-core/jasmine.js:656:53)
    at SpyRegistry.clearSpies (/usr/local/lib/node_modules/jasmine/node_modules/jasmine-core/lib/jasmine-core/jasmine.js:1870:19)
    at Env.clearResourcesForRunnable (/usr/local/lib/node_modules/jasmine/node_modules/jasmine-core/lib/jasmine-core/jasmine.js:532:21)
    at Suite.j$.Suite.resultCallback (/usr/local/lib/node_modules/jasmine/node_modules/jasmine-core/lib/jasmine-core/jasmine.js:676:13)
    at complete (/usr/local/lib/node_modules/jasmine/node_modules/jasmine-core/lib/jasmine-core/jasmine.js:2051:12)
    at QueueRunner.clearStack (/usr/local/lib/node_modules/jasmine/node_modules/jasmine-core/lib/jasmine-core/jasmine.js:594:9)
    at QueueRunner.run (/usr/local/lib/node_modules/jasmine/node_modules/jasmine-core/lib/jasmine-core/jasmine.js:1736:12)
    at /usr/local/lib/node_modules/jasmine/node_modules/jasmine-core/lib/jasmine-core/jasmine.js:1753:16
    at /usr/local/lib/node_modules/jasmine/node_modules/jasmine-core/lib/jasmine-core/jasmine.js:1697:9
    at complete (/usr/local/lib/node_modules/jasmine/node_modules/jasmine-core/lib/jasmine-core/jasmine.js:358:9)
 Use --force to continue.

Cannot remove default report when using current environment

Hi there,

I was checking the issues #20 and #21, and I believed that the solution proposed in #21 would solve my problem. However, when I use jasmine.getEnv().addReport it does not work. I've created a helper with the following content:

var SpecReporter = require('jasmine-spec-reporter');
jasmine.getEnv().addReporter(new SpecReporter());

And the default reporter is also added when running.

I've created an example into the specification: mauricioborges@c5e466d but I'm not sure if I'm using the correct approach. As I'm using the double env method, it's feasible that it won't work.

Thanks for all your help!

this.env.randomizeTests is not a function

I'm learning how to use jasmine, but it looks like I'm getting this error:

this.env.randomizeTests is not a function

I cloned this repo and npm installed and then npm test. I'm getting:

$ npm test                                                                                                      

> [email protected] test /home/ionicabizau/Documents/learning-nodejs/jasmine-test/node_modules/jasmine
> grunt && ./bin/jasmine.js

Running "jshint:all" (jshint) task
>> 20 files lint free.

Running "specs" task
Warning: this.env.randomizeTests is not a function Use --force to continue.

Aborted due to warnings.
npm ERR! Test failed.  See above for more details.

Is this a bug or did I do something wrong?

`beforeEach` no longer shares a context with `it`

I have this test, which works just fine under version 2.2.1 but breaks in 2.3:

      describe('when a service error occurs', function () {
        beforeEach(function () {
          var courseService = this.registry.Course;

          this.fakeError = {                                                                                                                                                                                                                                                            
            message: 'Failed to create course user'
          };  

          sinon.stub(courseService, 'findBySlug')
            .callsArgWith(2, this.fakeError);
        }); 

        afterEach(function () {
          this.registry.Course.findBySlug.restore();
        }); 

        it('should respond with a 400', function (done) {
          var fakeError = this.fakeError;
          console.log('fakeError', fakeError);
          request(app)
            .get('/admin/course/slug')
            .expect(400)
            .end(function (error, response) {
              console.log('fakeError', fakeError);
              var expectedError = { 
                service: [fakeError.message]
              };  

              expect(error).toBeNull();
              expect(response.body.errors).toEqual(expectedError);
              done(error);
            }); 
        }); 
      }); 

The issue in version 2.3 is that this.fakeError is undefined in the it. If I pull the variable into the closure created for the describe block then all is well.

Is this an expected change? I found no mention of a change like this in the release notes.

Display (or not) disabled specs?

Hi,

I thought I'd found a bug that you don't get any output for specs which are contained in an xdescribe block, unlike the pending info printed for xit. But then looking at console_reporter_spec.js it looks like it's deliberate? This seems kind of dangerous..

Perhaps I'm misunderstanding something, but I've modified a fork (https://github.com/LJWall/jasmine-npm/tree/master) to report disabled specs with a yellow dash, and summarise disabled specs/suites at the end,

LJ

Custom reporter

I think it would be much easier to solve compatibility issues (like this) if we will be able to configure the reporter from the config file (so we would not have to modify the code itself). Having at least the print and onComplete config options would be great.

Add logging options

When running jasmine-npm, every success just prints a .. It would be nice if I could see the specs outputted like it is on jasmine.github.io

A suite
  contains spec with an expectation

A suite is just a function
  and so is a spec

The 'toBe' matcher compares with ===
  and has a positive case
  and can have a negative case

customer reporter not finishing

I'm having a problem that seems related to #20, but I think that it may be different.

I'm trying to setup a simple Growl reporter. (Maybe there's already one out there that you can recommend?) I'm using 2.2.1.

My problem is this:
In the execute method of the wrapper that jasmine-npm creates around jasmine-core, it checks the reportersCount property and sets up the default reporter is the value is 0. The value of reportersCount is only modified in addReporter.

The instance of jasmine in my custom report is the one that is being wrapped. This means that I am not able to use the method that bumps reportersCount. In turn, configureDefaultReporter is always called. (I actually do want the ConsoleReporter to be added to, but I think that it's onComplete is terminating everything before my customer reporter is done.)

The end result is that jasmineDone is never called on my customer reporter.

My implementation (es6) is here:
https://gist.github.com/bennage/10bc25cdcc869bdbd92f

Any help is greatly appreciated.

Helper functions not loading

It appears that the helpers folder should be in the folder defiend by spec_dir, I've also tried though with the helpers folder at the root right along side spec_dir.

./spec/support/jasmine.json

{
  "spec_dir": "spec",
  "spec_files": [
    "**/*[sS]pec.js"
  ],
  "helpers": [
    "helpers/**/*.js"
  ]
}

./spec/spec.js

describe('Include helpers', function () {
    it('should have foo defined', function () {
        expect(typeof foo).toBe('function')
    })
})

./spec/helpers/test_helper.js

module.exports = {
    foo: function () {
        return 'bar';
    }
}

This fails

~/t/test $ cat ~/local/lib/node_modules/jasmine/package.json | grep version
  "version": "2.2.0",
~/t/test $ jasmine
Started
F

Failures:
1) Include helpers should have foo defined
  Message:
    Expected 'undefined' to be 'function'.
  Stack:
    Error: Expected 'undefined' to be 'function'.
        at Object.<anonymous> (/home/tperson/tmp/test/spec/spec.js:3:28)

1 spec, 1 failure
Finished in 0.004 seconds
~/t/test $ 

https://gist.github.com/travisperson/328381f4ea9a7deac3f2

onComplete never fires

Jasmine version is 2.3.2

// testStarter.js
var Jasmine = require('jasmine');
var Sails = require('sails/lib/app');
var TestConfig = require('../config/env/test');
var jasmine = new Jasmine();
var app = new Sails();
jasmine.loadConfigFile('test/support/jasmine.json');
jasmine.configureDefaultReporter({
    showColors: true
});

jasmine.onComplete(function(passed) {
  console.log('passed');
  app.lower(function() {
    console.log('lowered');
  });
});

app.lift(TestConfig, function(err, sails) {
  console.log('lifted');
  jasmine.execute();
});
// SomeSpec.js
  describe('Sample Test', function() {
    it('should do all the things', function() {
      expect(true).toEqual(true);
    });
  });

From the CLI:
node spec/testStarter.js

Output:

> [email protected] test /var/www/project
> node spec/testStarter.js

lifted
Started
.
// test/support/jasmine.json
{
    "spec_dir": "spec",
    "spec_files": [
        "**/*[sS]pec.js"
    ],
    "helpers": [
        "helpers/**/*.js"
    ]
}

It just sits there indefinitely.

Reporter not compatible with WebStorm

The reporter is not compatible with WebStorm, I got only ...FFF.....F.. etc... in the console, but no failure details. I checked, in nodejs it runs properly.

No specs found on node 0.11.14

Just tried Jasmine on Node 0.11.14 (unstable) and I get some errors. It also doesn't seem to find the specs.

$ jasmine
util.print: Use console.log instead
Startedutil.print: Use console.log instead

util.print: Use console.log instead

util.print: Use console.log instead
No specs foundutil.print: Use console.log instead

util.print: Use console.log instead
Finished in 0.001 secondsutil.print: Use console.log instead

deprecations are an easy fix but the fact it doesn't find the specs is kind of a non-starter. Not that I was expecting it to be all hunky dory on an unstable node release. Just thought I'd mention.

Can't run jasmine

After installing the last version (2.4.0) under npm -v => 3.3.6 and node -v => v5.0.0 I tried to run jasmine and got errors.

  1. npm install jasmine
  2. ./node/.bin/jasmine init
  3. ./node/.bin/jasmine

Error

./node_modules/.bin/jasmine
module.js:443
    throw err;
    ^

SyntaxError: /home/rianby64/Testing/demo/spec/support/jasmine.json: Unexpected token /
    at Object.parse (native)
    at Object.Module._extensions..json (module.js:440:27)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:311:12)
    at Module.require (module.js:366:17)
    at require (module.js:385:17)
    at Jasmine.loadConfigFile (/home/rianby64/Testing/demo/node_modules/jasmine/lib/jasmine.js:83:16)
    at runJasmine (/home/rianby64/Testing/demo/node_modules/jasmine/lib/command.js:92:11)
    at Command.run (/home/rianby64/Testing/demo/node_modules/jasmine/lib/command.js:49:7)
    at Object.<anonymous> (/home/rianby64/Testing/demo/node_modules/jasmine/bin/jasmine.js:11:9)

If run jasmine examples I got error too

./node_modules/.bin/jasmine examples
fs.js:856
  return binding.readdir(pathModule._makeLong(path));
                 ^

Error: ENOENT: no such file or directory, scandir '/home/rianby64/Testing/demo/node_modules/jasmine/node_modules/jasmine-core/lib/jasmine-core/example/node_example/spec/helpers/jasmine_examples'
    at Error (native)
    at Object.fs.readdirSync (fs.js:856:18)
    at copyFiles (/home/rianby64/Testing/demo/node_modules/jasmine/lib/command.js:186:24)
    at Object.installExamples [as action] (/home/rianby64/Testing/demo/node_modules/jasmine/lib/command.js:127:3)
    at Command.run (/home/rianby64/Testing/demo/node_modules/jasmine/lib/command.js:47:20)
    at Object.<anonymous> (/home/rianby64/Testing/demo/node_modules/jasmine/bin/jasmine.js:11:9)
    at Module._compile (module.js:425:26)
    at Object.Module._extensions..js (module.js:432:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:311:12)

Thanks in advance

Configurable loaders

I'd like to write my tests in ES6 as my source code is now ES6, currently as it stands I'd have to compile them into CJS to get them to run. It seems to me that jasmine-npm could support a configurable loader to remove the need to build the source.

Jasmine.prototype.loadSpecs = function() {
this.specFiles.forEach(function(file) {
require(file);
});
};

If loadSpecs returned a Promise you could allow async loading of files via loaders. Maybe a configuration like,

{
  "spec_dir": "spec",
  "spec_files": [
    "**/*[sS]pec.js"
  ],
  "helpers": [
    "helpers/**/*.js"
  ],
  "loader": "spec/es6-loader.js"
}

would allow people to load a file path and resolve a Promise once it's been executed so that Jasmine could go ahead and execute the tests.

I can give this a shot if you don't mind some extra dependencies in this project?

Improve error formatting

When an example fails, the output provided by jasmine-npm could be better.

We think that the format from jasmine-node is a good example. Specifically we like that:

  • The backtrace doesn't include jasmine internals
  • The color is red
  • The failures are numbered
  • The line number of the spec that failed is much easier to find
  • Number of assertions and skipped specs is included

jasmine-node:
jasmine-node

jasmine-npm:
jasmine-npm

cc @nertzy

done stops working if code is placed before it

I have a test case which tests a promise being called, if it does get called it tests the returned value is correct. However I've noticed that Jasmine works just fine as long as I call done inside the promise then function but if I do any checking of the returned value, any loops, or even just a single 1 line expect done stops working.

What I mean by stops working is done is clearly there still, its accessible inside the function and its perfectly callable, but calling it doesn't do anything. In fact if I do place expect calls before done they don't flag an error if wrong. Non-jasmine code works just fine but its like any jasmine code or jasmine functions just mysteriously stop working without any kind of error

Eventually jasmine times out with async timeout, once timed out, again, no errors are listed it just acs like done is never called.

However if I comment out all code except for done then everything works as expected.

2.2.1 seems to have introduced an issue that breaks output of istanbul

When running with version 2.2.0 istanbul coverage is displayed at the end of a jasmine run. Upgrading to 2.2.1 is apparently killing istanbul before it has completed. This results in no console output, but more importantly, when running on jenkins, the coverage output file are incomplete resulting in false positives(i.e. build passes even when a file doesn't have proper code coverage)

Exporting Jasmine functions

JS now has a module system so it seems like its a good time for Jasmine to start exporting its functions instead of having test modules access global state. The current export to global model can't be broken of course but this export model can be added for use by future tests. I guess the API can look something like this?

import {
   it,
   expect,
   describe,
   beforeEach
} from 'jasmine';

Which would be

const {it, expect, describe, beforeEach} = require('jasmine');

In the current CJS.

There are other exports like afterEach etc that also need to be exported but this gives an idea of how to consume the Jasmine package in a modular world.

jasmine examples fails with npm@3

As the transitive dependency structure for npm 3 is different than with npm 2, the cli jasmine examples command fails with:

Error: ENOENT: no such file or directory, scandir '.../node_modules/jasmine/node_modules/jasmine-core/lib/jasmine-core/example/node_example/spec/helpers/jasmine_examples'

Custom reporter?

HI. I try to looks around the docs but couldn't find a way to change the default reporter to something more verbose. Is there a sample project that uses jasmine-npm in this way?

Test suite overview

It would be great to have an option for jasmine to merely print the full sentence BDD descriptions, while not actually running the tests.

I was thinking something like jasmine --print-suites, which could output something like;

> jasmine --print-suites
object
  constructor
    succeeds
    fails when missing vital parameter
  method
    returns 1 when this
    returns 2 when that

.. where object, constructor and method are describes and the remaining are its. Alternatively, it could print the full sentences, like this;

> jasmine --print-suites
object constructor succeeds
object constructor fails when missing vital parameter
object method returns 1 when this
object method returns 2 when that

I realise this might require more functionality in core jasmine, but I thought I'd suggest it here first.

Test coverage

Has anyone managed to get testing coverage to work? I am using istanbul and I can't seem to get it to work.

JASMINE_CONFIG_PATH='.utilities/jasmine' node_modules/.bin/istanbul cover --report json ./node_modules/.bin/jasmine

I don't get any istanbul output

Command line options

Please make available command line options such as -V for version, -h for help, -c for configuration file.
There seems to be help available as jasmine help, but since "most" command line tools used the dashed version, perhaps jasmine could too.

There are several extensions that make it easy to configure these command line options, such as nomnom or yargs.

Also I would like to specify specDir and possible helpers directory via command line.

Remove dependency on jasmine.json file when running tests

I want to be able to run individual tests with jasmine and node but the runner requires jasmine.json to be created. Can this dependency be optional and favor cli arguments for specifying a path or regex to determine which tests to 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.