npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

karma-jasmine1-shim

v1.0.1

Published

Shim for jasmine 1.3 tests to run on jasmine 2.

Downloads

2

Readme

  • About This is a karma plugin (framework) which extends jasmine version 2 to allow some of the old tests to pass. It prints deprecation warnings at the end of tests run.

There are breaking changes, though, which cannot be shimed:

  • Clock needs to be removed after usage with =jasmine.clock.uninstall()=.
  • Object equality assertion is stricter in Jasmine 2 regarding keys with =undefined= value. This means that =toEqual()=, =toHaveBeenCalledWith()=, similar matchers will fail in cases like =expect({}).toEqual({ a: undefined });=.

See how to migrate here: http://jasmine.github.io/2.3/upgrading.html

  • Usage Add =jasmine1-shim= to =karma.conf.js=

#+begin_src javascript module.exports = function(config) { config.set({ // ...

// Optional as "plugins" is populated automatically.
plugins: [
  'karma-jasmine',
  'karma-jasmine1-shim'
],
frameworks: ['jasmine', 'jasmine1-shim'],

// ...

}); }; #+end_src

  • Tips on migration Start by adding shim to your frameworks list of Karma’s configuration. Your tests should pass in most of the cases. You will see a list of messages indicating old methods and properties being used that are no longer available in new Jasmine version.

You could fix them by hand if you have just a few tests. Otherwise, =sed= will help. Following are shell commands that will automate migration. Run them in appropriate directory, like =test/spec/=.

First, the easy targets:

#+BEGIN_SRC sh find . -name '*.js'
| xargs sed -i.bak
-e 's/.mostRecentCall/.calls.mostRecent()/g'
-e 's/.mostRecentCall/.calls.mostRecent()/g'
-e 's/.callCount/.calls.count()/g'
-e 's/.calls.length/.calls.count()/g'
-e 's/.andCallThrough()/.and.callThrough()/g'
-e 's/.argsForCall/.calls.allArgs()/g'
-e 's/.calls[0]/.calls.first()/g'
-e 's/.andCallFake(/.and.callFake(/g'
-e 's/.andReturn(/.and.returnValue(/g' #+END_SRC

Your tests should still pass. At least failing tests count should not increase.

Above will replace the most obvious methods and properties of spies. Next on the list, are =.reset()= and =.calls= property. It would be presumptuous to treat every occurrence as indication of spy, thus it’s recommended to run these individually and then carefully inspect diffs.

#+BEGIN_EXAMPLE $ find . -name '.js' | xargs sed -i.bak -e 's/.reset()/.calls.reset()/g' $ find . -name '.js' | xargs sed -i.bak -e 's/.calls([^.])/.calls.all()\1/g' #+END_EXAMPLE

And finally, you should migrate your custom matchers. For how to, see http://jasmine.github.io/2.3/upgrading.html

If all seems fine at the end, you can remove backed up files =rm *.bak=.