How to test foreground JavaScript library and integrate with Travis?

I have already experimented with testing NodeJS libraries using Jasmine or Mocha, but I do not know how to test front-end projects. I found tutorials online, but everything includes a task manager in the workflow, and I would like to know how to do it without it.

I found the following question close to what I am asking:

Using Travis-CI for JavaScript client libraries?

In my case, I use Jasmine and have already created the Jasmine library SpecRunner.html , Jasmine and spec/mylibSpec.js . The test passes when I run SpecRunner.html in my browser.

Now, how do I integrate this with Travis, without Grunt / Gulp / Brunch / etc?

I heard the words "PhantomJS" and "Selenium", and I think this is due to what I'm trying to accomplish. Is there a "hello world" -like project with the tests and integration of Travis, from which you can learn?

+5
source share
1 answer

The Travis documentation contains three main ways :

  • PhantomJS titleless browser
  • launching Firefox with a virtual display or
  • using VMware Saucelabs

Testing with PhantomJS is the fastest because it does not model the display (it still allows you to create screenshots). PhantomJS comes with a run-jasmine example .

The phantom script test can be executed directly by simply running

 script: phantomjs run-jasmine.js 

in your .travis.yml , without the extra overhead of a build system like Grunt.

If testing your project requires a real browser graphical interface, this leaves you with options 2 or 3.

Saucelabs browser virtual machines have the advantage of real cross-browser testing; if your project is open source, they offer a free <free rel = "noreferrer">. They also provide a detailed tutorial for your specific use case: Travis + Jasmine + Saucelabs , which, however, requires Grunt to run.

+6
source

Source: https://habr.com/ru/post/1214422/


All Articles