Writing Jasmine unit tests in ES6 and using Chutzpah as test runner Visual Studio 2019 - ecmascript-6

I am using the Jasmine testing library to write my unit tests. I'd like to use ES6 syntax to write the tests and am also testing files written in ES6.
I want to use Chutzpah as the test runner (I am open to other suggestions). At a basic level, I just want my tests discovered and ran in the Visual Studio Test Explorer menu. I cannot do this with ES6 files as Chutzpah isn't 'discovering' them if there's any ES6 syntax in the Javascript files (no import/export use, just something like plain arrow functions).
Ideally, I do not want to use node, hence the Jasmine library with no dependencies. At the moment I'm able to run my tests using the Chrome browser as a test runner. I'm using the standalone Jasmine library.
I'd like for these tests and the process to be transportable across both ASP.NET Core and ASP.NET projects. Also, it would be a huge plus if I can have this automated into an Azure build process so the JavaScript unit tests run any time I make a code commit, instead of me manually running the tests before I commit.
Is this achievable? Completely new to testing and setting up this kind of process.
I see my only pain point here is that I need to just transpile my ES6 code into ES5 and I can use all the tools I've mentioned (Chutzpah, Jasmine). However, I'm not sure how to do this without adding a node configuration.
If anyone can so much as to just give me an example of a simple transpilation process from ES6 to ES5 (without node), even that would be a huge help.

Related

Importing test coverage results into WebStorm

I have pretty complicated testing infrastructure that I scaffold before the test using gulp runner thus I can't use the build in debugger for unit tests in WebStorm v10.0.0.
During the test execution I generate the test coverage using karma-coverage that lands into reports/unit-test-coverage file.
Question: Can I import this file into WebStorm to see the coverage for my project?
No, there is currently no way to load coverage reports into IDE. Please follow WEB-10303

Is JUnit considered a plugin?

My thought is that "JUnit is a framework for testing java applications and is typically implemented as plugins (to popular IDEs)", but can't it also be considered a standalone testing tool if implemented as a standalone (although it might be a stupid idea)?
No, JUnit is a testing framework.
You would still require a "runner" to run your JUnit tests, be it Maven or a similar.
There are stand alone runners available so you can execute tests without build tools or an IDE.

TestNG equivalent of running NUnit tests with a .dll file on NUnit UI

So far I have been using eclipse to run testng tests, which requires me to code out a small program that includes a testng project; however this means every time I need to setup someone else's machine I have to pass alone the source codes so that they can run on their own eclipse.
I am sure it is not the best practice as when I was doing it in C#, I can build a .dll file to be imported in nunit's UI and I can execute the test from the nunit's UI. In this case I will just need to feed new users with the .jar or w/e file and tell them to use that UI tool to execute the tests. My questions fall below:
1) Are there any equivalent of nunit UI's for testng?
2) If so, how can I generate a .jar or w/e file of the testng project?

CI-friendly automated builds for as3/flex projects

Disclaimer: I am relatively unfamiliar with the flash build processes, so some/all of this may be misinformed nonsense. Please feel free to suggest alternative approaches.
We're currently developing a flex web app and our build situation is far from ideal. At present we're (as in individual developers) just building using FlashBuilder and deploying manually. The programmers are currently screaming bloody murder for two reasons, though:
The lack of CI is like going back to the stone age
We don't much care for FlashBuilder
(Note: We're only using FlashBuilder because it was the easiest way to set up a flex project in conjunction with Away3d and get it building / rendering correctly -- it's a stopgap solution).
As a predominately .NET development shop, we're used to doing continuous integration as well as continuous deployment. Ideally, we'd like to get something comparable to this for our flash projects without tying ourselves to a particular IDE.
Requirements:
The build process must be:
.. runnable via the commandline
.. runnable on both developer and CI build machines (and certainly not requiring an IDE!)
.. preferably as IDE-independent as possible (pragmatism will kick in though; if this causes a lot of friction we'll just pick one).
.. able to run on Windows (we develop using Windows)
We don't mind a touch of duplication or a few manual steps (e.g. tarting up the build scripts if we add a new project via an IDE, or generating one configuration from another if tools exist), but the less duplication / maintenance required the better.
I've read quite a few articles / blog posts and watched some short screencasts, but most of them are very thin on the ground on how the build system sits alongside IDEs. Most articles/screencasts have the same formula: How to create a "Hello World" build using a single file & text editors (no IDE).
I've not seen the topic of multiple libraries/projects etc. being broached, either.
After reading around the issue for a while, I'm considering investigating the following options:
Project Sprouts
Flexmojos
Maven Flex Plugin
buildr as3
Does anyone have any experience of the above solutions (or others I'm unaware of) and, if so, what do you make of them? Any help / pointers appreciated.
I recently started building with Gradle and the GradleFx plugin and I immediately fell in love with its power and ease of use.
Gradle is ANT + Maven + Ivy evolved and is primarily used from the command-line. You can:
write scripts in Groovy (a powerful Ruby-like language that runs in the Java Virtual Machine)
access all existing Maven and Ivy repositories as well as your own repos
use existing ANT tasks
integrate with CI (in Jenkins you just tick a checkbox to activate Gradle support)
although it has originally grown from the Java/Groovy community, it is in fact language agnostic. You add language-specific plugins for added functionality. GradleFx is such a plugin that provides you with additional ActionScript/Flex building tasks.
do easy multi-project builds. e.g. you can compile, unit test, package and deploy both your .NET service layer and your Flex client application with just one command.
use convention over configuration: if you stick to the conventions, your build scripts will be extremely terse
generate all kinds of reports: unit testing, checkstyles, codenarc, ...
generate Eclipse, IDEA or other IDE projects
all the things I haven't discovered yet
And best of all: it's very easy to learn. I had no knowledge of Maven before I started with Gradle and could get a multi-project build with some customizations working quite quickly.
Edit (comparison to Buildr AS3 and Maven)
I can compare this only to one of the projects you mentioned: Buildr AS3. It seems to start from a philosophy that is similar to Gradle's. But I've tried to use it about half a year ago and couldn't even get a simple 'Hello World' app to work. I e-mailed the developer for help: no response.
Compared to GradleFx: I had a small forum discussion with the developer (on a rather philosophical topic, since I didn't really need any help because it just worked right away). He answered within minutes.
As for Maven: (for what it's worth) I've only glanced at some configurations and they seem overly complicated when I compare them to a Gradle script.
There is one thing Maven does that you can't do with GradleFx (yet). It can pull the right Flex SDK from a Maven repo and build against that. With GradleFx you have to have your SDK's available locally.
I'm quite familiar with using maven as the main build tool and the flexmojos plugin from Sonatype. My experience has been a bit of a roller coaster with flexmojos. Maven is completely solid, it works all the time without issue, the only issue is the flexmojos plugin which has fluctuated a lot between versions. If you choose to go this route make sure to grab the source for flexmojos so you can see what your configuration options are actually doing to the command line parameters etc. For Flex 3.x flexmojos 3.x up to around 3.9 is good and works fine with regard to the goal for generating the .project eclipse files, believe there's also a mojo (a maven plugin) for generating intelliJ IDEA project files as well as others. If you're using Flex 4 you can compile with the latest flexmojos 4.0RC2 but it appears to me that the goal for generating flex/flashbuilder project properties is now gone (I'm not sure if this is because it's been replaced by another plugin altogether or what the deal is). However building with maven and flexmojos does fulfill all of your goals above (we also use it for building our service layer, so in a single mvn clean install we get a jar packed in a war packed in an ear with everything configured and a swf, that part is really nice). Also you can do continuous integration using bamboo (or simply write your own script that is triggered from a cron job or in windows as a batch file executed with a scheduled task if you don't have a *nix server around). Let me know if you'd like any more details or if I missed something major.
Shaun
I have been using Hudson, now Jenkins, with Ant for Flex automated builds and FlexUnit testing. Jenkins has some really useful plugins for integration with eclipse (and hence, FDT or FlashBuilder), Jira, SVN, Git etc., and it's free. Also, you can integrate the Ant build into Maven scripts, so I've found this to be a good and flexible solution for all purposes I've come across so far.
The Flex SDK comes with Ant tasks, and writing even elaborate Ant build scripts is quite easy - in fact, I'd been using Ant locally before, and I could reuse my existing scripts with only a few added extra compiler options for FlexUnit tasks.
However, it took a while to set up the system correctly for unit testing, because I'm running a headless server on Linux, and that implicates a rather complicated environment for ActionScript tests, because they run only in Flash Player. This, of course, is true for all CI scenarios using FlexUnit, regardless of which server you use.
Here's what I've learned:
FlexUnit needs a standalone debugger version of Flash Player installed, but Adobe only distributes binaries for the standard version on Linux. Therefore, compiling from source was necessary, and since my server system is stripped down to the bare necessities, it took some effort to install all the correct dependencies and get them to work.
The Flash Player needs hardware to run correctly: It uses graphics, therefore it needs a graphics card, and sounds, therefore it needs a sound card. On my headless server, this meant I had to install a VNC host to get it to run at all, and I had to eliminate any tests using sounds (those will now only run on local machines). If anyone ever comes across a working sound card emulation for openSuSE that I could use with the VNC client - you'll be my hero forever!
If you've set asynchronous timeouts in your unit tests, and/or you need to use setTimeout() to send delayed procedure calls, make sure the intervals aren't too short - I've had problems with tests that ran fine on any local machine, but broke the build on the CI server, because the Flash Player is considerably slower on the VNC client than on an actual graphics card.
I've also found this last issue to be a healthy lesson: Criteria for unit tests should not be based on assumptions about the system's performance, or at least be tolerant enough to succeed even on a slow machine.

Recompiling sources with a test specific jar

I have a multimodule project that is dependent on a rather large thirdparty library/apis. It is not possible to run automated junit tests with the actual library, since the apis interact with a system external to the management of the dev environment. As a workaround, we created classes that mocked the interfaces/apis so that we could do junits. We use eclipse as our IDE for development, so to run junits, we simply move the jar up higher in the classpath, recompile, run our junits, and everything works great.
Looking for a similar solution now that we are moving to Maven. Basically, after building our code, need to rebuild all of it again using the mock jar to run junit tests. This goes across all modules of the application. I tried adding the jar in the test scope, but that is only used for compiling the test classes; the sources classes are still compiled with the real jar. However, it fails at runtime since our mock jar does not match all signatures of the real jar (so a hot swap of the jar doesn't work; making all signatures match would be large undertaking). So the source needs to be recompiled with the jar.
So it appears there are two options:
1) Make a standalone test module that somehow pulls in all the source modules code and recompiles it using the mock jar and runs the tests or
2) Each module creates a testjar in addition to its installable jar that compiled with the mock jar, is then used by the dependent modules during the test phase.
Please advise. Any examples of how to do either of the above would be greatly appreciated.
Check out this link. I think it has what you need. You can handle this using two maven profiles. According to this you can have different dependencies for each profile.