addressalign-toparrow-leftarrow-leftarrow-right-10x10arrow-rightbackbellblockcalendarcameraccwcheckchevron-downchevron-leftchevron-rightchevron-small-downchevron-small-leftchevron-small-rightchevron-small-upchevron-upcircle-with-checkcircle-with-crosscircle-with-pluscontroller-playcredit-cardcrossdots-three-verticaleditemptyheartexporteye-with-lineeyefacebookfolderfullheartglobe--smallglobegmailgooglegroupshelp-with-circleimageimagesinstagramFill 1languagelaunch-new-window--smalllight-bulblightning-boltlinklocation-pinlockm-swarmSearchmailmediummessagesminusmobilemoremuplabelShape 3 + Rectangle 1ShapeoutlookpersonJoin Group on CardStartprice-ribbonprintShapeShapeShapeShapeImported LayersImported LayersImported Layersshieldstar-shapestartickettrashtriangle-downtriangle-uptwitteruserwarningyahooyoutube

Re: [jsmn] JavaScript Unit Testing?

From: Cjad E.
Sent on: Saturday, August 1, 2015, 4:15 PM
@robert - Not going outside the firewall is a policy issue. So no SauceLabs.
@will - I'll have to take a deeper look at Geb. May be a good alternative to a web project using maven in Jenkins. I think I can use Geb + Node.js in Jenkins to accomplish the same test runner task.
@John - Nice presentation.

All - I know I generically called these Unit Testing when it's really multiple types. Here are the definitions we use:
Unit tests are written from a programmer's perspective. They ensure that a particular method of a class successfully performs a set of specific tasks. Each test confirms that a method produces the expected output when given a known input. We use jsmeter.info to determine many things, including Cyclomatic Complexity - basically tells us a count with every path through a function so we can gauge how many unit tests to write and also if a function is overly complex and may need to be refactored, etc.
 
Functional tests are written from a user's perspective. These tests confirm that the system does what users are expecting it to.
 
Integration tests are tests written in which individual software modules are combined and tested as a whole. It often includes testing across tiers, such as front-end and app stack to database or other external systems.
 
Regression tests are all above types of tests written for previous releases.

Hope these help,
-Chad

On Wed, Jul 29, 2015 at 10:39 AM, John Urberg <[address removed]> wrote:
I did a presentation last year at TC Code Camp on testing JavaScript in a Grails app.  We separate out our JavaScript code into separate modules, test them independently using Jasmine and then run them thru phantomjs as part of the build.  We are able to export the results into junit xml format so it shows in the Jenkins build results.  We also use jscover to run coverage reports and show that with the build results.  

Slides and example code are available on github: https://github.com/jurberg/grails-js-presentation

On Wed, Jul 29, 2015 at 8:28 AM, robert tomb <[address removed]> wrote:
This is a great discussion. My team at ReachLocal is moving beyond their JS unit testing in Jasmine and doing integration testing in the browser for multiple browsers using Sauce Labs. We are still driving those integration tests with mocha+chai because it makes for very readable tests, but I would not call in-browser testing unit testing, even if it were driven by a classical nUnit framework.

The type of testing that's happening once you evaluate a JSP, serve it through an app server, and test it in a browser is crossing a lot of boundaries and creates a lot of complexity. Don't get me wrong, they are super important and should be run as frequently as is practical, but people in your organization will have certain expectations for unit tests. Tests like these may not meet unit testing expectations for speed, portability, durability, and setup overhead.

So many organizations are loathe to put time/effort into testing that I believe it's important to set expectation, which is all I'm recommending by not calling these unit tests. They can still be developer-driven (designed, written, executed) tests.

Anyway, there is a way to tunnel back to your behind-the-firewall services from Sauce (and other tools) if you can get permission, so don't write it off as a technical problem. If it's a policy problem, I understand (I may not agree with said policy, but I understand...).

If anyone is interested in meeting early for the next JSMN meeting, it would be good to grab a whiteboard at CoCo and talk testing. I agree that this could grow into an eventual presentation topic.

--rt


 -------- __@ 
 ----- _`\<,_ 
 ---- (*)/ (*)
 ~~~~~~~~~~~~~~
robert tomb
[address removed]
twitter: @bikeonastick
http://bikeonastick.blogspot.com/

On Tue, Jul 28, 2015 at 10:39 PM, CT Yeung <[address removed]> wrote:
Jeff, Chad,

Off the mark from discussion, I follow the angular recipe.  In Jenkins, Karma invokes jasmine unit tests for js and nunit for .net services.

CT

On Tue, Jul 28, 2015 at 6:52 PM, Cjad Elstad <[address removed]> wrote:

Unfortunately we cannot go outside our firewalls so SauceLabs is out. :(
I will see about putting together a presentaton, but not sure I can make the August meetup.

On Jul 28,[masked]:51 PM, "Jeff Conrad" <[address removed]> wrote:
Chad, we have a similar app framework (spring tiles jquery bootstrap backbone) and use qunit, junit, spock and Geb, selenium as well.  If you already have selenium it is similar to get your tests running in geb.  Geb allows you to run automated tests via Jenkins to saucelabs.com which gets you cloud testing across devices IE11 included.  I like having different startegies: unit level, functional, and regression tests like you mention but I'm also an advocate of stochastic testing to examine a variety of inputs.  I'd be interested in seeing a tech talk of demo if you're going to do one.

Sent from Yahoo Mail on Android


From:"Cjad Elstad" <[address removed]>
Date:Mon, Jul 27, 2015 at 18:28
Subject:Re: [jsmn] JavaScript Unit Testing?

I have an implementation that works well for our needs. Before we go full boat across our applications, I wanted to bounce it off others to see if there was a better, or more simplified approach.
In reading Testable JavaScript over the weekend, the author is implementing something very similar so I feel I am not far off a solid approach.
So here's an info dump on our implementation...

Our implementation for unit testing is:
QUnit scripts being injected in to our dynamic pages, Jenkins with Selenium Grid plugin as our test runner (opens browsers, logs in to app, navigates to pages and waits for textarea element to be populated, takes those results and creates XML files which Selenium sends to Jenkins and Jenkins automagically renders then on a Test Results page).
I have run YUITest, QUnit, and Mocha/Chai in this environment. - Mocha will not let me get JUnit results in a variable, only to the console, which is not useful and I cannot get both displayed and XML formats without writing my own logic off the 'suite end' event. I didn't feel like writing my own plugin for Mocha to do that and QUnit will display and allow me to save off the results easily.
The implementation handles the following types of tests: Unit, Functional, Integration, and by default Regression.

Here's our tech stack: Enterprise Java web app, Spring MVC, Apache Tiles, JSP's with JSTL's, YUI framework (switching to jQuery).

Our needs are:
1. Test in browser with all JSP's creating the pages. And web drivers often emulate browser functionality, but are not perfect.
2. Pre-commit testing - while developer is running code, tests should be able to run.
3. Post-commit/Post-deploy testing - after deploying to our enterprise development environment, test should be able to be run on demand.
4. #2 and #3 need to be the same set of scripts. Our skill-set is JavaScript for our front-end team.
5. We need to report out our unit tests to a web/wiki page or Jenkins for auditing.
6. Must run in IE11.

As far as do I have any code samples? Not right now, and my code is internal. I was thinking about creating a github or two sometime down the road which is also why I was checking to see if my solution is of value to the community.

Thoughts?
Hope this helps. Sorry for the long post.
-Chad

On Jul 27,[masked]:26 PM, "robert tomb" <[address removed]> wrote:
Chad:

Sorry, I don't know of any groups focused on JS unit testing, but unit testing would be great topic at this meetup! Do you have small, encapsulated bits of logic you want to test or are you looking for more of an integration test to see how your JS executes within the web page? Your mention of JSPs led me to think you're really looking for a way to test in browser, which probably means you have to have that servlet container running. (Which... in turn means a lot of sitting around waiting for things to start up.)

We should talk at the next meeting. I like to talk about the advantages and disadvantages of testing at various levels and how different architectures contribute to or resolve those problems.  :-)

--rt


 -------- __@ 
 ----- _`\<,_ 
 ---- (*)/ (*)
 ~~~~~~~~~~~~~~
robert tomb
[address removed]
twitter: @bikeonastick
http://bikeonastick.blogspot.com/


On Fri, Jul 24, 2015 at 10:35 PM, Cjad Elstad <[address removed]> wrote:

Anyone know of a good JS unit test group? In MN would be even better, but I'll take a good one anywhere.
I am looking to hear how others are handling JS unit testing with JSP's as well as hear what others are doing in a more enterprise space.
Thanks in advance,
-Chad





--
Please Note: If you hit "REPLY", your message will be sent to everyone on this mailing list ([address removed])
This message was sent by Cjad Elstad ([address removed]) from JavaScriptMN.
To learn more about Cjad Elstad, visit his/her member profile
To report this message or block the sender, please click here
Set my mailing list to email me As they are sent | In one daily email | Don't send me mailing list messages

Meetup, POB 4668 #37895 NY NY USA 10163 | [address removed]





--
Please Note: If you hit "REPLY", your message will be sent to everyone on this mailing list ([address removed])
This message was sent by robert tomb ([address removed]) from JavaScriptMN.
To learn more about robert tomb, visit his/her member profile
To report this message or block the sender, please click here
Set my mailing list to email me As they are sent | In one daily email | Don't send me mailing list messages

Meetup, POB 4668 #37895 NY NY USA 10163 | [address removed]




--
Please Note: If you hit "REPLY", your message will be sent to everyone on this mailing list ([address removed])
This message was sent by Cjad Elstad ([address removed]) from JavaScriptMN.
To learn more about Cjad Elstad, visit his/her member profile
To report this message or block the sender, please click here
Set my mailing list to email me As they are sent | In one daily email | Don't send me mailing list messages

Meetup, POB 4668 #37895 NY NY USA 10163 | [address removed]




--
Please Note: If you hit "REPLY", your message will be sent to everyone on this mailing list ([address removed])
This message was sent by Jeff Conrad ([address removed]) from JavaScriptMN.
To learn more about Jeff Conrad, visit his/her member profile
To report this message or block the sender, please click here
Set my mailing list to email me As they are sent | In one daily email | Don't send me mailing list messages

Meetup, POB 4668 #37895 NY NY USA 10163 | [address removed]




--
Please Note: If you hit "REPLY", your message will be sent to everyone on this mailing list ([address removed])
This message was sent by Cjad Elstad ([address removed]) from JavaScriptMN.
To learn more about Cjad Elstad, visit his/her member profile
To report this message or block the sender, please click here
Set my mailing list to email me As they are sent | In one daily email | Don't send me mailing list messages

Meetup, POB 4668 #37895 NY NY USA 10163 | [address removed]





--
Please Note: If you hit "REPLY", your message will be sent to everyone on this mailing list ([address removed])
This message was sent by CT Yeung ([address removed]) from JavaScriptMN.
To learn more about CT Yeung, visit his/her member profile
To report this message or block the sender, please click here
Set my mailing list to email me As they are sent | In one daily email | Don't send me mailing list messages

Meetup, POB 4668 #37895 NY NY USA 10163 | [address removed]





--
Please Note: If you hit "REPLY", your message will be sent to everyone on this mailing list ([address removed])
This message was sent by robert tomb ([address removed]) from JavaScriptMN.
To learn more about robert tomb, visit his/her member profile
To report this message or block the sender, please click here
Set my mailing list to email me As they are sent | In one daily email | Don't send me mailing list messages

Meetup, POB 4668 #37895 NY NY USA 10163 | [address removed]





--
Please Note: If you hit "REPLY", your message will be sent to everyone on this mailing list ([address removed])
This message was sent by John Urberg ([address removed]) from JavaScriptMN.
To learn more about John Urberg, visit his/her member profile
To report this message or block the sender, please click here
Set my mailing list to email me As they are sent | In one daily email | Don't send me mailing list messages

Meetup, POB 4668 #37895 NY NY USA 10163 | [address removed]

People in this
group are also in: