Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

m.expect not recognized as jasmine expectation (SPEC HAS NO EXPECTATIONS)

See original GitHub issue

In my Angular7 I made very simple test:

it('should see expectations', marbles(m => {
  const source: Observable<Message> ='^a--b--c');

But I get in console error:

ERROR: 'Spec 'MyService should see expectations' has no expectations.

And my test is prefixed with SPEC HAS NO EXPECTATIONS.

Adding expect(true).toBe(true); helps but I guess jasmine should recognize m.expect as expectation, right?

I posted also stackoverflow question: but I feel here I have better chance to understand the problem.

Also I looked on tests in this repository and there is no such message and I couldn’t find any settings related to this problem. Thank you for help.


"rxjs-marbles": "4.3.2"
"jasmine-core": "3.2.1"

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:16 (7 by maintainers)

github_iconTop GitHub Comments

Insulincecommented, Jan 14, 2019

FYI, to hopefully save some time for someone else in the future, the problem was resolved for me by following @cartant’s suggestion of importing rxjs-marbles/jasmine (instead of just rxjs-marbles) fixed the problem for me.

So: import {marbles} from "rxjs-marbles"; does not fix the expectation issue, while: import {marbles} from "rxjs-marbles/jasmine"; does.

This is especially annoying because my IDE likes to import the incorrect version by default, so remain vigilant about this!

Adding relevant packages from pacakge.json for the record:

"npm": "^6.4.0", 
"rxjs": "^6.3.3",
"@types/jasmine": "^2.8.8",
"istanbul-instrumenter-loader": "^3.0.1",
"jasmine-core": "^3.3.0",
"jasmine-spec-reporter": "^4.2.1",
"karma": "^3.0.0",
"karma-chrome-launcher": "~2.2.0",
"karma-coverage": "^1.1.2",
"karma-coverage-istanbul-reporter": "^2.0.1",
"karma-jasmine": "^1.1.2",
"karma-jasmine-html-reporter": "^1.4.0",
"karma-spec-reporter": "0.0.32",
"rxjs-marbles": "^5.0.0",
"tslint": "~5.11.0",
"typescript": "3.1.3"
cartantcommented, Nov 11, 2018

This should be fixed in 4.3.4. I messed up the overriding of the default configuration. Importing from rxjs-marbles/jasmine should now see Jasmine’s expect used in the internal assertions. If the latest version doesn’t solve the problem, there’s nothing that I can do about it and you’ll have to report the error against the package you’ve mentioned above - as the latest version definitely calls Jasmine’s expect function.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Spec has no expectations Angular 7 - Stack Overflow
When I execute test cases , I see a message SPEC HAS NO EXPECTATIONS for both test cases . I am wondering why...
Read more >
SPEC HAS NO EXPECTATIONS warnings in jasmine tests
There are 23 tests which Jasmine marks with the warning "SPEC HAS NO EXPECTATIONS": permissions service checkAll with extended permissions
Read more >
Frequently Asked Questions - Jasmine Documentation
All it ensures is that each spec has at least one expectation, not that the spec will actually fail for the right reason...
Read more >
An Introduction to Jasmine Unit Testing - Medium
Expectations compose the spec and are used along with matcher functions (via chaining) to define what the developer expect from a specific unit...
Read more >
Adding specs to your Jasmine test - Packt Subscription
How to do it… · The spec is prefixed with SPEC HAS NO EXPECTATION. · The spec passes even if we do not...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found