Open bluesliverx opened 8 years ago
Thanks for submitting this issue - I'm sorry about any problems with where
that are slowing you down.
I've not used phantom or karma before ~ the npm where.js and testem suites work and I've updated my version of jasmine-core ~ so I'd start looking at a phantom config or dependency.
That the error starts in this.expectationResultFactory(data)
is at least a good sign that jasmine 2 is is being executed.
That it's complaining about undefined
not being a constructor sounds like karma-jasmine is doing its own wrapping or intercepting - and probably that a this
reference is pointing to global rather than a jasmine environment instance.
Can you provide a link to a public repo where this failure is happening? Maybe it's just a test setup. One can hope...
--DKaye
Thanks for the quick response! In trying to reproduce this in a limited way, I've found something important: this only fails with the expectationResultFactory message when there is passing test. If all tests fail, it prints out the error messages correctly.
I've reproduced in this in a (relatively) small project here: https://github.com/bluesliverx/karma-wherejs-test
Just grab it, run npm install
, bower install
, and then gulp test:auto
. Then take a look at src/app/main/where.spec.js
. There are three tests in here:
1) This fails with the error I pasted above. 2) Identical to the first one except the third test case is commented out, this fails with the correct error messages since both remaining where clauses fail 3) I understood from the docs that I shouldn't need to pass jasmine in with the context if it is globally available, which it is in this case. However, this test shows that it can't find jasmine in the jasmine-strategy code.
The main moving pieces here (apologies if this is too detailed, I just want to help you out to know where to look) are gulp/unit-tests.js
and karma.conf.js
. Let me know if I can do anything else to help.
OK, let's start small...
{strategy: 'jasmine', jasmine: jasmine}
to { jasmine: jasmine, expect: expect }
log: 1
property to the context argument and see how noisy that is, too...Here's the results. Log: 1 didn't seem to add anything honestly.
WARN [watcher]: Pattern "C:/Users/saville/Documents/Projects/opensource/karma-wherejs/src/**/*.mock.js" does not match any file.
INFO [karma]: Karma v0.12.37 server started at http://localhost:9876/
INFO [launcher]: Starting browser PhantomJS2
INFO [PhantomJS 2.1.1 (Windows 7 0.0.0)]: Connected on socket hwSYAaTUA_KPZXUa1rC8 with id 71917686
LOG: '
[a | b | c] :
[2 | 2 | 3] (Expected 4 to be 3. )
'
LOG: '
[a | b | c] :
[5 | 3 | 7] (Expected 8 to be 7. )
'
PhantomJS 2.1.1 (Windows 7 0.0.0) wherejs fails with undefined is not a constructor FAILED
TypeError: undefined is not a constructor (evaluating 'this.expectationResultFactory(data)') in C:/Users/saville/Documents/Projects/opensource/karma-wherejs/node_modules/jasmine-core/lib/jasmine-core/jasmine.js (line 324)
addExpectationResult@C:/Users/saville/Documents/Projects/opensource/karma-wherejs/node_modules/where.js/strategy/jasmine-strategy.js:61:34
anonymous
testJasmine@C:/Users/saville/Documents/Projects/opensource/karma-wherejs/node_modules/where.js/strategy/jasmine-strategy.js:67:19
where@C:/Users/saville/Documents/Projects/opensource/karma-wherejs/node_modules/where.js/where.js:182:20
C:/Users/saville/Documents/Projects/opensource/karma-wherejs/src/app/main/where.spec.js:9:12
PhantomJS 2.1.1 (Windows 7 0.0.0) wherejs should not throw when intercept specified FAILED
Expected function not to throw, but it threw TypeError: undefined is not a constructor (evaluating 'this.expectationResultFactory(data)').
C:/Users/saville/Documents/Projects/opensource/karma-wherejs/src/app/main/where.spec.js:35:21
I added log: 1 to each of them.
@bluesliverx sorry for the delayed response ~ I think actually that's good news as it means the logging intercept actually works, expect
actually works... ~ at this point, without downloading phantom and karma, et al, I can only guess that there's something wrong with the finally block in the jasmine-strategy file, particularly at https://github.com/dfkaye/where.js/blob/master/strategy/jasmine-strategy.js#L69-L78
Try adding a console
statement inside each where
test, and see if jasmine.Spec.prototype.addExpectationResult
is changing or not ~ during the test it should look like this block at https://github.com/dfkaye/where.js/blob/master/strategy/jasmine-strategy.js#L43-L63
Then add a console
statement outside (before or after) each where
test to see if it's the jasmine version at https://github.com/jasmine/jasmine/blob/master/src/core/Spec.js#L31-L42
LMK what you find out...
I'm encountering this error when trying to use the jasmine strategy to report errors.
Would it be possible to create a jasmine spec reporter to do this same thing in a more jasmine accepted way? If you can't access what you need from a reporter, I understand. I've tried poking around in the code, but I'm not seeing where the breakdown is. Perhaps in the configuration of jasmine that karma-jasmine does? I've tried with every major jasmine-core version from 2.0.x (failed for another reason with karma-jasmine) to 2.4.x. 2.1.x+ failed with this error message.