Easiest way to run JavaScript unit tests.

Jarek's Avatar

Jarek

08 Apr, 2015 03:44 PM

Hi,
I have a question related to JavaScript unit testing.

I've checked the documentation site: http://www.appveyor.com/docs/running-tests, but found no information regarding testing using e.g. Jasmine or QUnit frameworks. While e.g. Visual Studio unit tests are discovered and executed automatically, is there currently an easy way to run JavaScript unit tests in a similar manner?

There is one workaround I've found, which is described here: http://blog.icanmakethiswork.io/2014/09/running-javascript-unit-tests-in-appveyor.html, but is there any alternative supported by AppVeyor out of the box?

Kind regards

  1. Support Staff 1 Posted by Feodor Fitsner on 08 Apr, 2015 08:55 PM

    Feodor Fitsner's Avatar

    Well, the approach described in that blog is pretty straightforward. The only challenge there is parsing and importing results - this is something we could build into AppVeyor.

    Currently, AppVeyor is auto-discovering .NET assemblies only with tests for MSTest, xUnit, NUnit and MSpec.

  2. 2 Posted by Jarek on 09 Apr, 2015 08:50 AM

    Jarek's Avatar

    Is auto-discovering of JavaScript unit tests planned to be added in the future or are there any technical contraindications blocking that idea?

  3. Support Staff 3 Posted by Feodor Fitsner on 09 Apr, 2015 04:45 PM

    Feodor Fitsner's Avatar

    Well, I guess the technical limitation here is that unlike .NET assemblies JavaScript programs/files do not have meta-information. Otherwise, is there any way to recognize test inside of JavaScript file?

  4. 4 Posted by Jarek on 09 Apr, 2015 05:07 PM

    Jarek's Avatar

    I don't know that. I'll try to investigate in that direction, but I can't promise to find a reliable way.

    Why I've asked about that, is because I'm using Resharper. And with Resharper you have an option "run all test from solution". That option automatically discovers and runs all tests - not only .NET related, but even JavaScript unit tests. So it must be a way to detect them.

    Some brief information related to that Resharper feature:
    http://blog.jetbrains.com/dotnet/2011/03/25/resharper-6-introduces-support-for-javascript-unit-testing/
    https://www.jetbrains.com/resharper/webhelp70/ReSharper_by_Language__JavaScript__Unit_Testing.html

  5. Support Staff 5 Posted by Feodor Fitsner on 09 Apr, 2015 05:21 PM

    Feodor Fitsner's Avatar

    Thanks for the hint - will take a look.

  6. 6 Posted by Jarek on 09 Apr, 2015 09:56 PM

    Jarek's Avatar

    I've just started reading a bit about that stuff and understood that Resharper in the context of execution JavaScript unit tests behaves just like any other test runner.

    Alternative test runner compatible with QUnit or Jasmine unit test frameworks is e.g. Chutzpah. The list of various test frameworks and the corresponding test runners is here. Finally, some actual testing (either in the full browser or just headless testing) is used to launch the unit tests via a suitable test runner (headless testing can be executed in PhantomJS - already integrated in Travis CI).

    JavaScript test files normally contain some meta information about used unit test framework e.g.
    /// <reference path="QUnit.js" /> or /// <reference path="Jasmine.js" /> etc, so such preamble could be used to determine if the script file contains real tests.

    But probably this meta-info is not required at all - Chutzpah doesn't seem to require any preamble at the top of script file - it detects appropriate framework automatically. Simple construction below:
    .\chutzpah.console.exe project_directory will recursively scan for .js files within project_directory and run any files it believes are test files.

  7. Support Staff 7 Posted by Feodor Fitsner on 10 Apr, 2015 04:34 AM

    Feodor Fitsner's Avatar

    Thanks for additional information - really appreciated!

    I've added a new issue: https://github.com/appveyor/ci/issues/226

  8. 8 Posted by Jarek on 10 Apr, 2015 09:00 AM

    Jarek's Avatar

    No problem, you're welcome.

    I'm glad I was able to draw your attention to this idea, so that its implementation is now being considered. I think AppVeyor is really great tool and this tiny feature would add an additional value to it, simplifying stuff quite a bit.

    Regards

  9. 9 Posted by Andrew Flierman on 21 Jan, 2016 10:21 AM

    Andrew Flierman's Avatar

    Curious about the status of this issue. We're very interested in the option to run JavaScript unittests on Appveyor

  10. Ilya Finkelshteyn closed this discussion on 25 Aug, 2018 02:03 AM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac