Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

require('jasmine-expect') API can only register watchers once #36

Closed
michael42 opened this issue Jun 22, 2015 · 9 comments
Closed

require('jasmine-expect') API can only register watchers once #36

michael42 opened this issue Jun 22, 2015 · 9 comments
Milestone

Comments

@michael42
Copy link

We're trying to use jasmine-expect to test a node.js application using gulp-jasmine. The current require('jasmine-expect') API isn't sufficient for that use case, since it only registers the matchers once. When the watcher runs the tests a second time, the require() result is already cached and the matchers aren't registered.

A function that registers the matchers when called would solve this issue. Not sure how to integrate it without breaking backwards compatibility or registering the matchers multiple times, though.

@JamieMason
Copy link
Owner

Thanks for this @michael42.

Integration with Node is currently the most awkward aspect of this project. I agree that some kind of method is needed such as require('jasmine-expect').register() (or similar) to get around this problem.

@JamieMason JamieMason modified the milestone: 2.0.0 Nov 18, 2015
@JamieMason
Copy link
Owner

/cc to users who've opened issues on this project before, a question for you. How do you tend to include Jasmine Matchers on a Node.js project? I'm trying to think of what might be the best way to do it — and I'm pretty sure it will require an API change.

Thanks.

@Hemins @JessicaSachs @MathRobin @PaulTondeur @RALifeCoach @alecxe @anisylen @atruskie @cryptoquick @endorama @jasonjohnson115 @jelinson @jhuesos @jrencz @message @michael42 @mohit-excelindia @mrozbarry @mull @pavelmigolinets @rkawala @tandrewnichols @xuxiankun

@mull
Copy link

mull commented Feb 3, 2016

We're only including it once in our of our jest specs by simply importing it. Sorry I can't be of more help :/

@ghost
Copy link

ghost commented Feb 3, 2016

Same as @mull. Include it once within our Jasmine specs and let it rip.

@JamieMason
Copy link
Owner

Thanks @mull @anisylen. I had thought that just including require('jasmine-expect') at the very start of your spec was all that was needed to include this in node, but I could see how it could be possible that the behaviour @michael42 describes could happen.

Could it be that this has been fixed since it was opened? @michael42 can you confirm?

Thanks.

@PaulTondeur
Copy link

I can confirm the include as @mull and @anisylen are describing.

@mrozbarry
Copy link

We are including it in a helper file, and our setup looks like this:

spec/support/jasmine.json:

{
  "spec_dir": "spec",
  "spec_files": [
    "**/*.spec.js"
  ],
  "helpers": [
    "helpers/*.js"
  ]
}

spec/helpers/extra.js:

// ...
require('jasmine-expect');
// ...

@JamieMason
Copy link
Owner

Thanks all, ok I think this is working then and can be closed.

@michaeljota
Copy link

Hi! You should post this on the readme.md. This is like a how-to-use with gulp-jasmine.

Thanks! 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants