jQuery Plugin TDD Starting Point [closed] - javascript

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 5 years ago.
Improve this question
I have some existing Javascript code that I'm looking to port to a jQuery plugin. The code itself is nothing complex: Flickr API photo gallery with varying photo sizes, a few other things. I coded it up quickly and it's stable enough, but I want to redo it the "right way".
I set up a simple TDD environment based off Yeoman, with Grunt and Mocha, and it works well. The problem I have is that my plugin will work like most jQuery plugins, having a simple entry point:
$( '#ele' ).myAwesomePlugin( { ... } ); // Do all the things
and I'm scratching my head at where to start writing tests. While I already have most of the code to complete the plugin, I'm trying to go through the motions of the development being driven by the tests, and I don't know how to transition from this high-level point into the smaller portions of the code.
Some stages of the program flow would be: communicate with Flickr, gather photos (or not), divide them up into various sizes, and arrange them into a container.
The plugin itself would (ideally) only have one publicly-accessible method, but, if that's the case, how should my tests hook into my deeper logic? Should I be splitting my code up into smaller, testable chunks that aren't jQuery plugins, and then combine them? I'm curious if there's a way for tests themselves to drive that development.
Any recommendations on reading material or articles would be very helpful. I'm pretty excited finally to be doing TDD!

Here is a link to test-driven-development of jquery plugins with Jasmine.
BDD Testing of jQuery plugins using Jasmine
Jasmine is similar to Mocha, so you could follow the tutorial with either Jasmine or Mocha.

Related

How to Remove Unused javascript From Website [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 2 years ago.
Improve this question
I'm trying to speed up my website. I used www.unused-css.com/ to trim away excess CSS, but I cannot find anything similar for JavaScript. Is there an online service that can detect the js code being used and then trim away the unused code?
Here is the website with the problem: IQ Tests for Kids
I'm using bootstrap code and it is very bloated. I'm sure that I'm only using a fraction of js because I trimmed down my HTML as well.
The best you are going to get is running the JavaScript itself through a dead code removal process, such as the one provided by the Google Closure Compiler with ADVANCED_OPTIMIZATIONS enabled or Uglify's dead_code option. Some people even combine both of these.
Tree shaking is an even better process you will hear people talk about. But this is more difficult to achieve in your case, because tree shaking involves using ES6 modules, which the code you are dealing with almost certainly is not. Thus it would be a lot of work to get that going, as you would have to modify the code.
Don't know any online tool for that, but there are techniques to do what is called "tree shaking". You can google about it more.
Best my used tools to have it working are webpack and Flow
Webpack is quite general tool to make all kind of magic with JS, while Flow is type checking tool which, if you have type checking active can provide very good tree shaking.
But as you mentioned, you are using Bootstrap, so best place to start looking at would be customize your build:
http://getbootstrap.com/customize/

Which JS library is used in Jira Workflow Designer? Looking for library for drawing dependencies on schemas [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 6 years ago.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Improve this question
I'm looking for the JS library similar to the one used in Jira Workflow editor (example below).
I need to visualize dependencies between elements and probably(in the future) make it configurable by mouse (with drag'n'drop).
P.S. I've tried to detect name of this library within the Developer Console, but had no luck (probably it's Atlassian proprietary library).
If you have Jira you can explore it yourself: Project -> Administration -> Workflows
After looking at the JS source for the Workflow Designer in Atlassian JIRA in the console, it seems to be using a mixture of Atlassian developed code and a whole host of other libraries.
However, the drawing part at least seems to be extending functionality provided by Draw2D JS library. Another option for what you want to achieve could be Raphael JS which is also a JS drawing library.

How to tackle JavaScript powered dynamic form [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 7 years ago.
Improve this question
I'm doing a hobbyist Django project. I feel comfrtable with both Python and Django, but I rarely use JavaScript, and mostly it ends after loading and initializing the library.
This time I want to tackle it a bit more, I have a good task, but I don't even know how to tackle it correctly.
I want to build something like this, with the main functionality being clicking on available statuses, and then 'painting' given hour blocks with them. After that you hit save, and it saves the data via Django
Conceptually I have an idea how to make this, but I don't know where to start. Should I use some kind of framework? Is there any plugin that could help me with this? Should I put this all into some kind of JS library?
Thanks in advance for any help
I've started knocking something up which is a good starter for 10 - have a look on JSFiddle. I can't do any more, as I've got to shoot off now.
I'd basically go for minimal markup, and have everything as a component.
I'd recommended including Bootstrap to handle your layout (grids), and jQuery to write less/do more with JS.
I wouldn't start with a framework - the thing you're doing is (fairly) noddy, and you'll do a fine job writing it yourself. You might want to check out jQuery UI to help out with some drag functionality.
General advice - read up about JS design patterns.
http://jsfiddle.net/daveSalomon/nxwytdqw/

How to mock DOM object in Js? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 7 years ago.
Improve this question
I would like to add some unit tests to test UI of some javascript. However I don't want to use HTML page, I would like to use node.js.
Is there any js library which I can use to mock HTML DOM, like document?
Yes, You can use jsdom for this. It is what facebook's jest framework uses behind the scenes to run tests on components that use DOM via node.
You could consider using a headless browser. Depending on your technology stack there are multiple options. When using node.js A popular one is phantom.js. There're different test runners for different test frameworks, here's an overview of them.
mocha.js is a popular testing framework which has a phantom.js test runner.
If you're using browserify there's also mochify which works really nice.
There's also jsdom but one caveat with that one is that it only works with io.js from v4.0.0.

Browserless, ant-task-oriented Javascript Unit Testing? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 7 years ago.
Improve this question
I'm looking for a javascript unit test framework that I can use as part of my automated maven build. This CANNOT use an actual browser, and it MUST be fully browserless.
I've tried looking at a few posts on SO, but none seem to meet my needs. Is there such a javascript unit tester? I'm anxious to find out.
I was trying to solve the same problem. It seems, that this is not as common, as one might think from our perspective.
RhinoUnit looks very good.
If you need browser capabilities within Rhino, take a look at
http://ejohn.org/blog/bringing-the-browser-to-the-server/
http://groups.google.com/group/envjs
http://github.com/thatcher/env-js/tree/master
There are two projects called JSUnit (www.jsunit.net) and (jsunit.berlios.de). The latter is designed to work with Rhino and Maven. Note that there will be browser-specific problems that such tests will not discover, but it should help with basic functionality.
Not sure about a JavaScript unit testing framework, though I'm sure there is one. But I would probably look towards Rhino as JS interpreter.
http://www.mozilla.org/rhino/
If your JS references any of the browser/DOM you'll also need to mock/stub those...
Have you tried JSunit?
AFAIK, javascript is a language specifically designed to run in the browser.
Have you considereds j-unit tests? They do still run in the browser however.

Categories

Resources