Coder Social home page Coder Social logo

jasmine-promises's People

Contributors

matthewjh avatar

Stargazers

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

Watchers

 avatar  avatar  avatar

jasmine-promises's Issues

How to test a fail condition? (should enter catch() not then())

There is one cases your library do not really address or I couldn't find the way to address it with it:

it('my test', function() {
  var promise = sut.methodUnderTest()
      .catch(function(err) {
        expect(err.message).toBe('expected error message');
      });
  return promise;
});

if promiseis a fullfilled promise, the test pass.

This is very common: I want to check my function is returning an error (in the form of a Promise.reject() on some condition and also check error message being of some type.

Using your library it doesn't matter what you check, if your method INCORRECTLY return a fullfilled promise value the test pass.

Is it the only way to implement then() in the test and call fail() with a reason or is there a better way in the library?

'this' is undefined inside beforeEach/afterEach/it/fit

I'm trying to make use of jasmine-promises in a promise-heavy codebase. Our current practice is to expect that the promise is resolved (or rejected as appropriate) inside a promise.finally handler (we're using Q.js promises). It can be hard to track down promise failures when this occurs. jasmine-promises looks like it will simplify the tests and ensure that errors are reported.

We have some complicated fixtures that need extensive set-up. We attach data and mock objects/spies to the fixture by using the object that jasmine passes to the beforeEach function, then subsequently to the it function, as the this pointer.

After enabling jasmine-promises, all existing tests that make use of this are failing with a TypeError: Cannot set property 'xxx' of undefined error.

This is a blocker preventing us from using jasmine-promises at all.

Minimum reproducible case:

describe('fixture', function() {
    beforeEach(function() {
        this.field = 'value';
    });

    it('should set `this` correctly', function() {
        expect(this.field).toEqual('value');
    });
});

Without loading jasmine-promises the test passes. After loading jasmine-promises, you get:

Chrome 48.0.2564 (Windows 7 0.0.0) fixture should set `this` correctly FAILED
        TypeError: Cannot set property 'field' of undefined
            at [...]/jasmine-promises.unit.js:6:24
            at Object.arguments.(anonymous function) ([...]/node_modules/jasmine-promises/
dist/jasmine-promises.js:39:23)
            at Object.arguments.(anonymous function) ([...]/node_modules/jasmine-promises/
dist/jasmine-promises.js:51:11)
        TypeError: Cannot read property 'field' of undefined
            at [...]/jasmine-promises.unit.js:10:24
            at Object.arguments.(anonymous function) ([...]/node_modules/jasmine-promises/
dist/jasmine-promises.js:39:23)

The behaviour of the this pointer is documented at Jasmine 2.2 introduction.js - The this keyword

Error running jasmine-promises

I'm getting an error when I try and use jasmine-promises.
The error is:
Error: Cannot find module './patch' from '[PATH TO NODE_MODULES]/node_modules/jasmine-promises/dist'
I see the call to require patch.js in the code, but no such file exists in dist/
I'm sure it's something simple I'm doing wrong.
Any help would be much appreciated.

Excessively long stack traces

Hi great work on this module!

I get strange stack traces when a test fails. Here's an example

Error: index must be defined in /myProject/src/entities/Face.js (line 9)
/myProject/src/entities/Face.js:9:1841
/myProject/tests/entities/FaceSpec.js:21:82
/myProject/node_modules/jasmine-promises/dist/jasmine-promises.js:35:34
/myProject/node_modules/jasmine-promises/dist/jasmine-promises.js:47:15
/myProject/node_modules/jasmine-promises/dist/jasmine-promises.js:47:15
/myProject/node_modules/jasmine-promises/dist/jasmine-promises.js:47:15
/myProject/node_modules/jasmine-promises/dist/jasmine-promises.js:47:15
/myProject/node_modules/jasmine-promises/dist/jasmine-promises.js:47:15
/myProject/node_modules/jasmine-promises/dist/jasmine-promises.js:47:15
/myProject/node_modules/jasmine-promises/dist/jasmine-promises.js:47:15
/myProject/node_modules/jasmine-promises/dist/jasmine-promises.js:47:15
/myProject/node_modules/jasmine-promises/dist/jasmine-promises.js:47:15
/myProject/node_modules/jasmine-promises/dist/jasmine-promises.js:47:15
   ..... this continues for another 40 lines ....

Any idea how to limit this?

Doesn't work correctly under Node.js

Unfortunately it looks like this library doesn't function when run under Node.js.

I suspect this has something to do with the way in which you're attempting to patch the global object - specifically the global.jasmineRequire object.

Workaround

Currently I'm working around the issue by "mocking" the jasmineRequire.interface function with a no-op. This seems to address the problem, however it would be good to include a check in the library itself instead.

global.jasmineRequire = {
    interface: function() {}
};

require('jasmine-promises');

Error Message

TypeError: Cannot read property 'interface' of undefined
    at patchInterfaceFn (D:\...\node_modules\jasmine-promises\dist\jasmine-promises.js:68:21)
    at apply (D:\...\node_modules\jasmine-promises\dist\jasmine-promises.js:80:3)
    at Object.<anonymous> (D:\...\node_modules\jasmine-promises\dist\jasmine-promises.js:12:18)
    at Object.__dirname.1../patch (D:\...\node_modules\jasmine-promises\dist\jasmine-promises.js:14:4)
    at s ((D:\...\node_modules\jasmine-promises\dist\jasmine-promises.js:1:316)
    at e ((D:\...\node_modules\jasmine-promises\dist\jasmine-promises.js:1:487)
    at Object.<anonymous> (D:\...\node_modules\jasmine-promises\dist\jasmine-promises.js:1:505)
    at Module._compile (module.js:425:26)
    at Object.Module._extensions..js (module.js:432:10)
    at Module.load (module.js:356:32)

jasmineRequire is undefined: Incompatibility with Jasmine 2.x under Protractor?

When running against Jasmine 2.3.2, at call-site of require('jasmine-promises').

Selenium standalone server started at http://10.32.64.38:59425/wd/hub
TypeError: Cannot read property 'interface' of undefined
    at patchInterfaceFn (F:\build\node_modules\jasmine-promises\dist\jasmine-promises.js:71:21)
    at Object.apply (F:\build\node_modules\jasmine-promises\dist\jasmine-promises.js:83:3)
    at Object.<anonymous> (F:\build\node_modules\jasmine-promises\dist\jasmine-promises.js:15:7)
    at Object../patch (F:\build\node_modules\jasmine-promises\dist\jasmine-promises.js:17:4)
    at s (F:\build\node_modules\jasmine-promises\dist\jasmine-promises.js:1:316)
    at e (F:\build\node_modules\jasmine-promises\dist\jasmine-promises.js:1:487)
    at Object.<anonymous> (F:\build\node_modules\jasmine-promises\dist\jasmine-promises.js:1:505)

Versions:

$ npm ls jasmine jasmine-promises protractor
[email protected] F:\build
├── [email protected]
└── [email protected]
└─┬ [email protected]
  └── [email protected]

jasmine-promises error stack trace

Version: v0.4.2

When promise fails i get stack trace like which is really anoint because you always have to scroll up a lot to see where did it failed

webpack:///src/features/tt-select/tt-select_test.js:68:53 <- src/features/tt-select/tt-select_test.js:112:54
node_modules/jasmine-promises/dist/jasmine-promises.js:83:36
node_modules/jasmine-promises/dist/jasmine-promises.js:95:17
node_modules/jasmine-promises/dist/jasmine-promises.js:95:17
node_modules/jasmine-promises/dist/jasmine-promises.js:95:17
node_modules/jasmine-promises/dist/jasmine-promises.js:95:17
node_modules/jasmine-promises/dist/jasmine-promises.js:95:17
node_modules/jasmine-promises/dist/jasmine-promises.js:95:17
node_modules/jasmine-promises/dist/jasmine-promises.js:95:17
node_modules/jasmine-promises/dist/jasmine-promises.js:95:17
node_modules/jasmine-promises/dist/jasmine-promises.js:95:17
node_modules/jasmine-promises/dist/jasmine-promises.js:95:17
node_modules/jasmine-promises/dist/jasmine-promises.js:95:17
node_modules/jasmine-promises/dist/jasmine-promises.js:95:17
node_modules/jasmine-promises/dist/jasmine-promises.js:95:17
node_modules/jasmine-promises/dist/jasmine-promises.js:95:17
node_modules/jasmine-promises/dist/jasmine-promises.js:95:17
node_modules/jasmine-promises/dist/jasmine-promises.js:95:17
node_modules/jasmine-promises/dist/jasmine-promises.js:95:17
node_modules/jasmine-promises/dist/jasmine-promises.js:95:17
node_modules/jasmine-promises/dist/jasmine-promises.js:95:17
node_modules/jasmine-promises/dist/jasmine-promises.js:95:17
...

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.