How Atom Editor Browser run ES6 Jasmine Tests - javascript

I'm using Atom editor, and it runs javascript test with Jasmine for ES6, with functionalities that are not read by any browser so far.
I'm trying to find out how it is done. I need to run the tests outside Atom. I will read Atom source code in order to find out, but maybe some one already know that?
Another alternative I was thinking was to use Babel to translate to ES5 and then run the tests, but Atom way seems better.
Any ideas?

Related

What is Babel's purpose in relation to Jest?

I have an API project where I've been successfully using Jest (v26.x because code coverage doesn't work with v27.x on Windows 10 for me) for unit testing. I've run into a situation where I'm trying to achieve sufficient code coverage on a module I'm testing, but not all functions in that module have been exported, so this is impeding my ability to achieve this.
I came across the NPM package rewire, which worked beautifully, as it allowed me to mock any functions I wanted. The only problem is that code coverage doesn't acknowledge the lines tested via rewire and the devs in the Jest GitHub said they don't plan to support this.
So then I saw a couple of posts that people were successfully using babel-plugin-rewire to achieve the same thing as rewire, but that code coverage lines were successfully being acknowledged with this package. However, I cannot get this setup to work.
I think I understand the basics of Babel, as it pertains to browsers. It will take newer JS code and transpile/polyfill so that older JS code is generated that will work with older browsers of your choice.
But then I started seeing stuff about babel-jest and Babel being integrated into Jest and so on. Aside from the fact that I can't get babel-plugin-rewire to work, I feel like I don't even understand the basics of how Babel and Jest work together, or why Jest needs Babel.
What is the relationship between Babel and Jest?

WebStorm not recognising browser.get or browser.getTitle()

Wondering if someone could help with a problem I'm having with WebStorm and trying to run Protractor tests using the Jasmine framework.
I believe I have imported all the relevant JavaScript libraries and Node packages but when using the IDE the browser part of the code is always underlined and WebStorm says "unresolved variable". For example browser.getTitle().
Could anyone explain why I'm having this issue? I have tried removing the libraries and re adding them and adding some additional ones which I thought might make a difference.

Adding code coverage to async node.js mocha tests in WebStorm

I am trying to set up code coverage for my node.js unit tests.
What I am trying to do is this:
Use WebStorm for running tests
use Mocha (and co-mocha) as a testing framework
Use yield and generators for making my test code more readable
See the code coverage of my source code via the WebStorm UI (hoping to see my source code files color-coded according to code coverage)
The first two points are going fine, the third one is tripping me up.
Unfortunately WebStorm doesn't provide coverage support for Mocha:( Please follow WEB-10373 for updates

What the best way to debug gulp plugins during developing using webstorm

I'm trying to find the best way for debug gulp plugins during developing using webstorm. I have a project example and couple gulp plugins, and I want to trace and inspect the code in webstorm right after I run gulp command in terminal. Ideally I want to add debugger statement or breakpoint inside the webstorm to trace the code execution.
Use this guide (shameless self promotion) to setup your configurations. Then debug should just work as is.
Also, you won't need to run gulp from commandline separately, since webstorm will do that for you.
this is an old question, and has an very good answer,
here is another one with VS Code
debugging-gulp-in-VS-Code

How can we run JavaScript jasmine tests from Jenkins (Hudson) without loading a JSP?

We have a rich web client. Our controllers and service facades are written in coffeescript (JavaScript) and jquery. In the past they would have been java.
To run our JavaScript jasmine tests from Jenkins/Hudson, we use java's junit and htmlunit to load a test oriented jsp page which includes the jasmine specs.
When the Htmlunit tries to run, it blows up trying to getPage() probably because of an XML parser class path which is extremely challenging to track down in our world.
We just want to be able to run our JavaScript tests from Jenkins and have it report failure if a JavaScript test does not pass. We are just using jsp and htmlunit in order to run JavaScript tests. Can we load the JavaScript tests and javascript code into a JavaScript engine with Jenkins as the thing that kicks it off? If so, how?
Sounds like you're in a Java environment. My jasmine-maven-plugin might be a good fit.
Jasmine Reporters would also be a solution. It has instructions for running headlessly via PhantomJS for example, and it can generate JUnit XML so Jenkins can understand the test results natively, graphing test count, duration, and failure over time.
Also, the "xvfb-run" wrapper often provided with xvfb is a great help here, so you can do "xvfb-run phantomjs.runner.sh ..." in a truly headless environment.
I've previously solved this problem by running the tests with a node.js plugin called jasmine-node
This solution of course requires node.js and a few node modules to properly run the jasmine tests. There is no real browser running the tests, but an emulated one using a module called jsdom, which basically creates a headless browser, and more specifically, a DOM, which the tests can interact with.
There's node modules for jQuery, underscore and propably other too, so these can be tested too. You can even skip the whole browser emulation if you'd rather run the tests in a browser, though I find it too cumbersome compared to automated Jenkins testing.
jasmine-node generates jUnit test reports, which Jenkins can interpret just fine.
I just realized there is some jenkins-jasmine-node plugin that might ease this process.
Grunt is your friend
use grunt http://gruntjs.com/
with grunt jasimine https://github.com/gruntjs/grunt-contrib-jasmine
with nodejs http://nodejs.org/
on jenkins using https://wiki.jenkins-ci.org/display/JENKINS/NodeJS+Plugin
got this setup and it's really nice, plus this gives you a place to start making your build server do other nice things such as deployment, unit testing, etc you know, other nice things
Can you use selenium? That would actually use a real browser then and get as close to the real environment as possible.

Categories