I'm having some bother getting Chutzpah to work with requireJs/jasmine 2.0. This method worked for version 1.3 but now for jasmine version 2.0 chutzpah has stopped picking up the tests. I upgraded chutzpah to 3.1.1 for the jasmine 2.0 support as well. I did have to make a small change to load jasmine from requireJs to make it work but I figured this shouldn't affect chutzpah as it was just loading the html.
Here's the mand I run for chutzpah.
chutzpah.console.exe path/to/SpecRunner.html
The console now fails to pick up tests
=== 0 total, 0 failed, took 0.25 seconds ===
But when I run the actual html file it finds the tests
Any help would be greatly appreciated
Instead of the HTML route I've been trying just the chutzpah built in configuration
{
"Framework": "jasmine",
"TestHarnessReferenceMode": "AMD",
"TestHarnessLocationMode": "SettingsFileAdjacent",
"Tests": [
{"Path" : "Specs/example.spec.js"},
],
"References" : [
{"Path" : "../../../Scripts/lib/require/require.js" },
{"Path" : "../../../Scripts/app/app.js" }
]
}
This runs however I'm getting an error
Error: Error: Script error for: specs/example.spec
Error: Timeout occured when executing test file
While Running:C:\path\to\specs\example.spec.js
System.AggregateException: One or more errors occurred.
---> System.NullReferenceException: Object reference not set to an instance of an object.
at Chutzpah.FileProbe.<FindScriptFiles>d__1a.MoveNext() in c:\Dev\chutzpah\Chutzpah\FileProbe.cs:line 159
The path here is definitely correct as i've copied and pasted it into an explorer window just to make sure.
The test is a simple piled coffeescript file which looks like this
(function() {
define([], function() {
return describe('==== example test ====', function() {
return describe('the test should', function() {
return it('showcase toBe', function() {
return expect(true).toBe(true);
});
});
});
});
}).call(this);
And I'm certain that this works as it's passing in my browser html based equivalent.
This was my final configuration that works with html. I couldn't get it to work with just the config discovering the tests. Hopefully this will be resolved when item 214 is resolved as in the below answer
{
"Framework": "jasmine",
"RootReferencePathMode": "SettingsFileDirectory",
"TestHarnessReferenceMode": "AMD",
"TestHarnessLocationMode": "SettingsFileAdjacent",
"Tests": [
{ "Path" : "specrunner.html" }
],
"References" : [
{"Path" : "../../../Scripts/lib/require/require.js" },
{"Path" : "../../../Scripts/app/app.js" }
]
}
I'm having some bother getting Chutzpah to work with requireJs/jasmine 2.0. This method worked for version 1.3 but now for jasmine version 2.0 chutzpah has stopped picking up the tests. I upgraded chutzpah to 3.1.1 for the jasmine 2.0 support as well. I did have to make a small change to load jasmine from requireJs to make it work but I figured this shouldn't affect chutzpah as it was just loading the html.
Here's the mand I run for chutzpah.
chutzpah.console.exe path/to/SpecRunner.html
The console now fails to pick up tests
=== 0 total, 0 failed, took 0.25 seconds ===
But when I run the actual html file it finds the tests
Any help would be greatly appreciated
Instead of the HTML route I've been trying just the chutzpah built in configuration
{
"Framework": "jasmine",
"TestHarnessReferenceMode": "AMD",
"TestHarnessLocationMode": "SettingsFileAdjacent",
"Tests": [
{"Path" : "Specs/example.spec.js"},
],
"References" : [
{"Path" : "../../../Scripts/lib/require/require.js" },
{"Path" : "../../../Scripts/app/app.js" }
]
}
This runs however I'm getting an error
Error: Error: Script error for: specs/example.spec
Error: Timeout occured when executing test file
While Running:C:\path\to\specs\example.spec.js
System.AggregateException: One or more errors occurred.
---> System.NullReferenceException: Object reference not set to an instance of an object.
at Chutzpah.FileProbe.<FindScriptFiles>d__1a.MoveNext() in c:\Dev\chutzpah\Chutzpah\FileProbe.cs:line 159
The path here is definitely correct as i've copied and pasted it into an explorer window just to make sure.
The test is a simple piled coffeescript file which looks like this
(function() {
define([], function() {
return describe('==== example test ====', function() {
return describe('the test should', function() {
return it('showcase toBe', function() {
return expect(true).toBe(true);
});
});
});
});
}).call(this);
And I'm certain that this works as it's passing in my browser html based equivalent.
This was my final configuration that works with html. I couldn't get it to work with just the config discovering the tests. Hopefully this will be resolved when item 214 is resolved as in the below answer
{
"Framework": "jasmine",
"RootReferencePathMode": "SettingsFileDirectory",
"TestHarnessReferenceMode": "AMD",
"TestHarnessLocationMode": "SettingsFileAdjacent",
"Tests": [
{ "Path" : "specrunner.html" }
],
"References" : [
{"Path" : "../../../Scripts/lib/require/require.js" },
{"Path" : "../../../Scripts/app/app.js" }
]
}
Share
Improve this question
edited Mar 3, 2014 at 14:51
Neil
asked Feb 28, 2014 at 9:45
NeilNeil
5,2398 gold badges53 silver badges88 bronze badges
4
- The best way for me to help is if you could attach a zip containg what you are trying that is not working. I would like to see both the .html file that won't run and the code you did to try to get it working with just Chutzpah configuration. Please attach this zip to the workitem you created here: chutzpah.codeplex./workitem/215 – Matthew Manela Commented Feb 28, 2014 at 16:02
- Thanks, I'll try and put together a stripped down example at the beginning of next week as all of it is deeply nested in my current project – Neil Commented Feb 28, 2014 at 20:30
- I understand. I appreciate the effort since its the best way for me to debug and diagnose your issue. – Matthew Manela Commented Feb 28, 2014 at 21:51
- Hi Matthew, I've put up a stripped down version here github./bapti/chutzpah.problems . Thanks so much for taking the time to look at it. I had to do a workaround to get require to work with jasmine in the browser so maybe that's the problem – Neil Commented Mar 1, 2014 at 9:11
2 Answers
Reset to default 6I looked into your code and here is what I found
Running HTML
This works fine if you make a couple small changes. 1. Your tests setting in the chutzpah.json file has a trailing ma. This exposes a bug where the deserializer returns this as a null entry and chutzpah isnt handling it. I will fix this issue but you can just delete the extra ma. 2. Once I deleted that mand I saw that your chutzpah.json file has a tests setting that is listing just the .js file. But when running the html file then that is your test file. So your chutzpah.json is filter it out. If you update the tests setting to point to the html file this works.
Once I made those changes the test ran successfully.
Running Chutzpah.json
Looking into this the way you load the example.spec in SpecRunner you reference the .js extension in your require call. This tells require.js to ignore the baseurl and look at the file relative to current location. When you have chutzpah generate the test harness it generates a require call without extension. This means that file needs to be able to be loaded given the current baseurl setting.
Now there is a bug in chutzpah where it doesn't understand baseurls. See https://chutzpah.codeplex./workitem/214. The planned solution is to allow you to tell chutzpah in the chutzpah.json file what your baseurl is. Without that it is still possible to get this to work but you would need to tell chutzpah to place its generated .html file where your baseurl would point.
Let me know if that helps.
I had a similar problem to yours, where none of the tests were being picked up by chutzpah. What I figured out was that because I was using require.js, I had removed all script reference to the jasmine.js from my specRunner.html. As soon as I put back
<!--<script src="jasmine.js"></script>-->