Jasmine is reporting a no specs found message after adding a 14th spec to it (doesn't matter if it is a copy of a working spec). If I use a self made reporter it shows that it went through all the specs no problem but that it reports a no specs found as end result.
added a console log to show what I mean
Started
[#quickSort]
Results Top Level Tests
------- ---------------
.Passed should sort small array
.Passed should hallo small array
.Passed should sort array with identical values
.Passed should do nothing with empty array
.Passed shouldn't sort a string
.Passed should do nothing with array with single field
Group "#quickSort" was finished
[#signature]
Results Top Level Tests
------- ---------------
[#signature Write signatureformat Remove]
Results Top Level Tests
------- ---------------
.Passed Compact 1/2; Remove additional x/y members
.Passed Compact 2/2; Also remove additional x/y members in sequential paths
Group "Write signatureformat Remove" was finished
[#signature Write signatureformat Reposition]
Results Top Level Tests
------- ---------------
.Passed Reposition 1/2; Reposition top-left to 0,0 for more compact output
.Passed Reposition 2/2; Reposition top-left to 0,0 for more compact output
Group "Write signatureformat Reposition" was finished
[#signature Write signatureformat Downscale]
Results Top Level Tests
------- ---------------
.Passed Downscale 1/2; Downscale when needed with minimal resolution loss, so it will never get to large (-2000..2000)
.Passed Downscale 2/2; Downscale when needed with minimal resolution loss, so it will never get to large (-2000..2000)
Group "Write signatureformat Downscale" was finished
.Passed Write signatureformat - Complex export
.Passed Write signatureformat - Rotate 180 degrees
Group "#signature" was finished
Started
No specs found
Finished in 0.002 seconds
Also here is the source of the spec_runner
//var exit = require('exit');
var Jasmine = require('jasmine'),
reporters = require('jasmine-reporters');
var junitReporter = new reporters.NUnitXmlReporter({
savePath: __dirname,
consolidateAll: true
});
var myReporter = {
jasmineStarted: function (suiteInfo) {
},
suiteStarted: function (result) {
console.log('[' + result.fullName + ']');
console.log('');
console.log('Results Top Level Tests');
console.log('------- ---------------');
},
specStarted: function (result) {
},
specDone: function (result) {
var line = result.status.substr(0, 1).toUpperCase() + result.status.substr(1);
if (line === "Failed") line = "+" + line;
while (line.length < 22) line += " ";
console.log(line + result.description);
},
suiteDone: function (result) {
console.log('');
console.log('Group "' + result.description + '" was ' + result.status);
for (var i = 0; i < result.failedExpectations.length; i++) {
console.log('AfterAll ' + result.failedExpectations[i].message);
console.log(result.failedExpectations[i].stack);
}
console.log('');
console.log('');
// werkt gewoon niet???? [rv]
//if (result.status !== "passed") exit(1)
},
jasmineDone: function () {
}
};
var jasmine = new Jasmine();
jasmine.loadConfigFile("spec/support/jasmine.json");
jasmine.addReporter(myReporter);
jasmine.execute();
Jasmine is reporting a no specs found message after adding a 14th spec to it (doesn't matter if it is a copy of a working spec). If I use a self made reporter it shows that it went through all the specs no problem but that it reports a no specs found as end result.
added a console log to show what I mean
Started
[#quickSort]
Results Top Level Tests
------- ---------------
.Passed should sort small array
.Passed should hallo small array
.Passed should sort array with identical values
.Passed should do nothing with empty array
.Passed shouldn't sort a string
.Passed should do nothing with array with single field
Group "#quickSort" was finished
[#signature]
Results Top Level Tests
------- ---------------
[#signature Write signatureformat Remove]
Results Top Level Tests
------- ---------------
.Passed Compact 1/2; Remove additional x/y members
.Passed Compact 2/2; Also remove additional x/y members in sequential paths
Group "Write signatureformat Remove" was finished
[#signature Write signatureformat Reposition]
Results Top Level Tests
------- ---------------
.Passed Reposition 1/2; Reposition top-left to 0,0 for more compact output
.Passed Reposition 2/2; Reposition top-left to 0,0 for more compact output
Group "Write signatureformat Reposition" was finished
[#signature Write signatureformat Downscale]
Results Top Level Tests
------- ---------------
.Passed Downscale 1/2; Downscale when needed with minimal resolution loss, so it will never get to large (-2000..2000)
.Passed Downscale 2/2; Downscale when needed with minimal resolution loss, so it will never get to large (-2000..2000)
Group "Write signatureformat Downscale" was finished
.Passed Write signatureformat - Complex export
.Passed Write signatureformat - Rotate 180 degrees
Group "#signature" was finished
Started
No specs found
Finished in 0.002 seconds
Also here is the source of the spec_runner
//var exit = require('exit');
var Jasmine = require('jasmine'),
reporters = require('jasmine-reporters');
var junitReporter = new reporters.NUnitXmlReporter({
savePath: __dirname,
consolidateAll: true
});
var myReporter = {
jasmineStarted: function (suiteInfo) {
},
suiteStarted: function (result) {
console.log('[' + result.fullName + ']');
console.log('');
console.log('Results Top Level Tests');
console.log('------- ---------------');
},
specStarted: function (result) {
},
specDone: function (result) {
var line = result.status.substr(0, 1).toUpperCase() + result.status.substr(1);
if (line === "Failed") line = "+" + line;
while (line.length < 22) line += " ";
console.log(line + result.description);
},
suiteDone: function (result) {
console.log('');
console.log('Group "' + result.description + '" was ' + result.status);
for (var i = 0; i < result.failedExpectations.length; i++) {
console.log('AfterAll ' + result.failedExpectations[i].message);
console.log(result.failedExpectations[i].stack);
}
console.log('');
console.log('');
// werkt gewoon niet???? [rv]
//if (result.status !== "passed") exit(1)
},
jasmineDone: function () {
}
};
var jasmine = new Jasmine();
jasmine.loadConfigFile("spec/support/jasmine.json");
jasmine.addReporter(myReporter);
jasmine.execute();
Share
Improve this question
edited May 1, 2017 at 12:13
Strike08
asked May 1, 2017 at 12:08
Strike08Strike08
2871 gold badge2 silver badges17 bronze badges
1
- Provide more information on how you run your tests and provide some config/code files, otherwise it won't be possible to help you. Also try to look for other issues like this one stackoverflow.com/questions/36208555/… and others. – sepulchered Commented May 1, 2017 at 12:11
4 Answers
Reset to default 7Fixed it. Problem was in package.json. I used "scripts":{"test": "jasmine spec/spec_runner.js"}
This caused jasmine to run 2 times. Fixed it by using
"scripts":{"test": "node spec/spec_runner.js"}
Make sure that your application compile successfully prior to try running tests.
Example
I had this error today, for me it was that I had a syntax-level error in my .ts
files, so they couldn't really compile.
In above situation, I think, the tests should not start (and instead show compile error).
But for whatever reason, somehow the tests start, and Jasmine
fails with "No specs found
" log.
Similar to the last post but I'm using jasmine-ts:
npx jasmine init
This will create the following file if it doesn't already exist:
spec/support/jasmine.json
The initial contents didn't fit the bill for me so I had to go with the following, paying particular attention to the spec_dir (relative to your package.json where you run the tests command from):
{
"spec_dir": "./",
"spec_files": [
"**/*.spec.ts"
],
"random": false,
"stopSpecOnExpectationFailure": false,
"reporters": [
{
"name": "jasmine-spec-reporter#SpecReporter",
"options": {
"suite": {
"displayNumber": true
},
"spec": {
"displayStacktrace": "pretty",
"displayDuration": true
}
}
},
{
"name": "jasmine-reporters#JUnitXmlReporter",
"options": {
"savePath": ".",
"consolidateAll": true
}
}
]
}
When I ran into this issue I used this command in the appropriate folder:
$jasmine init
It's simple but it worked for me.