How to test javascript (PouchDB) that requires a server -


I want to write a unit test on some JS which uses the Pouchbd library to use PouchDB, give me a simple HTTP server * must start.

My file structure is / public (all HTML and JS services have been served) / specs (all JS and Ruby spec files)

If I have a server in / public folder (Like a racket), I will not be able to use the specs in the / specs folder (because the / public folder root will become the web server).

If I had to start the racket in the / specs folder, then I would like to test JS files in the / public folder (because / the glasses folder web server will be rooted).

I think that if I reconstruct it so that my glasses are in my public folder, it can work but it looks very crappy. I think I can also duplicate JS files which I'm testing in the Glasses folder. Again, it feels great. Of course, there is a better way to do this.

* When I try to do the following simple code without running a simple http server, I get an error:

  var db = new PouchDB (' todos'); Db.put ({_ ID: '001'});   

I get:

"Operation Eye" in "Result = Type Error: Invalid" in the "Disapproved State" request

Trying the same code with an HTTP server using "Python -m SimpleHTTserver" will work fine (the request will be completed).

To use PouchDB, I need to start a simple HTTP server.

I'm not sure how you are using PouchDB (on the node? Browser? PouchDB server?), But you do not need an HTTP server to run it. You want to swap exactly and out in a backend: CouchDB, LEVDB, IndexedDB, or WebSQL.

It also has an in-memory backend that you can use in the node, and so it is ideal for testing.

Example Here is your HTTP-supported pouch:

  var db = new PouchDB ('http: // localhost: 5984 / mydb' );   

And here's your local sachets:

  var db = new 'myLocalDb';   

And here's your in-memory pouch (only works in node only):

  var db = new PouchDB ('My InMerdBee', {DB: Required ('Memmount'}});   

Does that help?

Comments

Popular posts from this blog

Pass DB Connection parameters to a Kettle a.k.a PDI table Input step dynamically from Excel -

multithreading - PhantomJS-Node in a for Loop -

c++ - MATLAB .m file to .mex file using Matlab Compiler -